-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
Jenkins 2.222.1, TFS plugin 5.157.1
I configured a Jenkins job for TFS PR verification builds as described in the Git section of https://github.com/jenkinsci/tfs-plugin. The pull request commits are found on branches named remotes/origin/pull/n/merge, so I added an additional branch specifier */merge to the Branches to build section of my Jenkins job definition.
However, when the build runs, Git refuses to accept the commit from the merge branch with the error message skipping resolution of commit ..., since it originates from another repository but builds with the HEAD commit of the master branch instead of origin-pull/3/merge.
Here is an excerpt of git log --oneline --graph --decorate --all:
* 7fcad29 (origin-pull/3/merge) Merge pull request 3 from feature-one into master |\ | * 37f0c7d (origin/feature-one) Test * | c7e2002 (HEAD, origin/master) Merged PR 2: change 5
Here is the console log:
Lightweight checkout support not available, falling back to full checkout. Checking out git http://10.0.2.2:8080/tfs/DefaultCollection/Jenkins-Git-Test/_git/testit.git into /var/jenkins_home/workspace/pull-request-verification@script to read Jenkinsfile using credential c0c927b7-0a3a-4051-af13-91ef394cd497 > git rev-parse --is-inside-work-tree # timeout=10 Fetching changes from the remote Git repository > git config remote.origin.url http://10.0.2.2:8080/tfs/DefaultCollection/Jenkins-Git-Test/_git/testit.git # timeout=10 Fetching upstream changes from http://10.0.2.2:8080/tfs/DefaultCollection/Jenkins-Git-Test/_git/testit.git > git --version # timeout=10 using GIT_ASKPASS to set credentials > git fetch --tags --progress -- http://10.0.2.2:8080/tfs/DefaultCollection/Jenkins-Git-Test/_git/testit.git +refs/heads/*:refs/remotes/origin/* +refs/pull/*:refs/remotes/origin-pull/* # timeout=10 skipping resolution of commit 7fcad293a558164c074986e0746a79eee02ba79d, since it originates from another repository Seen branch in repository origin-pull/2/merge Seen branch in repository origin-pull/3/merge Seen branch in repository origin/feature-one Seen branch in repository origin/master Seen 4 remote branches > git show-ref --tags -d # timeout=10 Checking out Revision c7e2002a890151347a6bf38c5fbd423756149d1a (origin/master) > git config core.sparsecheckout # timeout=10 > git checkout -f c7e2002a890151347a6bf38c5fbd423756149d1a # timeout=10 Commit message: "Merged PR 2: change 5" > git rev-list --no-walk c7e2002a890151347a6bf38c5fbd423756149d1a # timeout=10 Running in Durability level: MAX_SURVIVABILITY [Pipeline] Start of Pipeline [Pipeline] node Running on Jenkins in /var/jenkins_home/workspace/pull-request-verification [Pipeline] { [Pipeline] stage [Pipeline] { (Declarative: Checkout SCM) [Pipeline] checkout using credential c0c927b7-0a3a-4051-af13-91ef394cd497 > git rev-parse --is-inside-work-tree # timeout=10 Fetching changes from the remote Git repository > git config remote.origin.url http://10.0.2.2:8080/tfs/DefaultCollection/Jenkins-Git-Test/_git/testit.git # timeout=10 Fetching upstream changes from http://10.0.2.2:8080/tfs/DefaultCollection/Jenkins-Git-Test/_git/testit.git > git --version # timeout=10 using GIT_ASKPASS to set credentials > git fetch --tags --progress -- http://10.0.2.2:8080/tfs/DefaultCollection/Jenkins-Git-Test/_git/testit.git +refs/heads/*:refs/remotes/origin/* +refs/pull/*:refs/remotes/origin-pull/* # timeout=10 skipping resolution of commit 7fcad293a558164c074986e0746a79eee02ba79d, since it originates from another repository Seen branch in repository origin-pull/2/merge Seen branch in repository origin-pull/3/merge Seen branch in repository origin/feature-one Seen branch in repository origin/master Seen 4 remote branches > git show-ref --tags -d # timeout=10 Checking out Revision c7e2002a890151347a6bf38c5fbd423756149d1a (origin/master) > git config core.sparsecheckout # timeout=10 > git checkout -f c7e2002a890151347a6bf38c5fbd423756149d1a # timeout=10 Commit message: "Merged PR 2: change 5" [Pipeline] } [Pipeline] // stage [Pipeline] withEnv [Pipeline] { [Pipeline] stage [Pipeline] { (Build) [Pipeline] sh + cat README.md # Test Repository This repository has been set up for testing purposes only. This is another line added to trigger a build. And one more. This change has also been done on the feature-one branch. (First line removed) 2020-04-08T13:23:58+00:00 2020-04-08T13:27:16+00:00 [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline Finished: SUCCESS
Strangely, the build succeeds when the commit to be merged has been committed in the TFS Git repository itself. When the change is pushed into the TFS Git repository from a clone using a different user name and e-mail address, the pull request verification build fails as described above. Once user.name and user.email on the clone are set to be identical to the TFS Git repository, the pull request verification build after the push succeeds. This seems really strange!
Another thing is that the build fails if it is triggered by a TFS branch policy validation build:
However, it succeeds when it is triggered by a Jenkins Service Hook in TFS:
The Git log output after the successful verification build triggered by the service hook (commit c607f67) the failed branch policy build (pull request abandoned after failure) should have built commit 03420e8:
The error message is produced by the Jenkins Git plugin, so I assume that is the source of the strange behavior.