jenkinsci / jenkinsci/git-plugin

[JENKINS-21264] inverse build strategy issues

Open
#2,398 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

component:git-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
694
Forks
1.1k
Avg merge
1h 29m
Merged PRs (30d)
3

Description

I found a case where the inverse build strategy built the wrong branch. Perhaps this is expected behavior in this case. It is kind of an odd case.

  • create git repo with master branch
  • create new job cloning git repository, leave everything at the default
  • build the job - builds master as expected
  • create branch b1 in git repo
  • change the configuration to be inverse
  • wipe out the workspace
  • build the job - builds master instead of b1

Here's the output of the job:

Started by user Jon Schewe
Building in workspace /home/hudson/.hudson/jobs/test/workspace
Cloning the remote Git repository
Cloning repository /home/jpschewe/tmp/test-git
Fetching upstream changes from /home/jpschewe/tmp/test-git
Seen branch in repository origin/b1
Seen branch in repository origin/master
Seen 2 remote branches
No new revisions were found; the most-recently built branch will be built again.
Checking out Revision 88c6fdc580e0476c06bab09d872bbfeb625e58c2 (origin/master)
[workspace] $ /bin/sh -xe /tmp/hudson6219937155460885978.sh
+ env
BUILD_URL=http://mtu.net/jenkins/job/test/5/
HUDSON_SERVER_COOKIE=6c6746aa04dc140a
SHELL=/bin/sh
TERM=screen
XDG_SESSION_COOKIE=d1dab2177f9c573e5fae0e004864cf15-1388974748.816383-1116830797
BUILD_TAG=jenkins-test-5
GIT_PREVIOUS_COMMIT=88c6fdc580e0476c06bab09d872bbfeb625e58c2
ANT_HOME=/usr/local/ant/apache-ant-1.7.1
WORKSPACE=/home/hudson/.hudson/jobs/test/workspace
JOB_URL=http://mtu.net/jenkins/job/test/
USER=hudson
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:.tar=01;31:.tgz=01;31:.arj=01;31:.taz=01;31:.lzh=01;31:.lzma=01;31:.tlz=01;31:.txz=01;31:.zip=01;31:.z=01;31:.Z=01;31:.dz=01;31:.gz=01;31:.lz=01;31:.xz=01;31:.bz2=01;31:.bz=01;31:.tbz=01;31:.tbz2=01;31:.tz=01;31:.deb=01;31:.rpm=01;31:.jar=01;31:.war=01;31:.ear=01;31:.sar=01;31:.rar=01;31:.ace=01;31:.zoo=01;31:.cpio=01;31:.7z=01;31:.rz=01;31:.jpg=01;35:.jpeg=01;35:.gif=01;35:.bmp=01;35:.pbm=01;35:.pgm=01;35:.ppm=01;35:.tga=01;35:.xbm=01;35:.xpm=01;35:.tif=01;35:.tiff=01;35:.png=01;35:.svg=01;35:.svgz=01;35:.mng=01;35:.pcx=01;35:.mov=01;35:.mpg=01;35:.mpeg=01;35:.m2v=01;35:.mkv=01;35:.webm=01;35:.ogm=01;35:.mp4=01;35:.m4v=01;35:.mp4v=01;35:.vob=01;35:.qt=01;35:.nuv=01;35:.wmv=01;35:.asf=01;35:.rm=01;35:.rmvb=01;35:.flc=01;35:.avi=01;35:.fli=01;35:.flv=01;35:.gl=01;35:.dl=01;35:.xcf=01;35:.xwd=01;35:.yuv=01;35:.cgm=01;35:.emf=01;35:.axv=01;35:.anx=01;35:.ogv=01;35:.ogx=01;35:.aac=00;36:.au=00;36:.flac=00;36:.mid=00;36:.midi=00;36:.mka=00;36:.mp3=00;36:.mpc=00;36:.ogg=00;36:.ra=00;36:.wav=00;36:.axa=00;36:.oga=00;36:.spx=00;36:.xspf=00;36:
GIT_COMMIT=88c6fdc580e0476c06bab09d872bbfeb625e58c2
JENKINS_HOME=/home/hudson/.hudson
PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/local/ant/apache-ant-1.7.1/bin:/usr/lib/iceweasel
MAIL=/var/mail/hudson
_=/usr/bin/env
PWD=/home/hudson/.hudson/jobs/test/workspace
HUDSON_URL=http://mtu.net/jenkins/
LANG=en_US.UTF-8
JOB_NAME=test
JENKINS_URL=http://mtu.net/jenkins/
BUILD_ID=2014-01-07_20-57-52
HISTCONTROL=ignoredups
HOME=/home/hudson
SHLVL=3
GIT_BRANCH=origin/master
JENKINS_SERVER_COOKIE=6c6746aa04dc140a
EXECUTOR_NUMBER=0
GIT_URL=/home/jpschewe/tmp/test-git
NODE_LABELS=master
LOGNAME=hudson
HUDSON_HOME=/home/hudson/.hudson
NODE_NAME=master
LESSOPEN=| /usr/bin/lesspipe %s
BUILD_NUMBER=5
HUDSON_COOKIE=5cd023e7-de24-4667-8339-dda542b76b67
LESSCLOSE=/usr/bin/lesspipe %s %s
+ echo here
here
Finished: SUCCESS


Originally reported by jpschewe, imported from: inverse build strategy issues
  • status: Open
  • priority: Minor
  • component(s): git-plugin
  • resolution: Unresolved
  • votes: 4
  • watchers: 8
  • imported: 2025-12-02
