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

Lost vars in kubernetes declarative pipeline

    XMLWordPrintable

Details

    Description

      Hi, 

      We're having a problem when we define the pod configuration over the pipeline, we're lossing the vars injected by the Bitbucket Plugin (from the payload hook).

      If we define the agent to use from a label (previously configurated in the pod template on the kubernetes config) we've the envs.

      Jenkinsfile Head: 

       pipeline {
         agent{
      
           node('pod-label')    
      
        }
      
         stages { .....
        
       ENVs:
        .
       GIT_URL=[https://bitbucket.*******|https://bitbucket.%2A%2A%2A%2A%2A%2A%2A/]
       GIT_BRANCH=develop
       .
      

      But, in the other way:

      Jenkinsfile Head:

      pipeline {
        agent {
           kubernetes {
                label 'power-pod'
                inheritFrom 'pod-label'
                containerTemplate {
                   name 'jnlp'
                   args '${computer.jnlpmac} ${computer.name}'
                   resourceLimitMemory '6Gi'
                   image 'registry/image:latest'
                 }
            }
      

      This envs doesn't exist, the error over the pipeline is provocated by:
      code:

       def TEMP_VAR= env.GIT_URL ?: env.GIT_URL_1
       GIT_SPLIT_URL= TEMP_VAR.substring(0,TEMP_VAR.lastIndexOf("."))
      
      error:
       java.lang.NullPointerException: Cannot invoke method lastIndexOf() on null object
      

      Thanks,
      Regards.

      Attachments

        Activity

          where is that code ?

          csanchez Carlos Sanchez added a comment - where is that code ?

          In a jenkinsfile within the repository.

          rdcarrera Rubén Carrera added a comment - In a jenkinsfile within the repository.
          csanchez Carlos Sanchez added a comment - this was fixed in 1.12.2 https://github.com/jenkinsci/kubernetes-plugin/blob/master/CHANGELOG.md#1122

          Perfect,

           

          We're going to do the update.

           

          Thank Carlos!

          Regards.

          rdcarrera Rubén Carrera added a comment - Perfect,   We're going to do the update.   Thank Carlos! Regards.

          People

            csanchez Carlos Sanchez
            rdcarrera Rubén Carrera
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: