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

When using "Git Parameter PlugIn" and "Kubernetes PlugIn" at the same time, the variables in "Branches to build" cannot be assigned values

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • kubernetes-plugin
    • None
    • Jenkins 2.235.5
      Kubernetes plugin 1.27.0

      When using "Git Parameter PlugIn" and "Kubernetes PlugIn" at the same time, in the case of "Pipeline script from SCM", "Branches to build" will generally be set to the Git Parameter variable name, such as: ${branch_name}, But an error occurs when building the task:
      Pipeline] Start of Pipeline
      [Pipeline] readTrusted
      [Pipeline] End of Pipeline
      hudson.plugins.git.GitException: Command "git fetch --tags --progress --prune origin +refs/heads/${branch_name}:refs/remotes/origin/${branch_name}" returned status code 128:
      stdout:
      stderr: fatal: Couldn't find remote ref refs/heads/${branch_name}
      Unexpected end of command stream

      ${branch_name} can be used in Pipeline, because there is no problem when executing "Pipeline" at the top:
      > git --version # timeout=10
      > git --version #'git version 1.8.3.1'
      > git fetch --tags --progress http://git.bluersw.com/dev/gitlab.git +refs/heads/:refs/remotes/origin/ # timeout=10
      > git rev-parse refs/remotes/origin/test^{commit} # timeout=10
      > git rev-parse refs/remotes/origin/origin/test^{commit} # timeout=10
      Checking out Revision f7131ece6f66f7e57d53d297209326e45196596d (refs/remotes/origin/test)

      At the beginning, "Pipeline" was executed without problems. "/origin/test" was the branch I chose, but when I needed "Kubernetes PlugIn" to execute, there was an error, so I felt that "Kubernetes PlugIn" did not get the branch. Variable assignment.
      Please tell me the solution, thank you very much.

          [JENKINS-63558] When using "Git Parameter PlugIn" and "Kubernetes PlugIn" at the same time, the variables in "Branches to build" cannot be assigned values

          Please provide a Jenkinsfile that reproduces the problem.

          Vincent Latombe added a comment - Please provide a Jenkinsfile that reproduces the problem.

          Alexey Extor added a comment - - edited

          I have the same problem. I prepared a simple Jenkinsfile, Job configuration to reproduce the problem.

          Jenkinsfile:

           

          pipeline {
               agent none     parameters {
                  string(
                      name: 'BRANCH',
                      defaultValue: 'master',
                      description: 'Please specify commit, branch, tag'
                  )
                  // gitParameter defaultValue: 'master', name: 'BRANCH', type: 'PT_BRANCH'
              }    stages {        stage('Check Jenkinsfile branch') {
                      steps {
                          echo 'Jenkinsfile read from master branch...'
                          echo "${params.BRANCH}"
                      }
                  }        stage ('Get code from SCM') {
                      agent {
                          kubernetes {
                              yamlFile 'WorkerPod.yml'
                          }
                      }
                      options {
                          skipDefaultCheckout(true)
                      }
                      steps {
                          container('jenkins-63558') {
                              checkout scm: [
                                  $class: 'GitSCM',
                                  branches: [[name: "${params.BRANCH}" ]],
                                  doGenerateSubmoduleConfigurations: false,
                                  extensions: [[
                                  ]],
                                  submoduleCfg: [],
                                  userRemoteConfigs:
                                  [[
                                      url: 'git@github.com:Extor/jenkins-63558.git'
                                  ]]
                              ]
                          }
                      }
                  }
              }
          }
          

          WorkerPod.yml:

           

          ---
          kind: Pod
          spec:
            containers:
              - name: jenkins-63558
                image: alpine:latest
                imagePullPolicy: IfNotPresent
                env:
                  - name: DOCKER_HOST
                    value: tcp://localhost:2375
                tty: true
                resources:
                  requests:
                    memory: "128Mi"
                    cpu: "500m"
                  limits:
                    memory: "256Mi"
                    cpu: "1000m"
          

           

           

          job.xml: https://raw.githubusercontent.com/Extor/jenkins-63558/master/job.xml

           

           

           

          Alexey Extor added a comment - - edited I have the same problem. I prepared a simple Jenkinsfile, Job configuration to reproduce the problem. Jenkinsfile:   pipeline { agent none parameters { string( name: 'BRANCH' , defaultValue: 'master' , description: 'Please specify commit, branch, tag' ) // gitParameter defaultValue: 'master' , name: 'BRANCH' , type: 'PT_BRANCH' } stages { stage( 'Check Jenkinsfile branch' ) { steps { echo 'Jenkinsfile read from master branch...' echo "${params.BRANCH}" } } stage ( 'Get code from SCM' ) { agent { kubernetes { yamlFile 'WorkerPod.yml' } } options { skipDefaultCheckout( true ) } steps { container( 'jenkins-63558' ) { checkout scm: [ $class: 'GitSCM' , branches: [[name: "${params.BRANCH}" ]], doGenerateSubmoduleConfigurations: false , extensions: [[ ]], submoduleCfg: [], userRemoteConfigs: [[ url: 'git@github.com:Extor/jenkins-63558.git' ]] ] } } } } } WorkerPod.yml:   --- kind: Pod spec: containers: - name: jenkins-63558 image: alpine:latest imagePullPolicy: IfNotPresent env: - name: DOCKER_HOST value: tcp: //localhost:2375 tty: true resources: requests: memory: "128Mi" cpu: "500m" limits: memory: "256Mi" cpu: "1000m"     job.xml:   https://raw.githubusercontent.com/Extor/jenkins-63558/master/job.xml      

            Unassigned Unassigned
            bluersw Sun WeiSheng
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: