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

Lost vars in kubernetes declarative pipeline

XMLWordPrintable

      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.

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

              Created:
              Updated:
              Resolved: