Open karniemi opened 8 months ago
Of course, this could be turned the other way round: when Lightweight checkout is disabled and the Bitbucket Push and Pull Request Plugin triggers the build - the Jenkinsfile is not taken from the branch which is configured in the Jenkins job, but instead the Jenkinsfile from the PR-branch is picked.
This is actually what we( in my org) want though, but it's most illogical for users in UI perspective.
For "Lightweight checkout: enabled", I tried setting to "Branch specifier: refs/heads/${BITBUCKET_SOURCE_BRANCH}", hoping the plugin would set the BITBUCKET_SOURCE_BRANCH in the ENV , and therefore the Jenkinsfile would be checked out from the correct branch. But no, it was still using some wrong branch. ( For this experiment, I also had a build parameter named BITBUCKET_SOURCE_BRANCH - but that should not cause the issue, because according to Jenkins docs/statements environment variables cannot be overridden by the build parameters.)
We have configured a Jenkins job:
This allows us to trigger the job manually for whatever branch - and also trigger the build using the Bitbucket Push and Pull Request Plugin.
We wanted to start using Lightweight checkout - to prevent doing the checkout twice from git. Unfortunately, when we enable "Lightweight checkout", the Jenkinsfile is no more executed from the branch which the PR was made and which started the build - but some other branch. If we again disable "Lightweight checkout", the Jenkinsfile is executed from the branch as supposed to.