parameters are not available as environment variables in pod containers

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      Pipeline parameters are not available as environment variables in the pod containers that aren't the JNLP container.

      This Jenkinsfile produces output showing the issue:

      properties([
          parameters([
              string(name: 'PARAM_TEST', defaultValue: 'foo', description: ''),
          ]),
      ])
      
      podTemplate(
          cloud: 'kubernetes',
          containers: [
              containerTemplate(
                  alwaysPullImage: false,
                  envVars: [],
                  image: 'alpine',
                  name: 'alpine',
                  privileged: false,
                  ttyEnabled: true,
              ),
          ],
          serviceAccount: 'jenkins',
          idleMinutes: 0,
          instanceCap: 2,
          label: 'test-pipeline',
          name: 'test-pipeline',
      ) {
          node ('test-pipeline') {
              sh 'echo \$PARAM_TEST: $PARAM_TEST'
              container('alpine') {
                  sh 'echo \$PARAM_TEST: $PARAM_TEST'
              }
          }
      }
      
      

      Output:

      Started by user chance.zibolski
      [Pipeline] properties
      [Pipeline] podTemplate
      [Pipeline] {
      [Pipeline] node
      Running on test-pipeline-xchj7-gcv7h in /home/jenkins/workspace/test-pipeline
      [Pipeline] {
      [Pipeline] sh
      [test-pipeline] Running shell script
      + echo foo: foo
      foo: foo
      [Pipeline] container
      [Pipeline] {
      [Pipeline] sh
      [test-pipeline] Running shell script
      + echo :
      :
      [Pipeline] }
      [Pipeline] // container
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] }
      [Pipeline] // podTemplate
      [Pipeline] End of Pipeline
      Finished: SUCCESS
      

            Assignee:
            Unassigned
            Reporter:
            Chance Zibolski
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: