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

Pipeline Config: Getting env vars from Credentials

      What would be nice and idiomatic is to be able to something like:

      environment {
          AWS_ACCESS_KEY_ID = credentials(id='amazonKeyId')
          AWS_ACESS_KEY_SECRET = credentials(id='passwordId')
      }
      

      (or something more configgy looking). This can be limited to the single secret case if needed (ie not username/password).

      Using various incarnations of the wrapper:

      withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: '', passwordVariable: 'AWS_SECRET', usernameVariable: 'AWS_ID']]) {
          // some block
      }
      

      You can, I think get credentials back out but it is seems less configgy for common scenarious.

          [JENKINS-37778] Pipeline Config: Getting env vars from Credentials

          Andrew Bayer created issue -
          Andrew Bayer made changes -
          Environment New: Pipeline Config 0.1

          Andrew Bayer added a comment -

          So I'm wondering if it might actually make more sense to do a separate credentials section rather than combining with the environment section...need to think on this.

          Andrew Bayer added a comment - So I'm wondering if it might actually make more sense to do a separate credentials section rather than combining with the environment section...need to think on this.
          rsandell made changes -
          Assignee Original: Andrew Bayer [ abayer ] New: rsandell [ rsandell ]
          rsandell made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]

          Michael Neale added a comment - - edited

          abayer given most tools outside of the java ecosystem that one could use from a 'sh' step would use environment variables, I think it still makes sense to make it explicit what they are (those that don't use IAM or some out of band security service or device of course).

          Michael Neale added a comment - - edited abayer given most tools outside of the java ecosystem that one could use from a 'sh' step would use environment variables, I think it still makes sense to make it explicit what they are (those that don't use IAM or some out of band security service or device of course).

          Code changed in jenkins
          User: Robert Sandell
          Path:
          pipeline-model-definition/pom.xml
          pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Root.groovy
          pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Stage.groovy
          pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/model/CredentialsBindingHandler.java
          pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/steps/CredentialWrapper.java
          pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/steps/CredentialWrapperStep.java
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/steps/CredentialWrapperStep/config.groovy
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/steps/CredentialWrapperStep/help.html
          pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java
          pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/steps/CredentialWrapperStepTest.java
          pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/util/HasArchived.java
          pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/util/InputStreamContainingString.java
          pipeline-model-definition/src/test/resources/credentials/usernamePassword.groovy
          http://jenkins-ci.org/commit/pipeline-model-definition-plugin/5346000747953975d22b2b09a8a5d44328ca9a3b
          Log:
          JENKINS-37778 Support credentials in environment

          Compare: https://github.com/jenkinsci/pipeline-model-definition-plugin/compare/6e953c4ed1e2^...534600074795

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Robert Sandell Path: pipeline-model-definition/pom.xml pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Root.groovy pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Stage.groovy pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/model/CredentialsBindingHandler.java pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/steps/CredentialWrapper.java pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/steps/CredentialWrapperStep.java pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/steps/CredentialWrapperStep/config.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/steps/CredentialWrapperStep/help.html pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/steps/CredentialWrapperStepTest.java pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/util/HasArchived.java pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/util/InputStreamContainingString.java pipeline-model-definition/src/test/resources/credentials/usernamePassword.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/5346000747953975d22b2b09a8a5d44328ca9a3b Log: JENKINS-37778 Support credentials in environment Compare: https://github.com/jenkinsci/pipeline-model-definition-plugin/compare/6e953c4ed1e2 ^...534600074795

          Code changed in jenkins
          User: Robert Sandell
          Path:
          pipeline-model-api/pom.xml
          pipeline-model-declarative-agent/pom.xml
          pipeline-model-definition/pom.xml
          pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
          pom.xml
          http://jenkins-ci.org/commit/pipeline-model-definition-plugin/df39786c1495c4df0a974892c905770390160b35
          Log:
          Merge branch 'master' of github.com:jenkinsci/pipeline-model-definition-plugin into JENKINS-37778

          Compare: https://github.com/jenkinsci/pipeline-model-definition-plugin/compare/9b4ba7e75cea...df39786c1495

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Robert Sandell Path: pipeline-model-api/pom.xml pipeline-model-declarative-agent/pom.xml pipeline-model-definition/pom.xml pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy pom.xml http://jenkins-ci.org/commit/pipeline-model-definition-plugin/df39786c1495c4df0a974892c905770390160b35 Log: Merge branch 'master' of github.com:jenkinsci/pipeline-model-definition-plugin into JENKINS-37778 Compare: https://github.com/jenkinsci/pipeline-model-definition-plugin/compare/9b4ba7e75cea...df39786c1495

          Code changed in jenkins
          User: Robert Sandell
          Path:
          pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/steps/CredentialWrapperStepTest.java
          pipeline-model-definition/src/test/resources/credentials/mixedEnv.groovy
          http://jenkins-ci.org/commit/pipeline-model-definition-plugin/8b4885875aca43509f183a5e5972608b7387c119
          Log:
          JENKINS-37778 more happy path testing

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Robert Sandell Path: pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/steps/CredentialWrapperStepTest.java pipeline-model-definition/src/test/resources/credentials/mixedEnv.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/8b4885875aca43509f183a5e5972608b7387c119 Log: JENKINS-37778 more happy path testing

          Code changed in jenkins
          User: Robert Sandell
          Path:
          pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/model/CredentialsBindingHandler.java
          pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/steps/CredentialWrapperStepTest.java
          pipeline-model-definition/src/test/resources/credentials/noBinding.groovy
          http://jenkins-ci.org/commit/pipeline-model-definition-plugin/47f5b4c035267b8300904cf7f55370d3fbe8ce22
          Log:
          JENKINS-37778 A negative test

          And some test case refactoring to try to fix/work around the ClassRule optimizations

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Robert Sandell Path: pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/model/CredentialsBindingHandler.java pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/steps/CredentialWrapperStepTest.java pipeline-model-definition/src/test/resources/credentials/noBinding.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/47f5b4c035267b8300904cf7f55370d3fbe8ce22 Log: JENKINS-37778 A negative test And some test case refactoring to try to fix/work around the ClassRule optimizations

            rsandell rsandell
            abayer Andrew Bayer
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: