[JIRA] (JENKINS-59971) Unable to create folder credentials for plain-credentials-plugin

1 view
Skip to first unread message

mkovarik@redhat.com (JIRA)

unread,
Oct 29, 2019, 6:01:03 AM10/29/19
to jenkinsc...@googlegroups.com
Michal Kovarik created an issue
 
Jenkins / Bug JENKINS-59971
Unable to create folder credentials for plain-credentials-plugin
Issue Type: Bug Bug
Assignee: Daniel Spilker
Attachments: Screenshot from 2019-10-29 10-57-18.png
Components: job-dsl-plugin, plain-credentials-plugin
Created: 2019-10-29 10:00
Environment: Jenkins ver. 2.202
Plain Credentials Plugin 1.5
Job DSL 1.76
Priority: Minor Minor
Reporter: Michal Kovarik

Trying to create folder using job DSL but there is no option for credentials from plain-credentials-plugin - FileCredential and StringCredentials. Only credentials from credentials plugin are available.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

rittneje@gmail.com (JIRA)

unread,
Jan 14, 2020, 8:24:16 AM1/14/20
to jenkinsc...@googlegroups.com
Jesse Rittner commented on Bug JENKINS-59971
 
Re: Unable to create folder credentials for plain-credentials-plugin

I was able to work around this bug using the configure option for string creds.

 

properties {
  folderCredentialsProperty {
    domainCredentials {
       domainCredentials {
        domain {
          name('')
          description('')
        }
      }
    }   
  }
}
configure { folder ->
     def configNode = folder / 'properties''com.cloudbees.hudson.plugins.folder.properties.FolderCredentialsProvider_-FolderCredentialsProperty''domainCredentialsMap' / 'entry' / 'java.util.concurrent.CopyOnWriteArrayList'
   configNode << 'org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl'(plugin: 'plain-credentials@1.5') {
     id('secret-id')
     description('secret desc')
     secret(hudson.util.Secret.fromString('secret').getEncryptedValue())
   }
}

Unfortunately, I still cannot get file creds to work properly. It requires using com.cloudbees.plugins.credentials.SecretBytes, but attempting to do so gives all sorts of bizarre errors, like unable to resolve class com.cloudbees.plugins.credentials.SecretBytes or No such property: cloudbees for class: java.lang.String.

 

jswager@alohaoi.com (JIRA)

unread,
Jan 16, 2020, 2:30:03 PM1/16/20
to jenkinsc...@googlegroups.com

Jesse Rittner - perhaps this will help. Your original example helped me get much further; I couldn't have figured out the secret file stuff without your example.

properties {
  folderCredentialsProperty {
    domainCredentials {
       domainCredentials {
        domain {
          name('')
          description('')
        }
      }
    }   
  }
}
configure { folder ->
     def configNode = folder / 'properties''com.cloudbees.hudson.plugins.folder.properties.FolderCredentialsProvider_-FolderCredentialsProperty''domainCredentialsMap' / 'entry' / 'java.util.concurrent.CopyOnWriteArrayList'
  configNode << 'org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl' {
    id('secret-file-id')
    description('secret file desc')
    fileName('test.txt')
    secretBytes(com.cloudbees.plugins.credentials.SecretBytes.fromBytes('''This is a multiline file
Line two
finaly line'''.getBytes()).toString())
  }
}

This example won't work with a binary file.  If that was necessary, you could generate a BASE64 encode of the binary file, put that in place of the string and do a decodeBase64() on it to get the bytes.

jswager@alohaoi.com (JIRA)

unread,
Jan 16, 2020, 2:31:05 PM1/16/20
to jenkinsc...@googlegroups.com
Jason Swager edited a comment on Bug JENKINS-59971
[~rittneje] - perhaps this will help. Your original example helped me get much further; I couldn't have figured out the secret file stuff without your example.
{code:java}

properties {
  folderCredentialsProperty {
    domainCredentials {
       domainCredentials {
        domain {
          name('')
          description('')
        }
      }
    }  
  }
}
configure { folder ->
     def configNode = folder / 'properties' /  'com.cloudbees.hudson.plugins.folder.properties.FolderCredentialsProvider_-FolderCredentialsProperty' /  'domainCredentialsMap' / 'entry' / 'java.util.concurrent.CopyOnWriteArrayList'
  configNode << 'org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl' {
    id('secret-file-id')
    description('secret file desc')
    fileName('test.txt')
    secretBytes(com.cloudbees.plugins.credentials.SecretBytes.fromBytes('''This is a multiline file
Line two
finaly final line'''.getBytes()).toString())
  }
}
{code}

This example won't work with a binary file.  If that was necessary, you could generate a BASE64 encode of the binary file, put that in place of the string and do a decodeBase64() on it to get the bytes.

rittneje@gmail.com (JIRA)

unread,
Jan 16, 2020, 7:05:02 PM1/16/20
to jenkinsc...@googlegroups.com

Thanks, but unfortunately that still gives those weird error messages I posted.

Also, just FYI you should also set scope('GLOBAL') for your credentials. Otherwise, your config might be corrupted.

 

krystian@krystianmarek.com (JIRA)

unread,
Mar 24, 2020, 9:17:03 AM3/24/20
to jenkinsc...@googlegroups.com

Hello,
Daniel Spilker what makes plain-credentials-plugin incompatible with job-dsl-plugin ?
What would be needed to provide a fix for this ?

This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

riccardo.boettcher@tngtech.com (JIRA)

unread,
Apr 17, 2020, 9:00:03 AM4/17/20
to jenkinsc...@googlegroups.com

Hi Daniel Spilker,

I have tried to find a solution for the issue. Please have a look here https://github.com/RiccardoBoettcher/plain-credentials-plugin/tree/JENKINS-59971

As I'm not experienced with the Jenkins plugin development yet, I don't know what is the best strategy to introduce a breaking change. May be some can assist me with that?

riccardo.boettcher@tngtech.com (JIRA)

unread,
Apr 17, 2020, 9:03:05 AM4/17/20
to jenkinsc...@googlegroups.com
Riccardo Boettcher edited a comment on Bug JENKINS-59971
Hi Daniel Spilker,

I have tried to find a solution for the issue. Please have a look here [https://github.com/RiccardoBoettcher/plain-credentials-plugin/tree/JENKINS-59971]

As I'm not experienced with the Jenkins plugin development yet, I don't know what is the best strategy to introduce a breaking change. May be some can assist me with that?


 

As visible in the screenshot, the change makes the basicStringCredential available in the JobDSL API browser.

!image-2020-04-17-15-02-22-034.png!

riccardo.boettcher@tngtech.com (JIRA)

unread,
Apr 17, 2020, 9:05:03 AM4/17/20
to jenkinsc...@googlegroups.com
Riccardo Boettcher edited a comment on Bug JENKINS-59971
Hi Daniel Spilker,

I have tried to find a solution for the issue. Please have a look here [https://github.com/RiccardoBoettcher/plain-credentials-plugin/tree/JENKINS-59971]

As I'm not experienced with the Jenkins plugin development yet, I don't know what is the best strategy to introduce a breaking change. May be some someone can assist me with that?

 

As visible in the screenshot, the change makes
the a basicStringCredential (a functional equivalent implementation of the existing StringCredentialImpl) available in the JobDSL API browser.

!image-2020-04-17-15-02-22-034.png!

riccardo.boettcher@tngtech.com (JIRA)

unread,
Apr 17, 2020, 9:10:02 AM4/17/20
to jenkinsc...@googlegroups.com
Riccardo Boettcher edited a comment on Bug JENKINS-59971
Hi Daniel Spilker,

I have tried to find a solution for the issue. Please have a look here [https://github.com/RiccardoBoettcher/plain-credentials-plugin/tree/JENKINS-59971]

As I'm not experienced with the Jenkins plugin development yet, I don't know what is the best strategy to introduce a breaking change. May be someone can assist me with that?

 

As visible in the screenshot, the change makes a basicStringCredential (a functional equivalent implementation of the existing StringCredentialImpl) available in the JobDSL API browser.

!image-2020-04-17-15-02-22-034.png!


But, this draft has still some missing parts:
* when creating new credentials via the WebUI it can not be distinguished from the existing implementation for "secret text"
* when selecting it as the type of a new credentials no properties are shown
Reply all
Reply to author
Forward
0 new messages