Need help with include sc to bb

I have a bitbucket-pipelines.yml for pull-requests.
But when start "Container 'docker' exceeded memory limit."
How to organize code verification at the moment pull-requests?

clone:
      depth: full 
definitions:
      caches:
            sonar: ~/.sonar/cache  
      services:
          docker:
            memory: 2048
      steps:
      - step: &build-test-sonarcloud
              size: 2x
              name: Build, test and analyze on SonarCloud
              caches:
              - sonar
              script:
              - pipe: sonarsource/sonarcloud-scan:1.0.1
              variables:
              DEBUG: "true"
              SONAR_SCANNER_OPTS: -Xmx512m

      - step: &check-quality-gate-sonarcloud
              name: Check the Quality Gate on SonarCloud
              script:
              - pipe: sonarsource/sonarcloud-quality-gate:0.1.3

pipelines:
  pull-requests:
    '**':
      - step: *build-test-sonarcloud
      - step: *check-quality-gate-sonarcloud

Hello,

And welcome to the community forum!

Do you have more log or information about when this happens exactly in the build-test-sonarcloud step ?

What’s the size of the project you are trying to analyze ? And what languages does it use ?

1 Like

Hello.

Yes, when start build-test-sonarcloud.
Last log

INFO: 540 source files to be analyzed
INFO: 141/540 files analyzed, current file: docs/themes/default/js/vendor/jquery-ui.js
INFO: 236/540 files analyzed, current file: docs/themes/frontend/desktope/libs/jquery-ui/jquery-ui.js
INFO: 390/540 files analyzed, current file: docs/themes/frontend/desktope/modules/vin-request-list/components/vue-paginate.js
INFO: 494/540 files a

php + js + html
Size 400 mb

Ok thanks for the information.
Is that the full log ? You don’t see any errors before is stops ?

And does the analysis work if you try to run it locally (not in Bitbucket pipeline) ?

1 Like

No, this full log
pipelineLog-21.txt (13.4 KB)

Yes, we launched the project locally, there were no errors, but I would like to automate this process

The main goal is to get bugs pull-requests, and fix them before release

Looking at the logs it seems like you are also analyzing all the code of the library you use in your project, I see a lot of jquery files. So you should start by ignoring all those files that are probably minified and will raise a lot of issue that you don’t want to fix. You can do it by setting the sonar.exclusions parameter.

I also noticed that you have some files that are not parsable by our css analyzer, so you wont get issues reported on these:

ERROR: Failed to parse file:///opt/atlassian/pipelines/agent/build/docs/themes/frontend/desktope/core/global.css, line 163, Unexpected }
ERROR: Failed to parse file:///opt/atlassian/pipelines/agent/build/docs/themes/default/css/jstree/default/style.css, line 605, Unknown word
ERROR: Failed to parse file:///opt/atlassian/pipelines/agent/build/docs/themes/default/css/acat.css, line 1008, Unclosed block
1 Like

Thanks.
You can still tell
I use the following code to exclude unnecessary files, but for some reason it skips files .css and .js

 - step: &build-test-sonarcloud
          size: 2x
          name: Build, test and analyze on SonarCloud
          caches:
          - sonar
          script:
          - pipe: sonarsource/sonarcloud-scan:1.0.1
          variables:
          EXTRA_ARGS: -Dsonar.exclusions=**/*.xml,**/*.swf,**/*.js,**/*.css,**/*.less,.hg/**/*,deploy/**/*,logs/**/*,node_modules/**/*,docs/acat/**/*,docs/assets/**/*,docs/build/**/*,docs/ckeditor/**/*,docs/css/**/*,docs/ma/**/*,docs/mobile/**/*,docs/pic/**/*,docs/prices/**/*,docs/rt_files/**/*,docs/tacat/**/*,docs/upload/**/*,docs/xhprof/**/*,docs/protected/runtime/**/*,docs/protected/vendor/**/*,docs/protected/extensions/**/*,docs/upload_local/**/*,docs/upload/**/*,docs/themes/**/*,docs/protected/views/**/*
          DEBUG: "true"
          SONAR_SCANNER_OPTS: -Xmx512m

Of course, because you have the following patterns in your exclusion:
**/*.js,**/*.css

This mean ignore all js and css files everywhere is my project… So you probably want to review that exclusion list and try again.

1 Like

Yes that’s right.
At the first stage I want to exclude everything and check only one protected folder
Then I tried to exclude all styles and js so as not to load bb
Maybe you know how to make it select a specific folder for verification so that I don’t have to write a bunch of rules.
Thanks

And one more mistake
I removed the files but for some reason the sonar wants to check them and crashes
I could not find the full description for setting bitbucket-pipelines.yml
Can you suggest where you can see examples?
If there are no examples, tell me how to select only the folders that interest me

pipelineLog-24.txt (12.6 KB)

 - step: &build-test-sonarcloud
          size: 2x
          name: Build, test and analyze on SonarCloud
          caches:
          - sonar
          script:
          - pipe: sonarsource/sonarcloud-scan:1.0.1
          variables:
          EXTRA_ARGS: -Dsonar.exclusions=**/*.js,**/*.css,**/*.php
          DEBUG: "true"
          SONAR_SCANNER_OPTS: -Xmx512m

Yes it’s possible to select only the folders that interest you with sonar.sources, here is the doc for the existing analysis parameters.

Ok.
I do not understand.
I started a test with parameters

EXTRA_ARGS: -Dsonar.sources='docs/protected/models/*' 

next test
EXTRA_ARGS: -Dsonar.sources=docs/protected/models/*
and next
EXTRA_ARGS: -Dsonar.sources=docs/protected/models/**.php

But the scanner does not check files from these directories. Tell me what should be the setting to check the docs / protected / models / directory?
I found only a description in the documentation, but I don’t see any examples

Comma-separated paths to directories containing main source files. Read from build system for Maven, Gradle, MSBuild projects. Defaults to project base directory when neither sonar.sources nor sonar.tests is provided.

Looking at this sample project, the following should work:

- pipe: sonarsource/sonarcloud-scan:1.0.1
  variables:
    EXTRA_ARGS: '-Dsonar.sources=docs/protected/models,another/directory'