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

Does not list branches when used as a parameter in pipeline script

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      I noticed that the git-parameter-plugin now supports pipeline scripts, however I can not get the plugin to pickup branches for my repository. For instance, I setup my pipeline script according to the documentation:

       

       

      pipeline {
          agent any
          parameters {
              gitParameter branchFilter: 'origin.*/(.*)', defaultValue: 'master', name: 'BRANCH_A', type: 'PT_BRANCH', useRepository: '.*crowd.git'
              gitParameter branchFilter: 'origin.*/(.*)', defaultValue: 'master', name: 'BRANCH_B', type: 'PT_BRANCH', useRepository: '.*crowd-ember.git'
          }
          stages {
              stage('Git Checkouts') {
                  steps {
                      git branch: "${params.BRANCH_A}", credentialsId: 'e9e6e6f8-4c03-4460-ac4f-f2495315ef11', url: 'git@githost.org:crowd/crowd'
                      git branch: "${params.BRANCH_B}", credentialsId: 'e9e6e6f8-4c03-4460-ac4f-f2495315ef11', url: 'git@githost.org:crowd/crowd-ember'
                  }
              }
          }
      }

       

      The job has been setup as a "Pipeline" type and the script above is what I placed in its "Pipleline Script" section. 

      And yet, when I run my pipeline script I only see:

       

       

      Not entirely sure what I'm doing wrong here...

       

       

        Attachments

          Activity

          Hide
          ctataryn Craig Tataryn added a comment -

          Boguslaw Klimas I think everything is good.  I didn't have the same problems when re-testing.  However, I did find that if I used the git@github.com/klimas7 urls in the checkout I'd get a "Permission Denied (public key)" error. I had to test using the https repo urls.

          Thanks for your help.

           

          Show
          ctataryn Craig Tataryn added a comment - Boguslaw Klimas  I think everything is good.  I didn't have the same problems when re-testing.  However, I did find that if I used the git@github.com/klimas7 urls in the checkout I'd get a "Permission Denied (public key)" error. I had to test using the https repo urls. Thanks for your help.  
          Hide
          ctataryn Craig Tataryn added a comment -

          Damn. I just tried this again on my own project... same problem. The only way to get around it is to comment out the "branch" in the git command.  I'll put together a demo and paste the required logs.

          Show
          ctataryn Craig Tataryn added a comment - Damn. I just tried this again on my own project... same problem. The only way to get around it is to comment out the "branch" in the git command.  I'll put together a demo and paste the required logs.
          Hide
          ctataryn Craig Tataryn added a comment -

          Boguslaw Klimas I figured it out!  Ok, so if your build fails for any reason the first time you run it (which happened for me in my pipeline script), Jenkins will then become "parameter aware" and will create the Git parameter for you. After this, you are screwed.  The only way around it is to edit the job, explicitly remove the parameter from the top of the job definition (i.e. not from the Pipeline script itself, but rather from the "This project is Parameterized" area.  Then you can run it again as if it were your first time running the job, wait for it to finish, and then go back and "Build with Parameters" and the Git parameter will correctly show the branches, instead of the error message.

          Show
          ctataryn Craig Tataryn added a comment - Boguslaw Klimas I figured it out!  Ok, so if your build fails for any reason the first time you run it (which happened for me in my pipeline script), Jenkins will then become "parameter aware" and will create the Git parameter for you. After this, you are screwed.  The only way around it is to edit the job, explicitly remove the parameter from the top of the job definition (i.e. not from the Pipeline script itself, but rather from the "This project is Parameterized" area.  Then you can run it again as if it were your first time running the job, wait for it to finish, and then go back and "Build with Parameters" and the Git parameter will correctly show the branches, instead of the error message.
          Hide
          klimas7 Boguslaw Klimas added a comment -

          This issue should be resolve in release 0.9.10

          Show
          klimas7 Boguslaw Klimas added a comment - This issue should be resolve in release 0.9.10
          Hide
          klimas7 Boguslaw Klimas added a comment -

          Release 0.9.10

          Show
          klimas7 Boguslaw Klimas added a comment - Release 0.9.10

            People

            • Assignee:
              klimas7 Boguslaw Klimas
              Reporter:
              ctataryn Craig Tataryn
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: