Since I upgrade from 3.30.1 to 3.31.1, I've an issue with a custom groovy script that uses the following classes:
to generate AWS credentials for a docker proxy to an ECR registry.
- aws-java-sdk-core-1.11.1034.jar
- aws-java-sdk-ecr-1.11.1034.jar
- ini4j-0.5.4.jar
to the /opt/sonatype/nexus/deploy folder and the script run and set the username/password for the applicable docker proxy repository.
This is part of the code:
AWSCredentials awsCredentials = new BasicAWSCredentials(
prefs.get('access_key_id', ''), prefs.get('secret_access_key', ''))
AmazonECR amazonECR = AmazonECRClientBuilder
.standard()
.withRegion(prefs.get('region', 'eu-west-1'))
.withCredentials(new AWSStaticCredentialsProvider(awsCredentials))
.build()
However, with version 3.31.1, running the script fails with the following log messages:
021-07-05 08:33:17,910+0200 ERROR [quartz-11-thread-20] *SYSTEM java.lang.Throwable - groovy.lang.MissingMethodException: No signature of method: com.amazonaws.services.ecr.AmazonECRClientBuilder.withCredentials() is applicable for argument types: (com.amazonaws.auth.AWSStaticCredentialsProvider) values: [com.amazonaws.auth.AWSStaticCredentialsProvider@45eb0adf]
Possible solutions: withCredentials(com.amazonaws.auth.AWSCredentialsProvider), getCredentials(), setCredentials(com.amazonaws.auth.AWSCredentialsProvider)
I've been trying to cast the static credentials provider to the class named, but nothing works. Then I removed the deployed jars from nexus and restarted, and I found out that there are already some aws libraries installed as it didn't complain during the import about the mentioned classes, but it did complain about other classes not found.
Apparently they are not the same version.
What is the best way to overwrite the libraries for this script only, or can you suggest another solution?
Kind regards,
Mariska