AWS Java SDK missingMethodException when setting credentials in pipeline environment

120 views
Skip to first unread message

Rowland Watkins

unread,
Mar 28, 2018, 12:03:26 AM3/28/18
to Jenkins Users
Hi folks,

Jenkins: 2.113
Groovy: 2.4.11
Amazon Web Services SDK plugin: 1.11.264
Java version: 1.8.0 161
OS: Ubuntu Xenial LTS

I'm encountering a curious runtime exception when running a pipeline script that previously worked when setting up EC2 and Route53 clients. The Amazon Web Services SDK has migrated over to the ClientBuilder fluent interfaces, but there appears to be an issue when invoking in the Groovy pipeline.

I've tried the following in a pipeline script and the Groovy script console:

import com.amazonaws.auth.AWSCredentials
import com.amazonaws.auth.AWSCredentialsProvider
import com.amazonaws.services.ec2.AmazonEC2ClientBuilder
import com.amazonaws.auth.profile.ProfileCredentialsProvider
import com.amazonaws.regions.Regions

def creds = new ProfileCredentialsProvider("default")

def ec2 = AmazonEC2ClientBuilder.standard().withCredentials(creds).build()

this yields the following runtime missingMethodException:

groovy.lang.MissingMethodException: No signature of method: com.amazonaws.services.ec2.AmazonEC2ClientBuilder.withCredentials() is applicable for argument types: (com.amazonaws.auth.profile.ProfileCredentialsProvider) values: [com.amazonaws.auth.profile.ProfileCredentialsProvider@2f758ab3]
Possible solutions: withCredentials(com.amazonaws.auth.AWSCredentialsProvider), getCredentials(), setCredentials(com.amazonaws.auth.AWSCredentialsProvider)

Groovy complains that withCredentials only takes AWSCredentialsProvider as an parameter even though ProfileCredentialsProvider implements the interface:


Now, I've tried the above code in the groovysh AWS Java SDK 1.11.264 in isolation on Groovy 2.4.11 on Java 1.8.0 161 with no issues. I'm wondering if there are any tips on how I might resolve this? In the meantime, I'll try replacing the plugin jar with earlier version of the SDK, or use https://jenkins.io/doc/book/pipeline/shared-libraries/#using-third-party-libraries.

Many thanks in advance!

Cheers,

Rowland

Alan Sparks

unread,
Jun 26, 2018, 4:19:41 PM6/26/18
to Jenkins Users
Were you able to get this to work, or find a better workaround than downgrading?   I see a similar issue to this just trying to get a Groovy script working (intended to use with Active Choice plugin).
-Alan

Alan Sparks

unread,
Jun 27, 2018, 7:19:16 PM6/27/18
to Jenkins Users
I suddenly realized, while trying to debug the script, that the AWS SDK version did not match the version I expected from the install of the aws-java-sdk version.    Digging through installed plugins, I found that my installed up-to-date aws-codebuild plugin embeds a few JARs for itself, with an older version.   Going to try to uninstall that plugin and test.   Wondering if that plugin really needs to have its own copy of the SDK, assuming that the other plugin is already installed...
Reply all
Reply to author
Forward
0 new messages