jenkinsci / jenkinsci/git-plugin
[JENKINS-51875] Jenkins spawns two builds (for two branches) after notifyCommit detects changes
- Dominant language
- Java
- Stars
- 694
- Forks
- 1.1k
- Avg merge
- 1h 29m
- Merged PRs (30d)
- 3
Description
Hello.
My setup contains multibranch pipeline project driven by Jenkins (declarative) file.
Jenkinsfile fraction:
triggers {
pollSCM('')
}
And I start Jenkins with:
```
-Dhudson.plugins.git.GitStatus.safeParameters=pullRequestId,toBranch,toHash,mergeCommit,fromHash,action,author,reviewers
```
Once new commit is detected on my Bitbucket server, Pull Request Notifier for Bitbucket plugin sends notifyCommit request to the Jenkins. notifyCommit request contains both, sha1 and branches parameters. SHA1=5c5e0c03cbab1dae0dcb9f755689ac1cfca653c9 and branches=feature/jen3.
However, Jenkins spawns two builds from this very request (#101 and #102): 
Event log (notice that "Processed 2 branches"):
```
[Mon Jun 11 13:08:41 CEST 2018] Received jenkins.plugins.git.GitSCMSource$ListenerImpl$1 UPDATED event from 10.29.1.239 ⇒ https://***/git/notifyCommit with timestamp Mon Jun 11 13:08:41 CEST 2018
> /opt/rh/rh-git29/root/usr/bin/git-launch.sh rev-parse --is-inside-work-tree # timeout=10
Setting origin to ssh://git@***:7999/jen/jenkins.git
> /opt/rh/rh-git29/root/usr/bin/git-launch.sh config remote.origin.url ssh://git@***:7999/jen/jenkins.git # timeout=10
Fetching & pruning origin...
Fetching upstream changes from origin
> /opt/rh/rh-git29/root/usr/bin/git-launch.sh --version # timeout=10
using GIT_SSH to set credentials
> /opt/rh/rh-git29/root/usr/bin/git-launch.sh fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/* --prune
Listing remote references...
> /opt/rh/rh-git29/root/usr/bin/git-launch.sh config --get remote.origin.url # timeout=10
using GIT_SSH to set credentials
> /opt/rh/rh-git29/root/usr/bin/git-launch.sh ls-remote -h ssh://git@***:7999/jen/jenkins.git # timeout=10
Checking branches...
Checking branch feature/jen3
‘Jenkinsfile’ found
Met criteria
Changes detected: feature/jen3 (0e8de89af3183f9f6daac7bd9e40203a0465799d → 5c5e0c03cbab1dae0dcb9f755689ac1cfca653c9)
Scheduled build for branch: feature/jen3
Processed 2 branches (query complete)
[Mon Jun 11 13:08:42 CEST 2018] jenkins.plugins.git.GitSCMSource$ListenerImpl$1 UPDATED event from 10.29.1.239 ⇒ https://***/git/notifyCommit with timestamp Mon Jun 11 13:08:41 CEST 2018 processed in 1 sec
```
notifyCommit request contains additional parameters and the exclamation mark means that build #101 has been spawned without the parameters provided (have when clause inside stages).
Build #101:
See the branch name "feature/jen3"

Build #102:
Branch name is different "origin/feature/jen3"

Build #103:
Was also triggered by notifyCommit, but with manual trigger by clicking a button (supported by the Bitbucket plugin) while no new changes has been made to the repository.

—
- Is that normal behavior that Jankins is processing two branches (even though they are the same, aren't they?) or is it a bug?
Thank you.
---
Originally reported by ferda_mravenec, imported from: Jenkins spawns two builds (for two branches) after notifyCommit detects changes
Raw content of original issue
Hello.
My setup contains multibranch pipeline project driven by Jenkins (declarative) file.
Jenkinsfile fraction:
triggers {
pollSCM('')
}And I start Jenkins with:
-Dhudson.plugins.git.GitStatus.safeParameters=pullRequestId,toBranch,toHash,mergeCommit,fromHash,action,author,reviewersOnce new commit is detected on my Bitbucket server, Pull Request Notifier for Bitbucket plugin sends notifyCommit request to the Jenkins. notifyCommit request contains both, sha1 and branches parameters. SHA1=5c5e0c03cbab1dae0dcb9f755689ac1cfca653c9 and branches=feature/jen3.
However, Jenkins spawns two builds from this very request (#101 and #102):
Event log (notice that "Processed 2 branches"):
[Mon Jun 11 13:08:41 CEST 2018] Received jenkins.plugins.git.GitSCMSource$ListenerImpl$1 UPDATED event from 10.29.1.239 ⇒ https://***/git/notifyCommit with timestamp Mon Jun 11 13:08:41 CEST 2018
> /opt/rh/rh-git29/root/usr/bin/git-launch.sh rev-parse --is-inside-work-tree # timeout=10
Setting origin to ssh://git@***:7999/jen/jenkins.git
> /opt/rh/rh-git29/root/usr/bin/git-launch.sh config remote.origin.url ssh://git@***:7999/jen/jenkins.git # timeout=10
Fetching & pruning origin...
Fetching upstream changes from origin
> /opt/rh/rh-git29/root/usr/bin/git-launch.sh --version # timeout=10
using GIT_SSH to set credentials
> /opt/rh/rh-git29/root/usr/bin/git-launch.sh fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/* --prune
Listing remote references...
> /opt/rh/rh-git29/root/usr/bin/git-launch.sh config --get remote.origin.url # timeout=10
using GIT_SSH to set credentials
> /opt/rh/rh-git29/root/usr/bin/git-launch.sh ls-remote -h ssh://git@***:7999/jen/jenkins.git # timeout=10
Checking branches...
Checking branch feature/jen3
‘Jenkinsfile’ found
Met criteria
Changes detected: feature/jen3 (0e8de89af3183f9f6daac7bd9e40203a0465799d → 5c5e0c03cbab1dae0dcb9f755689ac1cfca653c9)
Scheduled build for branch: feature/jen3
Processed 2 branches (query complete)
[Mon Jun 11 13:08:42 CEST 2018] jenkins.plugins.git.GitSCMSource$ListenerImpl$1 UPDATED event from 10.29.1.239 ⇒ https://***/git/notifyCommit with timestamp Mon Jun 11 13:08:41 CEST 2018 processed in 1 sec
notifyCommit request contains additional parameters and the exclamation mark means that build #101 has been spawned without the parameters provided (have when clause inside stages).
Build #101:
See the branch name "feature/jen3"
Build #102:
Branch name is different "origin/feature/jen3"
Build #103:
Was also triggered by notifyCommit, but with manual trigger by clicking a button (supported by the Bitbucket plugin) while no new changes has been made to the repository.
—
- Is that normal behavior that Jankins is processing two branches (even though they are the same, aren't they?) or is it a bug?
Thank you.
environment
```
Jenkins: v2.105
GIT plugin: v4.0.0-beta2
GIT client plugin: v3.0.0-beta3
```
5 attachments
- [image-2018-06-12-08-37-43-767.png](https://issues.jenkins.io/secure/attachment/42838/image-2018-06-12-08-37-43-767.png)
> 
- [image-2018-06-12-08-39-21-145.png](https://issues.jenkins.io/secure/attachment/42834/image-2018-06-12-08-39-21-145.png)
> 
- [jenkins-101.png](https://issues.jenkins.io/secure/attachment/42837/jenkins-101.png)
> 
- [jenkins-102.png](https://issues.jenkins.io/secure/attachment/42836/jenkins-102.png)
> 
- [jenkins-103.png](https://issues.jenkins.io/secure/attachment/42835/jenkins-103.png)
> 
Contributor guide
Assessment
This issue has not been assessed yet.