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

Can't use parameters in git plugin "Branches to build" configuration

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: git-plugin
    • Labels:
      None
    • Environment:
      Platform: All, OS: All
    • Similar Issues:

      Description

      I would like to be able to use parameters in the "Branches to build"
      configuration setting.

      Something like origin/myproject-${version}-branch should check replace the
      ${version} string with the correct value given in the build parameters.

        Attachments

          Activity

          tisoft_media tisoft_media created issue -
          abayer Andrew Bayer made changes -
          Field Original Value New Value
          Assignee jbq [ jbq ] abayer [ abayer ]
          Hide
          abayer Andrew Bayer added a comment -

          Fixed - not sure exactly when, but it's definitely working in 0.9.1.

          Show
          abayer Andrew Bayer added a comment - Fixed - not sure exactly when, but it's definitely working in 0.9.1.
          abayer Andrew Bayer made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          tisoft_media tisoft_media made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Hide
          weissjeffm Jeff Weiss added a comment -

          This is not working for me in plugin version 1.1.26. If I specify anything like

          origin/$MYBRANCH

          or

          origin/${MYBRANCH}

          it just picks some random branch. If I hardcode it to the branch I want then it builds the right branch. But the point is to be able to use a parameter, and I can't.

          Show
          weissjeffm Jeff Weiss added a comment - This is not working for me in plugin version 1.1.26. If I specify anything like origin/$MYBRANCH or origin/${MYBRANCH} it just picks some random branch. If I hardcode it to the branch I want then it builds the right branch. But the point is to be able to use a parameter, and I can't.
          weissjeffm Jeff Weiss made changes -
          Resolution Fixed [ 1 ]
          Status Closed [ 6 ] Reopened [ 4 ]
          Hide
          orrc Christopher Orr added a comment -

          I set up a job with this today, so it definitely works.

          Have you added the branch parameter to the refspec?

          Show
          orrc Christopher Orr added a comment - I set up a job with this today, so it definitely works. Have you added the branch parameter to the refspec?
          Hide
          howama howama added a comment -

          Not sure if this is a different issue, but we're having problems with git polling when parameters are used in the branch field - a single (random?) branch is being built continuously rather than just the branch that has changed.

          We'd like to create a parameterised build with the branch as the build parameter, defaulting to :^(?!.master).$ i.e. we want automatic builds of all commits to any non-master branches and also to have the option to build a specific branch manually.

          Show
          howama howama added a comment - Not sure if this is a different issue, but we're having problems with git polling when parameters are used in the branch field - a single (random?) branch is being built continuously rather than just the branch that has changed. We'd like to create a parameterised build with the branch as the build parameter, defaulting to :^(?!. master). $ i.e. we want automatic builds of all commits to any non-master branches and also to have the option to build a specific branch manually.
          Hide
          saji Saji Weerasingham added a comment -

          It would be good if the Git plugin could just detect what branches exist and offer it as a build parameter.

          Perhaps the "Branches to build" field could have a drop-down-list that has the options "Specific branch" or "Branch Picker Parameter". If "Specific Branch" is selected, then the current "Branch Specifier" text box should appear to allow the user the specify the branch. If "Branch Picker Parameter" is selected the text box should read "Default Branch" text box should appear (this branch will be used for triggered builds). When the user manually start a build, a drop-down-list parameter should appear with the branches as options (the branch specified as the default branch in the settings should be pre-selected if it exists).

          Show
          saji Saji Weerasingham added a comment - It would be good if the Git plugin could just detect what branches exist and offer it as a build parameter. Perhaps the "Branches to build" field could have a drop-down-list that has the options "Specific branch" or "Branch Picker Parameter". If "Specific Branch" is selected, then the current "Branch Specifier" text box should appear to allow the user the specify the branch. If "Branch Picker Parameter" is selected the text box should read "Default Branch" text box should appear (this branch will be used for triggered builds). When the user manually start a build, a drop-down-list parameter should appear with the branches as options (the branch specified as the default branch in the settings should be pre-selected if it exists).
          Hide
          markewaite Mark Waite added a comment - - edited

          The git parameter plugin seems like a possible candidate to add that type of advanced pick list capability, since it must already be parsing the content of the git repository to generate its current pick lists.

          Show
          markewaite Mark Waite added a comment - - edited The git parameter plugin seems like a possible candidate to add that type of advanced pick list capability, since it must already be parsing the content of the git repository to generate its current pick lists.
          Hide
          saji Saji Weerasingham added a comment -

          The git parameter plugin only supports tags and revisions, not branches.

          I currently use the Extended Choice Parameter plugin and build the drop-down-list from a branches text file, which is populated by another Jenkins builds that runs every 5 mins. It executes a batch file with the following contents.

          @echo off

          if [%1] == [] exit /b 1
          set workspace=%1

          cd %workspace%

          git fetch --prune
          git pull
          git branch -r > %workspace%\branches.txt

          setlocal EnableDelayedExpansion

          set lines=""
          set /a count=0

          (for /f "tokens=*" %%i in (%workspace%\branches.txt) do (
          if Unable to render embedded object: File (count) not found. gtr 0 (
          if Unable to render embedded object: File (count) not found. equ 1 (
          set lines=%%i
          ) else (
          set "lines=Unable to render embedded object: File (lines) not found.,%%i"
          )
          )

          set /a count=count+1
          ))

          setlocal DisableDelayedExpansion

          echo branches=%lines% > %workspace%\branches.txt

          Show
          saji Saji Weerasingham added a comment - The git parameter plugin only supports tags and revisions, not branches. I currently use the Extended Choice Parameter plugin and build the drop-down-list from a branches text file, which is populated by another Jenkins builds that runs every 5 mins. It executes a batch file with the following contents. @echo off if [%1] == [] exit /b 1 set workspace=%1 cd %workspace% git fetch --prune git pull git branch -r > %workspace%\branches.txt setlocal EnableDelayedExpansion set lines="" set /a count=0 (for /f "tokens=*" %%i in (%workspace%\branches.txt) do ( if Unable to render embedded object: File (count) not found. gtr 0 ( if Unable to render embedded object: File (count) not found. equ 1 ( set lines=%%i ) else ( set "lines= Unable to render embedded object: File (lines) not found. ,%%i" ) ) set /a count=count+1 )) setlocal DisableDelayedExpansion echo branches=%lines% > %workspace%\branches.txt
          Hide
          markewaite Mark Waite added a comment -

          The plugin allows parameters (as described in the original bug report). It does not provide a pick list as suggested by one of the comments. That would need to be opened as a separate request.

          Show
          markewaite Mark Waite added a comment - The plugin allows parameters (as described in the original bug report). It does not provide a pick list as suggested by one of the comments. That would need to be opened as a separate request.
          markewaite Mark Waite made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          rtyler R. Tyler Croy made changes -
          Workflow JNJira [ 134184 ] JNJira + In-Review [ 186765 ]

            People

            • Assignee:
              abayer Andrew Bayer
              Reporter:
              tisoft_media tisoft_media
            • Votes:
              2 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: