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

Declarative Pipeline Environment ignored

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • kubernetes-plugin
    • None

      The environment declarative no longer works in pipeline. 

       

      pipeline {
        agent {
          kubernetes {
              label 'maven-pod'
              containerTemplate {
              name 'maven-container'
              image 'maven'
              workingDir  '/home/jenkins'
              ttyEnabled true
              command 'cat'
              }
          }
        }
        environment {
          test = 'Hello World!'
        }
        stages {
          stage('print') {
            steps {
              //will not print
              sh 'echo ${test}'
               container('maven-container'){
                   //will also not print
                    sh 'echo ${test}'
                 }
              }
            }
          }
        }    
      
      
      

      It appears to be due to environment variables for the container being set prior to container execution.

            csanchez Carlos Sanchez
            seakip18 Matthew Ludlum
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: