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

Declarative Pipeline Environment ignored

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Component/s: kubernetes-plugin
    • Labels:
      None
    • Similar Issues:

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: