I am trying to get environment variables from AWS Parameter Store for Jenkins CI/CD pipeline. I have assigned IAM role to this instance, so no credentials are required to be passed. This is my parameter
{
"Parameters": [
{
"Name": "Test",
"Type": "String",
"Value": "Hello World",
"Version": 1,
"LastModifiedDate": 1639400445.755,
"ARN": "arn:aws:ssm:########:#########:parameter/Test",
"DataType": "text"
}
],
"InvalidParameters": []
}
I have installed AWS Parameter Store Build Wrapper plug-in and using withAWSParameterStore method to capture the value.
This is how I am trying
val = withAWSParameterStore(namePrefixes: "Test", regionName: '#######'){}
echo val
Variable var returns null.
How do I capture the value "Hello World" here.
IAM role assigned to EC2 instance where Jenkins is running doesn't help. We still need to create a credential in Jenkins with IAM Access and Secret key. In order to capture the data, you may follow something like the below:
withAWSParameterStore(credentialsId: 'myjenkins-id',
namePrefixes: 'Test',
regionName: '########') {
echo "${env.Test}"
echo "${env.TEST}"
echo TEST} ```