Error when Run pipeline

Not sure how to configure bitbucket-pipelines.yml.

image: gcc:6.5

clone:
depth: full # SonarCloud scanner needs the full history to assign issues properly

definitions:
caches:
sonar: ~/.sonar/cache # Caching SonarCloud artifacts will speed up your build
steps:
- step: &build-test-sonarcloud
name: Build, test and analyze on SonarCloud
caches:
- sonar
script:
- export SONAR_SCANNER_VERSION=4.4.0.2170
- export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
- export BW_OUTPUT=$HOME/.sonar/bw-output
- mkdir -p $BW_OUTPUT
- curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
- unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
- export PATH=$SONAR_SCANNER_HOME/bin:$PATH
- export SONAR_SCANNER_OPTS="-server"
- curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
- unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
- export PATH=$HOME/.sonar/sonar/build-wrapper-linux-x86:$PATH
- build-wrapper-linux-x86-64 --out-dir $BW_OUTPUT make clean all
- sonar-scanner -Dsonar.cfamily.build-wrapper-output=$BW_OUTPUT

pipelines: # More info here: https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html
branches:
master:
- step: *build-test-sonarcloud
pull-requests:
‘**’:
- step: *build-test-sonarcloud

Error message:
build-wrapper-linux-x86-64 --out-dir $BW_OUTPUT make clean all<1s

+ build-wrapper-linux-x86-64 --out-dir $BW_OUTPUT make clean all
bash: build-wrapper-linux-x86-64: command not found

Hey there.

Your pipeline seems to diverge from the official example in the SonarCloud UI slightly. It reads:

- unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/

It should instead read:

- unzip -o $HOME/.sonar/sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/

Hi Colin,

Still having error after corrected the error that you pointed out.

image: gcc:6.5

clone:
depth: full # SonarCloud scanner needs the full history to assign issues properly

definitions:
caches:
sonar: ~/.sonar/cache # Caching SonarCloud artifacts will speed up your build
steps:
- step: &build-test-sonarcloud
name: Build, test and analyze on SonarCloud
caches:
- sonar
script:
- export SONAR_SCANNER_VERSION=4.4.0.2170
- export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
- export BW_OUTPUT=$HOME/.sonar/bw-output
- mkdir -p $BW_OUTPUT
- curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
- unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
- export PATH=$SONAR_SCANNER_HOME/bin:$PATH
- export SONAR_SCANNER_OPTS="-server"
- curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
- unzip -o $HOME/.sonar/sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
- export PATH=$HOME/.sonar/sonar/build-wrapper-linux-x86:$PATH
- build-wrapper-linux-x86-64 --out-dir $BW_OUTPUT make clean all
- sonar-scanner -Dsonar.cfamily.build-wrapper-output=$BW_OUTPUT

pipelines: # More info here: https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html
branches:
master:
- step: *build-test-sonarcloud
pull-requests:
‘**’:
- step: *build-test-sonarcloud

+ unzip -o $HOME/.sonar/sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
Error message:
unzip:  cannot find or open /root/.sonar/sonar/build-wrapper-linux-x86.zip, /root/.sonar/sonar/build-wrapper-linux-x86.zip.zip or /root/.sonar/sonar/build-wrapper-linux-x86.zip.ZIP.

Okay, I think this one is on us. :smiley:

This line

curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip

Should probably read

curl --create-dirs -sSLo $HOME/.sonar/sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip

At least, that should kick things into order. I’m not sure why we create a /sonar/ folder inside /sonar/. However, I’ll ping around internally to see this gets fixed.

1 Like

Hi Colin,

New error T-T.
build-wrapper-linux-x86-64 --out-dir $BW_OUTPUT make clean all<1s

+ build-wrapper-linux-x86-64 --out-dir $BW_OUTPUT make clean all
bash: build-wrapper-linux-x86-64: command not found

Hey there.

Can you show us the changes you’ve made to your pipeline?

When the shell cannot find a command, it’s because the base directory of the command is not on PATH.

Change the downloading + unzipping + path setting to this:

- curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
- unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
- export PATH=$HOME/.sonar/build-wrapper-linux-x86:$PATH

The download zip file contains this:

build-wrapper-linux-x86/
build-wrapper-linux-x86/libinterceptor-x86_64.so
build-wrapper-linux-x86/libinterceptor-i686.so
build-wrapper-linux-x86/build-wrapper-linux-x86-64
build-wrapper-linux-x86/libinterceptor-haswell.so

So when this is unzipped it into $HOME/.sonar/, the executable will be at $HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64, and so the base directory to add to PATH is $HOME/.sonar/build-wrapper-linux-x86. The export PATH=... line does this correctly, so this should work.

It should, if directory and file permissions are “normal”, which should be the case… If it still doesn’t work, then please share the output of this command, which will help verify permission issues, if any:

ls -l "$HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86"

Hi,

Still error.
Can you share a working example with me?

image: gcc:6.5

clone:
depth: full # SonarCloud scanner needs the full history to assign issues properly

definitions:
caches:
sonar: ~/.sonar/cache # Caching SonarCloud artifacts will speed up your build
steps:
- step: &build-test-sonarcloud
name: Build, test and analyze on SonarCloud
caches:
- sonar
script:
- export SONAR_SCANNER_VERSION=4.4.0.2170
- export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
- export BW_OUTPUT=$HOME/.sonar/bw-output
- mkdir -p $BW_OUTPUT
- curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
- unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
- export PATH=$SONAR_SCANNER_HOME/bin:$PATH
- export SONAR_SCANNER_OPTS="-server"
- curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
- unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
- export PATH=$HOME/.sonar/build-wrapper-linux-x86:$PATH
- build-wrapper-linux-x86-64 --out-dir $BW_OUTPUT make clean all
- sonar-scanner -Dsonar.cfamily.build-wrapper-output=$BW_OUTPUT

pipelines: # More info here: https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html
branches:
master:
- step: *build-test-sonarcloud
pull-requests:
‘**’:
- step: *build-test-sonarcloud

Error message:
build-wrapper-linux-x86-64 --out-dir $BW_OUTPUT make clean all<1s

+ build-wrapper-linux-x86-64 --out-dir $BW_OUTPUT make clean all
make: *** No rule to make target 'clean'.  Stop.