Raw content of original issue

I found a case where the inverse build strategy built the wrong branch. Perhaps this is expected behavior in this case. It is kind of an odd case.

  • create git repo with master branch
  • create new job cloning git repository, leave everything at the default
  • build the job - builds master as expected
  • create branch b1 in git repo
  • change the configuration to be inverse
  • wipe out the workspace
  • build the job - builds master instead of b1

Here's the output of the job:

Started by user Jon Schewe Building in workspace /home/hudson/.hudson/jobs/test/workspace Cloning the remote Git repository Cloning repository /home/jpschewe/tmp/test-git Fetching upstream changes from /home/jpschewe/tmp/test-git Seen branch in repository origin/b1 Seen branch in repository origin/master Seen 2 remote branches No new revisions were found; the most-recently built branch will be built again. Checking out Revision 88c6fdc580e0476c06bab09d872bbfeb625e58c2 (origin/master) [workspace] $ /bin/sh -xe /tmp/hudson6219937155460885978.sh + env BUILD_URL=http://mtu.net/jenkins/job/test/5/ HUDSON_SERVER_COOKIE=6c6746aa04dc140a SHELL=/bin/sh TERM=screen XDG_SESSION_COOKIE=d1dab2177f9c573e5fae0e004864cf15-1388974748.816383-1116830797 BUILD_TAG=jenkins-test-5 GIT_PREVIOUS_COMMIT=88c6fdc580e0476c06bab09d872bbfeb625e58c2 ANT_HOME=/usr/local/ant/apache-ant-1.7.1 WORKSPACE=/home/hudson/.hudson/jobs/test/workspace JOB_URL=http://mtu.net/jenkins/job/test/ USER=hudson LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:.tar=01;31:.tgz=01;31:.arj=01;31:.taz=01;31:.lzh=01;31:.lzma=01;31:.tlz=01;31:.txz=01;31:.zip=01;31:.z=01;31:.Z=01;31:.dz=01;31:.gz=01;31:.lz=01;31:.xz=01;31:.bz2=01;31:.bz=01;31:.tbz=01;31:.tbz2=01;31:.tz=01;31:.deb=01;31:.rpm=01;31:.jar=01;31:.war=01;31:.ear=01;31:.sar=01;31:.rar=01;31:.ace=01;31:.zoo=01;31:.cpio=01;31:.7z=01;31:.rz=01;31:.jpg=01;35:.jpeg=01;35:.gif=01;35:.bmp=01;35:.pbm=01;35:.pgm=01;35:.ppm=01;35:.tga=01;35:.xbm=01;35:.xpm=01;35:.tif=01;35:.tiff=01;35:.png=01;35:.svg=01;35:.svgz=01;35:.mng=01;35:.pcx=01;35:.mov=01;35:.mpg=01;35:.mpeg=01;35:.m2v=01;35:.mkv=01;35:.webm=01;35:.ogm=01;35:.mp4=01;35:.m4v=01;35:.mp4v=01;35:.vob=01;35:.qt=01;35:.nuv=01;35:.wmv=01;35:.asf=01;35:.rm=01;35:.rmvb=01;35:.flc=01;35:.avi=01;35:.fli=01;35:.flv=01;35:.gl=01;35:.dl=01;35:.xcf=01;35:.xwd=01;35:.yuv=01;35:.cgm=01;35:.emf=01;35:.axv=01;35:.anx=01;35:.ogv=01;35:.ogx=01;35:.aac=00;36:.au=00;36:.flac=00;36:.mid=00;36:.midi=00;36:.mka=00;36:.mp3=00;36:.mpc=00;36:.ogg=00;36:.ra=00;36:.wav=00;36:.axa=00;36:.oga=00;36:.spx=00;36:.xspf=00;36: GIT_COMMIT=88c6fdc580e0476c06bab09d872bbfeb625e58c2 JENKINS_HOME=/home/hudson/.hudson PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/local/ant/apache-ant-1.7.1/bin:/usr/lib/iceweasel MAIL=/var/mail/hudson _=/usr/bin/env PWD=/home/hudson/.hudson/jobs/test/workspace HUDSON_URL=http://mtu.net/jenkins/ LANG=en_US.UTF-8 JOB_NAME=test JENKINS_URL=http://mtu.net/jenkins/ BUILD_ID=2014-01-07_20-57-52 HISTCONTROL=ignoredups HOME=/home/hudson SHLVL=3 GIT_BRANCH=origin/master JENKINS_SERVER_COOKIE=6c6746aa04dc140a EXECUTOR_NUMBER=0 GIT_URL=/home/jpschewe/tmp/test-git NODE_LABELS=master LOGNAME=hudson HUDSON_HOME=/home/hudson/.hudson NODE_NAME=master LESSOPEN=| /usr/bin/lesspipe %s BUILD_NUMBER=5 HUDSON_COOKIE=5cd023e7-de24-4667-8339-dda542b76b67 LESSCLOSE=/usr/bin/lesspipe %s %s + echo here here Finished: SUCCESS

environment
Jenkins 1.509.4<br/>
Git Plugin 2.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the inverse build strategy scenario in the Jenkins git-plugin: create master and b1, switch the job to inverse, wipe the workspace, and compare the selected branch with the reported output. No source file or test is named; trace the job configuration and branch-selection entry points. Done means the behavior is clarified or the inverse strategy selects b1 as expected, with a regression test if the behavior is a bug.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, java
Domain
ci-cd, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.