Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing property accessors #239

Closed
wants to merge 1 commit into from

Conversation

jeromepochat
Copy link

When generating pipeline script for withCredentials with AWS credentials binding, the result script is not correct (fields are not set):

withCredentials([<object of type com.cloudbees.jenkins.plugins.awscredentials.AmazonWebServicesCredentialsBinding>]) {
    // some block
}

Instead, it should generate something like:

withCredentials([[
    $class: 'AmazonWebServicesCredentialsBinding',
    credentialsId: '1de24f4f-2f81-433a-a900-b7fc4196f81f',
    accessKeyVariable: 'AWS_ACCESS_KEY_ID',
    secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
]])

Steps to reproduce:

  1. Start a Jenkins instance with AWS Credentials plugin installed
  2. Create AWS Credentials (no need for real one)
  3. Create pipeline and use the script syntax page to create withCredentials step using AWS credentials binding
  4. Check the generated script snippet

The following exception is logged:

2024-03-20 16:29:53.774+0000 [id=56]    WARNING o.j.p.s.d.DescribableParameter#uncoerce: failed to uncoerce com.cloudbees.jenkins.plugins.awscredentials.AmazonWebServicesCredentialsBinding@2db4c9ee
java.lang.UnsupportedOperationException: no public field ‘roleArn’ (or getter method) found in class com.cloudbees.jenkins.plugins.awscredentials.AmazonWebServicesCredentialsBinding
        at org.jenkinsci.plugins.structs.describable.DescribableParameter.getValue(DescribableParameter.java:161)
        at org.jenkinsci.plugins.structs.describable.DescribableParameter.inspect(DescribableParameter.java:142)
        at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate2(DescribableModel.java:656)
        at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate2_(DescribableModel.java:754)
        at org.jenkinsci.plugins.structs.describable.DescribableParameter.uncoerce(DescribableParameter.java:196)
        at org.jenkinsci.plugins.structs.describable.DescribableParameter.uncoerce(DescribableParameter.java:190)
        at org.jenkinsci.plugins.structs.describable.DescribableParameter.inspect(DescribableParameter.java:142)
        at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate2(DescribableModel.java:656)
        at org.jenkinsci.plugins.structs.describable.DescribableModel.uninstantiate2_(DescribableModel.java:754)
        at org.jenkinsci.plugins.workflow.steps.StepDescriptor.uninstantiate(StepDescriptor.java:251)
        at org.jenkinsci.plugins.workflow.cps.Snippetizer.object2Groovy(Snippetizer.java:152)
        at org.jenkinsci.plugins.workflow.cps.Snippetizer.step2Groovy(Snippetizer.java:81)
        at org.jenkinsci.plugins.workflow.cps.Snippetizer.doGenerateSnippet(Snippetizer.java:522)

This adds the missing public access method to properties.

@jeromepochat
Copy link
Author

Closed as duplicates #238

@jeromepochat jeromepochat deleted the BEE-47313 branch March 20, 2024 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant