-
Bug
-
Resolution: Fixed
-
Major
-
None
-
bitbucket-branch-sources-883.v041fa_695e9c2 or higher
-
-
936.0.0
Before https://github.com/jenkinsci/bitbucket-branch-source-plugin/pull/796/files#diff-d769b0b5dee9decacfe1ed7cf599bafdf4f4137f90ddca90c472abed3672c4eb it was possible to build PRs opened from a tag in the same repository. Since that PR was merged, PRs must be opened from forks, which in case of the origin was a tag is not the usual situation
Reproduction steps
- Configuration of the Bitbucket server:
- Create 1 project and 1 repository for this project.
- Create a Jenkinsfile in the above repository (master branch). It can be as simple as Ex1
- Create a new branch from master named feature/ex.
- Make a commit in the branch feature/ex (change in the Jenkinsfile). It can be something as simple as Ex2
- Create a tag for this commit, for example v1.0.
- Make a second commit in the branch feature/ex. Again a simple commit such as Ex3
- Create a Pull Request from the tag v1.0 (created in step 1.4) to the master branch.
- Spin up a Jenkins instance
- Install the CloudBees Bitbucket Branch Source plugin.
- [If using a on-premise Bitbucket server] Configure the Jenkins instance to access the above repository
- Manage Jenkins > Settings > Bitbucket Endpoints
- Choose Bitbucket Server and configure the server from step 1
- Create a new Multibranch pipeline job
- Source of kind BitBucket.
- Choose the above Bitbucket configuration and add the credentials
- Configure the owner (the project) to have the correct repository.
- Save and wait for the indexing.
- Go to the Pull Request section, and in the PR-1 you will see the build failing.
Branch indexing Checking out git *** into *** to read Jenkinsfile The recommended git tool is: NONE using credential admin Cloning the remote Git repository Cloning with configured refspecs honoured and without tags Cloning repository *** > git init *** # timeout=10 Fetching upstream changes from *** > git --version # timeout=10 > git --version # 'git version 2.34.1' using GIT_ASKPASS to set credentials > git fetch --no-tags --force --progress -- *** +refs/heads/v1.0:refs/remotes/origin/v1.0 +refs/heads/master:refs/remotes/origin/master +refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/remotes/origin/* # timeout=10 ERROR: Error cloning remote repo 'origin' hudson.plugins.git.GitException: Command "git fetch --no-tags --force --progress -- *** +refs/heads/v1.0:refs/remotes/origin/v1.0 +refs/heads/master:refs/remotes/origin/master +refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/remotes/origin/*" returned status code 128: stdout: stderr: fatal: no se pudo encontrar ref remota refs/heads/v1.0 at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2852) at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2188) at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:638) at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:880) at PluginClassLoader for git//hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1221) at PluginClassLoader for git//hudson.plugins.git.GitSCM._checkout(GitSCM.java:1311) at PluginClassLoader for git//hudson.plugins.git.GitSCM.checkout(GitSCM.java:1278) at PluginClassLoader for workflow-scm-step//org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:136) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:161) at PluginClassLoader for workflow-multibranch//org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:148) at PluginClassLoader for workflow-job//org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:319) at hudson.model.ResourceController.execute(ResourceController.java:101) at hudson.model.Executor.run(Executor.java:446) ERROR: Error cloning remote repo 'origin' ERROR: Maximum checkout retry attempts reached, aborting ERROR: Error cloning remote repo 'origin' ERROR: Maximum checkout retry attempts reached, aborting [Bitbucket] Notifying pull request build result Can not determine Jenkins root URL or Jenkins URL is not a valid URL regarding Bitbucket API. Commit status notifications are disabled until a root URL is configured in Jenkins global configuration. IllegalStateException: Jenkins URL cannot start with http://localhost Finished: FAILURE
Jenkinsfile
Ex1.
pipeline { agent any stages { stage('Build') { steps { echo 'Building..' } } stage('Test') { steps { echo 'Testing..' } } stage('Deploy') { steps { echo 'Deploying....' } } } }
Ex2.
pipeline { agent any stages { stage('Build') { steps { echo 'Building..' } } stage('Test') { steps { echo 'Testing..' } } stage('Deploy') { steps { echo 'Deploying....' } } stage('Greetings') { steps { echo 'Well done!' } } } }
Ex3
pipeline { agent any stages { stage('Build') { steps { echo 'Building..' } } stage('Test') { steps { echo 'Testing..' } } stage('Deploy') { steps { echo 'Deploying....' } } stage('Greetings') { steps { echo 'Well done!' } } stage('Again?') { steps { echo 'Are not these too many commits?' } } } }
Hypothesis
The following code to add the `refs/pull-requests` has been moved to the `withPullRequestRemote` method. However, this has been done wrongly and now any PR opened from the same fork will enter through this condition: https://github.com/jenkinsci/bitbucket-branch-source-plugin/pull/796/files#diff-d769b0b5dee9decacfe1ed7cf599bafdf4f4137f90ddca90c472abed3672c4ebR220
This means the plugin is expecting that all PRs are to be open from forks, but that makes no sense if the PR is opened from a tag.
- links to