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

Pipeline Config: Getting env vars from Credentials

    Details

    • Similar Issues:

      Description

      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.

        Attachments

          Activity

          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Robert Sandell
          Path:
          pipeline-model-definition/pom.xml
          pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/steps/CredentialWrapperStepTest.java
          http://jenkins-ci.org/commit/pipeline-model-definition-plugin/bec0c4be0503c5703e9d6e0da24833bc999d1372
          Log:
          JENKINS-37778 Fix test after merge

          Something unrelated in the shared libraries caused the tests to fail
          bumping the dependency down one version to fix that.
          An npe caused bu the credentials folder property to not be correctly initialized also fixed.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Robert Sandell Path: pipeline-model-definition/pom.xml pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/steps/CredentialWrapperStepTest.java http://jenkins-ci.org/commit/pipeline-model-definition-plugin/bec0c4be0503c5703e9d6e0da24833bc999d1372 Log: JENKINS-37778 Fix test after merge Something unrelated in the shared libraries caused the tests to fail bumping the dependency down one version to fix that. An npe caused bu the credentials folder property to not be correctly initialized also fixed.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Robert Sandell
          Path:
          pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/AbstractModelASTCodeBlock.java
          pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTScriptBlock.java
          pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTStage.java
          pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTWhen.java
          pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidator.java
          pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Stage.groovy
          pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/JSONParser.groovy
          pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
          pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
          pipeline-model-definition/src/main/resources/ast-schema.json
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
          pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/WhenStageTest.java
          pipeline-model-definition/src/test/resources/when/simpleWhen.groovy
          pipeline-model-definition/src/test/resources/when/whenEmpty.groovy
          pipeline-model-definition/src/test/resources/when/whenException.groovy
          http://jenkins-ci.org/commit/pipeline-model-definition-plugin/44c8249f6df539cc3477d08b0142813d91001a45
          Log:
          Merge remote-tracking branch 'origin/master' into JENKINS-37778

          Conflicts:
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Robert Sandell Path: pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/AbstractModelASTCodeBlock.java pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTScriptBlock.java pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTStage.java pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTWhen.java pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidator.java pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Stage.groovy pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/JSONParser.groovy pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy pipeline-model-definition/src/main/resources/ast-schema.json pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/WhenStageTest.java pipeline-model-definition/src/test/resources/when/simpleWhen.groovy pipeline-model-definition/src/test/resources/when/whenEmpty.groovy pipeline-model-definition/src/test/resources/when/whenException.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/44c8249f6df539cc3477d08b0142813d91001a45 Log: Merge remote-tracking branch 'origin/master' into JENKINS-37778 Conflicts: pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
          Hide
          scm_issue_link 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/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ClosureModelTranslator.groovy
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/PropertiesToMapTranslator.groovy
          pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java
          pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/EnvironmentTest.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/mixedEnv.groovy
          pipeline-model-definition/src/test/resources/credentials/noBinding.groovy
          pipeline-model-definition/src/test/resources/credentials/usernamePassword.groovy
          http://jenkins-ci.org/commit/pipeline-model-definition-plugin/f4e86644f5f483602da9b7686d9fc4a0e6b51e07
          Log:
          Merge pull request #46 from jenkinsci/JENKINS-37778

          JENKINS-37778 Support credentials in environment

          Compare: https://github.com/jenkinsci/pipeline-model-definition-plugin/compare/ec6f0ea92278...f4e86644f5f4

          Show
          scm_issue_link 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/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ClosureModelTranslator.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/PropertiesToMapTranslator.groovy pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/EnvironmentTest.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/mixedEnv.groovy pipeline-model-definition/src/test/resources/credentials/noBinding.groovy pipeline-model-definition/src/test/resources/credentials/usernamePassword.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/f4e86644f5f483602da9b7686d9fc4a0e6b51e07 Log: Merge pull request #46 from jenkinsci/ JENKINS-37778 JENKINS-37778 Support credentials in environment Compare: https://github.com/jenkinsci/pipeline-model-definition-plugin/compare/ec6f0ea92278...f4e86644f5f4
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Robert Sandell
          Path:
          SYNTAX.md
          http://jenkins-ci.org/commit/pipeline-model-definition-plugin/71c3d60ee486e48757bbd76315dc69a9e0418775
          Log:
          Update SYNTAX.md

          Noting changes introduced in JENKINS-37792, JENKINS-37781 and JENKINS-37778

          Also fixed the script example and marked the code sections as groovy
          so that GitHub hopefully can color the code a bit more nicely.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Robert Sandell Path: SYNTAX.md http://jenkins-ci.org/commit/pipeline-model-definition-plugin/71c3d60ee486e48757bbd76315dc69a9e0418775 Log: Update SYNTAX.md Noting changes introduced in JENKINS-37792 , JENKINS-37781 and JENKINS-37778 Also fixed the script example and marked the code sections as groovy so that GitHub hopefully can color the code a bit more nicely.
          Hide
          bitwiseman Liam Newman added a comment -

          Bulk closing resolved issues.

          Show
          bitwiseman Liam Newman added a comment - Bulk closing resolved issues.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: