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

pipeline declarative 'parameters' DSL should support credential parameter

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      When creating release automation for blueocean, I wanted user to select their user store credentials as build input parameter. 

      I can do it using pipeline script:

       

      [$class: 'CredentialsParameterDefinition', credentialType: 'com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl', defaultValue: '', description: '', name: 'GITHUB_CREDENTIALS', required: true]
      

       

      I can't use declarative pipeline as it only supports string and boolean, there is no support for credentials parameter.

      Andrew Bayer tells me its because there is no symbol on descriptor of https://github.com/jenkinsci/credentials-plugin/blob/master/src/main/java/com/cloudbees/plugins/credentials/CredentialsParameterDefinition.java.

      I also tried using string parameter with declarative where user types in their user store credential id but then declarative 'credentials' DSL failed to find it. Below is sample script where 'my-user-cred' is credential id created in user credentials store.

       

      pipeline{
          agent any
          environment { 
              USER_CRED = credentials('my-user-cred') 
          }
          stages {
              stage('Example') {
                  steps {
                      sh 'echo ${USER_CRED}'
                  }
              }
          }
      }
      

       

       It fails with:

      org.jenkinsci.plugins.credentialsbinding.impl.CredentialNotFoundException: my-user-cred
      	at org.jenkinsci.plugins.pipeline.modeldefinition.model.CredentialsBindingHandler.forId(CredentialsBindingHandler.java:121)
      	at org.jenkinsci.plugins.pipeline.modeldefinition.model.CredentialsBindingHandler$forId.call(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      	at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:18)
      	at 
      

      Probably these are two different issues but relates to declarative and credentials so thought will list them here.

       

       

       

        Attachments

          Issue Links

            Activity

            Hide
            abayer Andrew Bayer added a comment -

            Vivek Pandey - could you split the user store credentials out to a separate ticket? Thanks.

            Show
            abayer Andrew Bayer added a comment - Vivek Pandey - could you split the user store credentials out to a separate ticket? Thanks.
            Hide
            abayer Andrew Bayer added a comment -
            Show
            abayer Andrew Bayer added a comment - PR up ( https://github.com/jenkinsci/credentials-plugin/pull/86 ) to add the needed symbol.
            Show
            vivek Vivek Pandey added a comment - Andrew Bayer done, https://issues.jenkins-ci.org/browse/JENKINS-44635
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            pom.xml
            src/main/java/com/cloudbees/plugins/credentials/CredentialsParameterDefinition.java
            http://jenkins-ci.org/commit/credentials-plugin/b8e5d604fdc0d194617873889f54722e118eee1e
            Log:
            [FIXED JENKINS-44588] Add "credentials" symbol to parameter

            Allows use of the credentials parameter type in Declarative.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pom.xml src/main/java/com/cloudbees/plugins/credentials/CredentialsParameterDefinition.java http://jenkins-ci.org/commit/credentials-plugin/b8e5d604fdc0d194617873889f54722e118eee1e Log: [FIXED JENKINS-44588] Add "credentials" symbol to parameter Allows use of the credentials parameter type in Declarative.
            Hide
            bitwiseman Liam Newman added a comment -

            Bulk closing resolved issues.

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

              People

              Assignee:
              abayer Andrew Bayer
              Reporter:
              vivek Vivek Pandey
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: