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

ENV VAR / Job Parameter not being used in Git Checkout

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Critical
    • Resolution: Duplicate
    • Component/s: git-plugin
    • Labels:
      None
    • Similar Issues:

      Description

      I have a job with a String Parameter - BRANCH_NAME

      I am running' Pipeline Script from SCM'

      I have specified the parameter BRANCH_NAME in the 'Branches to Build' field as an environment variable (i,e ${BRANCH_NAME})

      It does not clone that branch - I get an error:
      hudson.plugins.git.GitException: Command "git fetch --tags --force --progress --prune – origin +refs/heads/${BRANCH_NAME}:refs/remotes/origin/${BRANCH_NAME}"

       

        Attachments

          Issue Links

            Activity

            Hide
            djl197 Daniel Laird added a comment -

            Forgot to add we are running 4.2.1 of the plugin 

            Show
            djl197 Daniel Laird added a comment - Forgot to add we are running 4.2.1 of the plugin 
            Hide
            markewaite Mark Waite added a comment - - edited

            Please provide your pipeline definition file, especially the checkout step. I suspect that you've used single quotes around the refspec instead of using double quotes. It may also be that you need to use ${env.BRANCH_NAME} in the step rather than ${BRANCH_NAME}.

            Show
            markewaite Mark Waite added a comment - - edited Please provide your pipeline definition file, especially the checkout step. I suspect that you've used single quotes around the refspec instead of using double quotes. It may also be that you need to use ${env.BRANCH_NAME } in the step rather than ${BRANCH_NAME }.
            Hide
            djl197 Daniel Laird added a comment -

            Hi - Its a manually configured 'Pipeline' Job - which I have a string parameter:

            I then specify is a Pipeline from SCM
            And select the following:

            It never gets to the point where it runs the pipeline script within SCM.  It seems to not checkout the specified branch (if i use a hardcoded value it works)

            Does that help?

             

            Show
            djl197 Daniel Laird added a comment - Hi - Its a manually configured 'Pipeline' Job - which I have a string parameter: I then specify is a Pipeline from SCM And select the following: It never gets to the point where it runs the pipeline script within SCM.  It seems to not checkout the specified branch (if i use a hardcoded value it works) Does that help?  
            Hide
            djl197 Daniel Laird added a comment - - edited

            I also tried a 'Git Parameter' and not a 'String Parameter' - it lists the branches succesfully but still cant be used as an ENV var in the Branch Specifier field.

            Show
            djl197 Daniel Laird added a comment - - edited I also tried a 'Git Parameter' and not a 'String Parameter' - it lists the branches succesfully but still cant be used as an ENV var in the Branch Specifier field.
            Hide
            markewaite Mark Waite added a comment - - edited

            Duplicate of JENKINS-49758.

            I believe this use case is much better handled by using a multibranch pipeline to automatically create and delete a job for each branch rather than having a single job which can switch from one branch to another branch based on a parameter from the user.

            Show
            markewaite Mark Waite added a comment - - edited Duplicate of JENKINS-49758 . I believe this use case is much better handled by using a multibranch pipeline to automatically create and delete a job for each branch rather than having a single job which can switch from one branch to another branch based on a parameter from the user.

              People

              • Assignee:
                markewaite Mark Waite
                Reporter:
                djl197 Daniel Laird
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: