'How to set AWS credentials as Environmental variable in Jenkins

I have added my AWS Access Key and AWS Secret Key in Jenkins using the AWS Credentials plugin.

AWS credentials plug-in 1

After that I added a new AWS Credentials param called AWSCRED in my project. Now I want to use the AWS Access Key and AWS Secret Key in the bash script I am running for my deployment. But it seems the $AWSCRED variable contains only the ID of the (I tried echo $AWSCRED in my bash) credential. How can I get access to or use the Access Key ID and Secret Access Key

AWS credentials param



Solution 1:[1]

suppose you can try $AWSCRED_USR $AWSCRED_PSW If this doesn't work then you can use "secret text" for aws_access_key_id and aws_secret_access_key credentials and use it in pipeline

pipeline {
    agent {
        // Define agent details here
    }
    environment {
        AWS_ACCESS_KEY_ID     = credentials('aws_access_key_id')
        AWS_SECRET_ACCESS_KEY = credentials('aws_secret_access_key')
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dmitriy Tarasevich