Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-29644

Branch parameter ignored when a non-parameterized branch is also monitored

      when setting a jenkins job that tracks 2 sources - */develop as jenkins trigger and ${branch} as a parameterized branch
      the build always builds the develop branch(as if it was externally triggered) and ignores the ${branch} parameter.

      without this option users are forced to create 2+ build jobs doing the same thing, therefor have double the maintenance and bugs because of code duplication

      attached the Stash screen that sets up the jenkins trigger

          [JENKINS-29644] Branch parameter ignored when a non-parameterized branch is also monitored

          Mark Waite added a comment - - edited

          I don't understand how to duplicate the bug you're reporting. Can you provide a series of steps which will show the bug?

          Steps I tried while attempting to duplicate the bug:

          1. Create a bare git repository /var/lib/git/mwaite/bugs/JENKINS-29644.git
          2. Create a hook script in that bare repository to notify Jenkins on every commit
          3. Clone the bare repo, create and push two branches, one named "master", the other named "named-branch"
          4. Create a parameterized Jenkins job to build from the bare repo with string parameter "BRANCH_TO_BUILD", default value "master"
          5. Set the branch to build to be "origin/$BRANCH_TO_BUILD"
          6. Add an additional branch to build that is "origin/named-branch"
          7. Enable polling for that job without setting a polling time (so it will listen to notifications from the hook script)
          8. Add an XShell job step "git log -n 1" to the job
          9. Commit a change to named-branch in the clone and push that change to the bare repo, confirm the job builds named-branch
          10. Commit a change to master in the clone and push that change to the bare repo, bug that the job never detects change and never builds
          11. Run parameterized build with value "master", bug that the master branch is not built, the named-branch is built instead
          12. Add another branch to build that is "origin/master"
          13. Commit a change to master in the clone, push that change to the bare repo, confirm the job builds master branch
          14. Change parameter from a string parameter to a Git parameter (through git parameter plugin), as a branch, with default "master" and one of the "Branch to build" values as "$BRANCH_TO_BUILD"
          15. Run the build with parameter "origin/master", confirm that the master branch is built
          16. Run the build with parameter "origin/named-branch", bug that master branch is built

          Is the problem that the parameter is ignored when a non-parameterized branch name is also to be monitored?

          Mark Waite added a comment - - edited I don't understand how to duplicate the bug you're reporting. Can you provide a series of steps which will show the bug? Steps I tried while attempting to duplicate the bug: Create a bare git repository /var/lib/git/mwaite/bugs/ JENKINS-29644 .git Create a hook script in that bare repository to notify Jenkins on every commit Clone the bare repo, create and push two branches, one named "master", the other named "named-branch" Create a parameterized Jenkins job to build from the bare repo with string parameter "BRANCH_TO_BUILD", default value "master" Set the branch to build to be "origin/$BRANCH_TO_BUILD" Add an additional branch to build that is "origin/named-branch" Enable polling for that job without setting a polling time (so it will listen to notifications from the hook script) Add an XShell job step "git log -n 1" to the job Commit a change to named-branch in the clone and push that change to the bare repo, confirm the job builds named-branch Commit a change to master in the clone and push that change to the bare repo, bug that the job never detects change and never builds Run parameterized build with value "master", bug that the master branch is not built, the named-branch is built instead Add another branch to build that is "origin/master" Commit a change to master in the clone, push that change to the bare repo, confirm the job builds master branch Change parameter from a string parameter to a Git parameter (through git parameter plugin), as a branch, with default "master" and one of the "Branch to build" values as "$BRANCH_TO_BUILD" Run the build with parameter "origin/master", confirm that the master branch is built Run the build with parameter "origin/named-branch", bug that master branch is built Is the problem that the parameter is ignored when a non-parameterized branch name is also to be monitored?

          Roi Rosenthal added a comment -

          yes, that's the bug I meant - that the branch parameter is ignored, while another branch is monitored.
          The series of steps you've made are reproducing the behavior I was reporting.

          Kudos for the responsiveness!

          Roi Rosenthal added a comment - yes, that's the bug I meant - that the branch parameter is ignored, while another branch is monitored. The series of steps you've made are reproducing the behavior I was reporting. Kudos for the responsiveness!

            Unassigned Unassigned
            roiros Roi Rosenthal
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: