[x] Jenkins version: 2.150.3
[x] Plugin version: Credentials Plugin - 2.2.0 and Role-based Authorization Strategy - 2.12
[x] OS: Linux
Description:
I'm trying to download configuration of JCasC via JCasC UI but the file that I was able to extract throws the below error:
credentials:
system:
domainCredentials:
- credentials: |-
FAILED TO EXPORT
com.cloudbees.plugins.credentials.domains.DomainCredentials#credentials: java.lang.NullPointerException
at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.describe(DataBoundConfigurator.java:250)
at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.lambda$convertToNode$de0cd4f8$1(HeteroDescribableConfigurator.java:283)
at io.vavr.CheckedFunction0.lambda$unchecked$52349c75$1(CheckedFunction0.java:201)
at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.convertToNode(HeteroDescribableConfigurator.java:283)
at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.lambda$describe$5(HeteroDescribableConfigurator.java:107)
at io.vavr.control.Option.map(Option.java:373)
at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.describe(HeteroDescribableConfigurator.java:107)
at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.describe(HeteroDescribableConfigurator.java:55)
at io.jenkins.plugins.casc.Attribute.describe(Attribute.java:198)
at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.describe(DataBoundConfigurator.java:274)
at io.jenkins.plugins.casc.Attribute.describe(Attribute.java:198)
at com.cloudbees.plugins.credentials.casc.SystemCredentialsProviderConfigurator.describe(SystemCredentialsProviderConfigurator.java:76)
at com.cloudbees.plugins.credentials.casc.SystemCredentialsProviderConfigurator.describe(SystemCredentialsProviderConfigurator.java:48)
at io.jenkins.plugins.casc.Attribute.describe(Attribute.java:202)
at com.cloudbees.plugins.credentials.casc.CredentialsRootConfigurator.describe(CredentialsRootConfigurator.java:90)
at com.cloudbees.plugins.credentials.casc.CredentialsRootConfigurator.describe(CredentialsRootConfigurator.java:52)
I tried updating Credentials and Role Strategy Plugin as documented on JCasC release v1.18 but it still throws the above error. Can't find anything on google so here I am. Thank you for your help.
What version of the configuration-as-code-plugin are you using?
jcasc version: 1.23
By any chance do you have a credential certificate added?
you can run this in the script console to credential types your using:
def credentials_store = jenkins.model.Jenkins.instance.getExtensionList('com.cloudbees.plugins.credentials.SystemCredentialsProvider')
println "credentials:"
credentials_store[0].credentials.each { it ->
println "${it}"
}
Hi @casz I tried running your code on the script console and below is the result:
credentials:
com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl@6bf5e517
com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl@6b54f95a
com.cloudbees.jenkins.plugins.awscredentials.AWSCredentialsImpl@416cbb07
com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey@bd5d6203
Result: [com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl@6bf5e517, com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl@6b54f95a, com.cloudbees.jenkins.plugins.awscredentials.AWSCredentialsImpl@416cbb07, com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey@bd5d6203]
Thanks
What happens if you remove AWSCredentials? Just take a backup before removing it :)
@casz you mean Cloudbees AWS Credentials plugin?
I guess that's what they are calling it 馃憠 https://github.com/jenkinsci/aws-credentials-plugin/blob/master/pom.xml#L40 馃槅
@casz I can't uninstall Cloudbess AWS Credentials plugin as there are a lot of dependencies on it on our jenkins setup.
As a test, to see whos causing trouble I was suggesting you take a copy of your jenkins. Spin it up and delete the AWS credential in the credential store. To see if it is the blocker.
@casz I've deleted all AWS credentials account in our jenkins and tried executing the script you have provided above. I got the below result.
credentials:
com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl@6bf5e517
com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl@6b54f95a
com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey@bd5d6203
Result: [com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl@6bf5e517, com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl@6b54f95a, com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey@bd5d6203]
I'm sorry I'm new with jenkins configurations. Thank you for bearing with me.
@bianxseyer @casz FWIW +1 here and is there another way for us to have Jenkins created with Role-Based Authorization selected?
Role-Based Authorization has nothing to do with credentials?
role-strategy plugin should be fully supported.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
When ever I add credentials, kind: Secret file, JCasc will always gives this error
FAILED TO EXPORT
com.cloudbees.plugins.credentials.domains.DomainCredentials#credentials: java.lang.NullPointerException
How can I fix this?
This requires a fix in the plain credentials and/or credentials plugin.
My suggestion is to save the file as base64 and convert to a file when needed.
You can use a shared pipeline step for this.
So, without fixing the credentials plugin, I can workaround by encoding the file with base64 and store it as kind: Secret text, and convert it back when I want to use them right?
Ya @phootip :)
Thank you 馃檹
It's not perfect but the problem is somewhat tricky and really the fix should be carried out in stapler but 馃槺
@phootip your issue of NullPointerException exception should be fixed.
So should your issue @bianxseyer
both was fixed in v2.3.3 of credential plugin and v1.36 of configuration-as-code-plugin.
Most helpful comment
This requires a fix in the plain credentials and/or credentials plugin.
My suggestion is to save the file as base64 and convert to a file when needed.
You can use a shared pipeline step for this.