AWS s3 for storing Jenkins artifacts

Milind Yadav
2 min readNov 7, 2023

--

Integrating Jenkins with AWS S3 for artifact storage can streamline your CI/CD pipeline by securely storing build artifacts. Here’s a general process on how to use Jenkins with AWS S3 for artifact storage:

1. AWS Credentials: Store your AWS credentials securely in Jenkins. You can use the Jenkins credential store to save your AWS access key ID and secret access key.
Best to refer — https://www.howtoforge.com/how-to-store-aws-user-access-key-and-secret-key-in-jenkins/

2. Install Plugins: Install the necessary Jenkins plugins, such as the AWS Steps Plugin or S3 Publisher Plugin. These plugins enable Jenkins to interact with AWS services, including S3.
More Insights about specific plugins — https://plugins.jenkins.io/pipeline-aws/

3. Configure S3 Bucket: Create an S3 bucket in AWS where your artifacts will be stored. Ensure it’s properly configured for access and security (e.g., setting up IAM policies).
Detailed does and don’ts — https://docs.aws.amazon.com/AmazonS3/latest/userguide/creating-bucket.html

4. Configure Jenkins Job:
— Add a post-build action in your Jenkins job configuration.
— Choose the option to publish artifacts to S3.
— Specify the details of your S3 bucket and the files you want to upload as artifacts.

5. Uploading Artifacts: After a successful build, Jenkins will use the plugin to upload the specified artifacts to your S3 bucket.

6. Manage Artifacts: Use lifecycle policies in S3 to manage old artifacts, like setting expiration policies to delete old builds automatically.
to refer — https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html

7. Security Considerations: Make sure to set up appropriate IAM roles and policies to control access to the S3 artifacts. You should adhere to the principle of least privilege.

8. Accessing Artifacts: Configure access permissions if you want your team to access the artifacts from S3. You could set up presigned URLs for secure, temporary access.
More about presigned URLs — https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html

9. Automation: You can further automate the process using Jenkins pipelines (Jenkinsfile) and including steps to upload to S3 as part of the pipeline script.

10. Monitoring: Set up monitoring and alerts for your S3 to keep track of your storage usage and to get notified of any unauthorized access attempts.

Remember to regularly review AWS and Jenkins documentation for updates on plugins and best practices for security and cost management.

--

--