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

Lost vars in kubernetes declarative pipeline

    Details

    • Similar Issues:

      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

          Hide
          csanchez Carlos Sanchez added a comment -

          where is that code ?

          Show
          csanchez Carlos Sanchez added a comment - where is that code ?
          Hide
          rdcarrera Rubén Carrera added a comment -

          In a jenkinsfile within the repository.

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

          Perfect,

           

          We're going to do the update.

           

          Thank Carlos!

          Regards.

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

            People

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

              Dates

              • Created:
                Updated:
                Resolved: