bencch
(Ben Choy)
April 19, 2021, 3:51am
1
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
Colin
(Colin)
April 19, 2021, 1:23pm
2
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/
bencch
(Ben Choy)
April 20, 2021, 12:08am
3
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.
Colin
(Colin)
April 20, 2021, 8:36am
4
Okay, I think this one is on us.
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
bencch
(Ben Choy)
April 20, 2021, 9:05am
6
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
Colin
(Colin)
April 20, 2021, 9:25am
7
Hey there.
Can you show us the changes you’ve made to your pipeline?
janos
(Janos Gyerik)
April 20, 2021, 9:46am
9
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"
bencch
(Ben Choy)
April 21, 2021, 2:39am
10
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.