The issue is both on the master builds AND on pull-request builds.
BITBUCKET_PR_DESTINATION_BRANCH is not supposed to be set on the master builds but I don’t know why it is not available for pull-request builds.
A good improvement could be to provide a better error message but I don’t know what is possible in Bitbucket pipes.
Hi Julien,
Can you post your bitbucket-pipelines.yml content?
According to the Bitbucket Pipelines docs, BITBUCKET_PR_DESTINATION_BRANCH should always be available for pull requests and passed into the pipe container. For non-PR builds the setting is not passed at all and that’s perfectly fine.
I’ve investigated it and the problem is not really specific to SonarCloud pipe (our pipe doesn’t even validate BITBUCKET_PR_DESTINATION_BRANCH). The problem is that the scripts which you execute before the pipe execution define “bash strict mode” (set -euo pipefail) which doesn’t seem to play nice with Bitbucket Pipes.
The quick way to fix this would be to not use strict mode or turn it off for the pipe execution like this:
...
- set +u
- pipe: sonarsource/sonarcloud-scan:0.1.5
variables:
SONAR_TOKEN: ${SONAR_TOKEN}
- set -u
...
BTW, I noticed that you don’t define the SONAR_TOKEN variable which is needed by the pipe (that one is actually validated). Also it seems like one of your scripts downloads and installs sonar scanner which is not needed since the pipe already contains the scanner.
I suppose bash complains against missing env in strict mode. So, the question is: who is generating the docker container run command? IMO, it should not have the BITBUCKET_PR_* env for pull request builds and should work in strict mode too.
I noticed that you don’t define the SONAR_TOKEN variable which is needed by the pipe
Thank, we will update it!
it seems like one of your scripts downloads and installs sonar scanner which is not needed since the pipe already contains the scanner.
Right! It is our previous pipeline and we will remove it once the new pipe will work.
I agree it should work in “strict mode” but this happens on Bitbucket Pipelines side (it will affect all the other Pipes). I reported this to the Atlassian team that works on it.
Thank you for providing the logs and configuration!