Hi there,
I'm trying to build a dynamic parameter that fetches an AMI ID based on tags from our AWS account but I'm having some trouble adding a custom classpath. The classpath I'm trying to add is:
/opt/aws-sdk/*
The directory above contains a numer of jar files, most of which are dependencies for the AWS SDK. This is being executed on the Jenkins master.
My test dynamic parameter script looks like this:
import com.amazonaws.auth.EnvironmentVariableCredentialsProvider
import com.amazonaws.services.ec2.model.*
import com.amazonaws.services.ec2.
sleep(30000)
return "hello world."
By commenting out the import statements, the sleep statement is executed and "hello world" appears in the build parameter text box. With the imports left uncommented, the sleep statement is not executed and the build parameter text box appears empty. This is how I'm able to tell the imports are failing. I'm not seeing any logs from the plugin appearing in Jenkins.
The script that I need executed by the plugin is:
import com.amazonaws.auth.EnvironmentVariableCredentialsProvider
import com.amazonaws.services.ec2.model.*
import com.amazonaws.services.ec2.*
// Create EC2 Client Object.
def ec2 = new AmazonEC2Client(new EnvironmentVariableCredentialsProvider())
// Fetch AMI ID.
try {
ami = ec2.describeImages(new DescribeImagesRequest().withFilters(new Filter("tag:TAGNAME",["TAGVALUE"]))).getImages()
println ami[0].imageId
} catch (e) {
println "Something went wrong."
println e
}
I'm able to successfully execute this script locally by running:
groovy -cp $CLASSPATH:/opt/jars/* -d ami_lookup.groovy
What am I doing wrong?
What is the exact format I should be using for the classpath input?
Where exactly should the logs from this plugin appear?
Is there anywhere I can find/see the output of the groovyShell call?
https://github.com/Seitenbau/sb-jenkins-dynamicparameter/blob/master/src/main/java/com/seitenbau/jenkins/plugins/dynamicparameter/util/JenkinsUtils.java#L124
Any insight or help would be greatly appreciated. Thanks!