jenkinsci / jenkinsci/git-plugin
[JENKINS-58471] Git SCM polling should use last built refspec instead of defined refspec
- Dominant language
- Java
- Stars
- 694
- Forks
- 1.1k
- Avg merge
- 1h 29m
- Merged PRs (30d)
- 3
Description
Actual behavior
When setting refspec like this: +refs/heads/${GIT_REF}:refs/remotes/origin/${GIT_REF}
And after building a branch, the SCM polling does not find a match with git ls-remote and the built branch:
[poll] Last Built Revision: Revision ce9cc0a298fc94cafa4cc87e0bb1544b359ee752 (feature/20190711-FVE-test_job_scm)
> git --version # timeout=10...
Ignoring refs/heads/feature/20190711-FVE-test_job_scm as it doesn't match any of the configured refspecs
No changes
Expected behavior:
The SCM poll should keep the source refspec of the last build, in this case "refs/heads/feature/20190711-FVE-test_job_scm", and do a comparison with that, with git ls-remote:
[poll] Last Built Revision: Revision ce9cc0a298fc94cafa4cc87e0bb1544b359ee752 (feature/20190711-FVE-test_job_scm)
> git --version # timeout=10...
[poll] Latest remote head revision on refs/heads/feature/20190711-FVE-test_job_scm is: 4a598524b56af4493027828d7e2a5f1b3179ec82
Done. Took 0.4 sec
Changes found
Workaround:
I set the GIT_REFSPEC to:
+refs/heads/${GIT_REF}:refs/heads/${GIT_REF}
But that is not optimal for us, because we want this to work with branches and tag, and this does not work for tags, thus the old value:
+refs/heads/${GIT_REF}:refs/remotes/origin/${GIT_REF}
---
Originally reported by antoinetran, imported from: Git SCM polling should use last built refspec instead of defined refspec
Raw content of original issue
Actual behavior
When setting refspec like this: +refs/heads/${GIT_REF}:refs/remotes/origin/${GIT_REF}
And after building a branch, the SCM polling does not find a match with git ls-remote and the built branch:
[poll] Last Built Revision: Revision ce9cc0a298fc94cafa4cc87e0bb1544b359ee752 (feature/20190711-FVE-test_job_scm)
> git --version # timeout=10...
Ignoring refs/heads/feature/20190711-FVE-test_job_scm as it doesn't match any of the configured refspecs
No changes
Expected behavior:
The SCM poll should keep the source refspec of the last build, in this case "refs/heads/feature/20190711-FVE-test_job_scm", and do a comparison with that, with git ls-remote:
[poll] Last Built Revision: Revision ce9cc0a298fc94cafa4cc87e0bb1544b359ee752 (feature/20190711-FVE-test_job_scm)
> git --version # timeout=10...
[poll] Latest remote head revision on refs/heads/feature/20190711-FVE-test_job_scm is: 4a598524b56af4493027828d7e2a5f1b3179ec82
Done. Took 0.4 sec
Changes found
Workaround:
I set the GIT_REFSPEC to:
+refs/heads/${GIT_REF}:refs/heads/${GIT_REF}But that is not optimal for us, because we want this to work with branches and tag, and this does not work for tags, thus the old value:
+refs/heads/${GIT_REF}:refs/remotes/origin/${GIT_REF}
environment
```
Jenkins 2.60.3
Git client 2.7.1
```
Contributor guide
Assessment
This issue has not been assessed yet.