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

Credentials environment variable isn't evaluated/available in the environment directive

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • None
    • Jenkins 2.32.3
      Pipeline Model Definition Plugin 1.1.1 (and associated/dependent plugins)

      We'd like to do:

      pipeline {
       // snip //
       environment {
        VARIABLES = credentials('MOZILLIANS_VARIABLES')
        SAUCELABS_API_KEY = credentials('SAUCELABS_API_KEY')
        PYTEST_ADDOPTS = "--color=yes --driver=SauceLabs --variables=capabilities.json --variables=${VARIABLES}"
       }
       // snip //
      }
      

      But we get:

      WorkflowScript: 25: ""--variables" is not a valid identifier and cannot be used for an environment variable. Identifiers must start with a letter or underscore and can contain only letters, numbers or underscores. @ line 25, column 7.
       "--variables=${VARIABLES}"
      

       The workaround is to currently do:

      pipeline {
       // snip //
       environment {
        VARIABLES = credentials('MOZILLIANS_VARIABLES')
        SAUCELABS_API_KEY = credentials('SAUCELABS_API_KEY')
       }
       stages {
        stage('Test') {
         environment {
          PYTEST_ADDOPTS = "--color=yes --driver=SauceLabs --variables=capabilities.json --variables=${VARIABLES}"
         }
        // snip //
      }

       

       

            abayer Andrew Bayer
            stephendonner Stephen Donner
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: