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

git-parameter-plugin in declarative pipeline showing origin1 and origin as remote branches but actually did'nt exist

      I have configured Jenkins git parameter plugin for selecting appropriate branches before building a job. I am using two repositories for building a single job.

      For one of the repositories its showing two remote sever as origin and origin1 but actually it has only one it is origin.

      I have checked the repository and given the result as below

       
      $ git ls-remote --heads origin
      d8c63b4c1f1a87cba2b5065d3c2018193079fb80        refs/heads/XXXX
      3b390cec5ede9ec4dede3b83dc8d05969a286b70        refs/heads/XXXX
      ea0908b790a8491584bfe0f7e7ba459ee6307cb0        refs/heads/XXXX
      a1225d5a8f1a24ef4c65384b6833224358d30587        refs/heads/XXXX
      74977aed5ed375d2afae0e35d3ec73fa214e63e1        refs/heads/XXXX
      9e3e0fa0c93829b9dbb945f3d7788e77462f15c9        refs/heads/feature/scenario
      ff9af7bcd7d6c06cbb573656cf73abe2c0b26538        refs/heads/master
       
      $ git ls-remote
      From https://github.developer.allianz.io/cta-crui/crui-data-model.git
      ff9af7bcd7d6c06cbb573656cf73abe2c0b26538        HEAD
      d8c63b4c1f1a87cba2b5065d3c2018193079fb80        refs/heads/XXXX
      3b390cec5ede9ec4dede3b83dc8d05969a286b70        refs/heads/XXXX
      ea0908b790a8491584bfe0f7e7ba459ee6307cb0        refs/heads/XXXX
      a1225d5a8f1a24ef4c65384b6833224358d30587        refs/heads/XXXX
      74977aed5ed375d2afae0e35d3ec73fa214e63e1        refs/heads/XXXX
      9e3e0fa0c93829b9dbb945f3d7788e77462f15c9        refs/heads/feature/scenario
      ff9af7bcd7d6c06cbb573656cf73abe2c0b26538        refs/heads/master
      7d3177956309ea27d828ea8e879084ee2c1a5344        refs/pull/1/head
      27a27fe3d82c0fd867a54716b693e7173968b05b        refs/pull/2/head
      9e3e0fa0c93829b9dbb945f3d7788e77462f15c9        refs/pull/3/head
      d8c63b4c1f1a87cba2b5065d3c2018193079fb80        refs/pull/4/head
      3b390cec5ede9ec4dede3b83dc8d05969a286b70        refs/pull/5/head
      a1225d5a8f1a24ef4c65384b6833224358d30587        refs/pull/6/head
      74977aed5ed375d2afae0e35d3ec73fa214e63e1        refs/pull/7/head
      9564fdb879cc3b3ff15d66baf4d9a0cfafcda120        refs/pull/7/merge
      ff9af7bcd7d6c06cbb573656cf73abe2c0b26538        refs/tags/v0.1

       
       
      But in jenkins job it showing like this

       
       
      You can see both origin1 and origin are showing . Please provide us support regarding this issue 
       

          [JENKINS-61769] git-parameter-plugin in declarative pipeline showing origin1 and origin as remote branches but actually did'nt exist

          Hi,

          Are you try used 'use-repository' option?

          https://github.com/jenkinsci/git-parameter-plugin#use-repository

          Boguslaw Klimas added a comment - Hi, Are you try used 'use-repository' option? https://github.com/jenkinsci/git-parameter-plugin#use-repository

          krishna prasad added a comment - - edited

          Hi klimas7,

          Yes I am already using use-repository option. so that it will select appropriate branches before the Jenkins build start .

          In this case I am confused since origin1 remote branch is not existing in repository as you can see in the above comments . So how this is getting populated in the parameter branch list.

          krishna prasad added a comment - - edited Hi klimas7 , Yes I am already using use-repository option. so that it will select appropriate branches before the Jenkins build start . In this case I am confused since origin1 remote branch is not existing in repository as you can see in the above comments . So how this is getting populated in the parameter branch list.

          Hi klimas7,

          Is it related to plugin issue ? I there any way to debug this. 

          krishna prasad added a comment - Hi klimas7 , Is it related to plugin issue ? I there any way to debug this. 

          Rahul Singh added a comment -

          I am also facing this issue and this is happening after plugin update. Now If I am adding more than one repository then I am getting the branch name as origin/branch1 , origin1/branch1 , origin2, branch for each git parameter added for the each repository. I am having 3 repos at the moment. 

          krishnakp2 Did you get any solution to this ?

          Rahul Singh added a comment - I am also facing this issue and this is happening after plugin update. Now If I am adding more than one repository then I am getting the branch name as origin/branch1 , origin1/branch1 , origin2, branch for each git parameter added for the each repository. I am having 3 repos at the moment.  krishnakp2 Did you get any solution to this ?

          Unfortunately, the problem still exists.

          However, I found out that the problem only occurs when the job does not process the gitParameter itself or does not check out the repository itself.
          As an example: A main pipeline job has gitParameters which are from different repositories. However, the main pipeline does not check out the associated repositories, but only starts other pipelines which receive exactly this git parameter as a parameter and check it out.

          As a workaround I wrote a function to clean up the gitParameters, so that the number is no longer exceeded.

          def sanitizeGitParameters( gitParameterString ) {
              // sanitizes the repository URLs which can start with 'origin{NUMBER}/{BRANCH_NAME}' and transform them if necessary into 'origin/{BRANCH_NAME}'.
              // The URLs of the branches in the gitParameters list that are not checked out in this Job because they are only passed as arguments, have a number after 'origin' in the branch URL.
              // Bug is reported here: https://issues.jenkins.io/browse/JENKINS-61769
              if( gitParameterString.contains('/')){
                  if (!gitParameterString.startsWith("origin/")){
                      return "origin/" + gitParameterString.substring(gitParameterString.indexOf("/") + 1);
                  }
              }
              return gitParameterString
          } 

          Pascal Gimmler added a comment - Unfortunately, the problem still exists. However, I found out that the problem only occurs when the job does not process the gitParameter itself or does not check out the repository itself. As an example: A main pipeline job has gitParameters which are from different repositories. However, the main pipeline does not check out the associated repositories, but only starts other pipelines which receive exactly this git parameter as a parameter and check it out. As a workaround I wrote a function to clean up the gitParameters, so that the number is no longer exceeded. def sanitizeGitParameters( gitParameterString ) {     // sanitizes the repository URLs which can start with 'origin{NUMBER}/{BRANCH_NAME}' and transform them if necessary into 'origin/{BRANCH_NAME}' .     // The URLs of the branches in the gitParameters list that are not checked out in this Job because they are only passed as arguments, have a number after 'origin' in the branch URL.     // Bug is reported here: https://issues.jenkins.io/browse/JENKINS-61769     if ( gitParameterString.contains( '/' )){         if (!gitParameterString.startsWith( "origin/" )){             return "origin/" + gitParameterString.substring(gitParameterString.indexOf( "/" ) + 1);         }     }     return gitParameterString }

            klimas7 Boguslaw Klimas
            krishnakp2 krishna prasad
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: