Problem Abstract env GIT_COMMIT is not always same the real git revision in particular situation. GIT_COMMIT, SHA of the current, is defined by Git Plugin. Problem Detail I use GitHub Branch Source Plugin to run Pull Request job with Jenkinsfile. My job use Jenkinsfile in my github repository. I found GIT_COMMIT is sometime different from real git revision in the stage of Pipeline. When the problem happen, Jenkisn build logs says it causes git merge twice. First merge is to read Jenkinsfile from git, second merge is to setup working directory. So I print the revision in my Pipeline script. env.GIT_COMMIT = 75ddc1933fd10b87c529536e3107ea7313debaea HEAD revision = a98b709283bd47d251dfcc9360b91ffc024af16b GIT_COMMIT is the revision at first merge, and HEAD is the revision at second merge. How to reproduce this problem I test with minimum condition which can reproduce the problem by using it↓ https://github.com/mtgto/jenkins-pipeline-test/blob/prtest/Jenkinsfile https://github.com/mtgto/jenkins-pipeline-test/pull/1 The problem is only happened below all conditions matched:
- The job is Multibranch job.
- The job uses pipeline by Jenkinsfile in git repository.
- The pull request can't merge fast-forward.
- Twice merge commits is away at least one second.
1, 2: The condition to generate twice merge commits. 3: Fast-forward merge doesn't change by current time. 4: Git object contains time, it is by the second. Same time merge commits always have same revisions. Installed Plugins
- Apache HttpComponents Client 4.x API Plugin - 4.5.5-3.0
- Authentication Tokens API Plugin - 1.3
- bouncycastle API Plugin - 2.17
- Branch API Plugin - 2.2.0
- Command Agent Launcher Plugin - 1.3
- Credentials Binding Plugin - 1.18
- Credentials Plugin - 2.1.18
- Display URL API - 2.3.1
- Docker Commons Plugin - 1.13
- Docker Pipeline - 1.17
- Durable Task Plugin - 1.29
- Folders Plugin - 6.7
- Git client plugin - 2.7.6
- Git plugin - 3.9.3
- GIT server Plugin - 1.7
- GitHub API Plugin - 1.95
- GitHub Branch Source Plugin - 2.4.5
- GitHub plugin - 1.29.4
- Jackson 2 API Plugin - 2.9.8
- JavaScript GUI Lib: ACE Editor bundle plugin - 1.1
- JavaScript GUI Lib: Handlebars bundle plugin - 1.1.1
- JavaScript GUI Lib: jQuery bundles (jQuery and jQuery UI) plugin - 1.2.1
- JavaScript GUI Lib: Moment.js bundle plugin - 1.1.1
- JDK Tool Plugin - 1.2
- JSch dependency plugin - 0.1.55
- JUnit Plugin - 1.27
- Lockable Resources plugin - 2.5
- Mailer Plugin - 1.23
- Matrix Project Plugin - 1.14
- Pipeline - 2.6
- Pipeline Graph Analysis Plugin - 1.9
- Pipeline: API - 2.33
- Pipeline: Basic Steps - 2.15
- Pipeline: Build Step - 2.8
- Pipeline: Declarative - 1.3.7
- Pipeline: Declarative Agent API - 1.1.1
- Pipeline: Declarative Extension Points API - 1.3.7
- Pipeline: Groovy - 2.65
- Pipeline: Input Step - 2.10
- Pipeline: Job - 2.32
- Pipeline: Milestone Step - 1.3.1
- Pipeline: Model API - 1.3.7
- Pipeline: Multibranch - 2.21
- Pipeline: Nodes and Processes - 2.29
- Pipeline: REST API Plugin - 2.10
- Pipeline: SCM Step - 2.7
- Pipeline: Shared Groovy Libraries - 2.13
- Pipeline: Stage Step - 2.3
- Pipeline: Stage Tags Metadata - 1.3.7
- Pipeline: Stage View Plugin - 2.10
- Pipeline: Step API - 2.19
- Pipeline: Supporting APIs - 3.2
- Plain Credentials Plugin - 1.5
- SCM API Plugin - 2.4.0
- Script Security Plugin - 1.56
- SSH Credentials Plugin - 1.15
- Structs Plugin - 1.17
- Token Macro Plugin - 2.7
|