How to Upload data Using Jenkins Plugin to AWS S3 Bucket
Using S3 Publisher Plugin: Upload data to S3 Bucket
Step 1:
Go to Jenkins Master >> click on Manage Jenkins
Step 2:
Click on Manage Plugin
Step 3:
Search S3 Publisher in the Available Plugin section and install it
Step 4:
Go Back to Manage Jenkins and click on Configure System
Step 5:
Scroll Down till Amazon S3 profiles
Here you have two ways to do it
IAM Role
Step1: Go AWS console >> Go to IAM Roles >> Click on Create Role
Step2: select AWS service and in the use case select ec2 then click on next
Step3: Search and select AamzonS3FullAccess and click on Next
Step4: Give the name of the role and click on Create Role
Role is created
Now Adding a role to the ec2 instances/Slave or Master Node depending on your configuration.
Step 5: Select the instance >> click on Action >> Security >> Modify IAM role.
Step 6: Select the IAM Role and update it.
Step 7: Make sure in Your Jenkins Master >> Configuration Systems >> Amazon S3 Profiles have checked on Use IAM Role Click on Apply and Save
AWS API Key credentials
Step 1: Go to the Top-Right corner and click on your name >> Click on Security Credentials
Step2: Scroll down till Access Keys >> Create Access Key
Step 3 Mentioned All details of the Access key in Your Jenkins Master >> Configuration Systems >> Scroll down Amazon S3 Profiles
Click on Apply and Save
Step 6: Got Jenkins Master >> Click on New Item
Step 7: Enter an item name and select Freestyle project >> click on Ok
Step 8: Give the description and mention your custom workspace [optional]
Step 9: Mention your Git Repository Link and Credential if needed. Also, mention the branch.
Step 10: You can setup build environments like I prefer to Delete workspace before the build starts [optional]
Step 11:
You can mention shell script or other operations on the repository
Step 12:
Click on Add post-build action >> Click on Publish artifacts to S3 Bucket
Step 13:
Select S3 profile >> click on files upload mention source or destination (bucket name and path) select storage class and region of the bucket.
Click on Apply & Save
Note: Jenkins s3 Publisher plugin does not create the bucket. You have to create the bucket and provide access permission accordingly.
Step 14:
Now Click on Build Now
Yess Done!!!
Let's check the S3 Bucket
We successfully uploaded all .html files to the S3 bucket.
Error Code Orange:
ERROR: Failed to upload files java.io.IOException: Expecting Ant GLOB pattern, but saw '/*.html'. See ant.apache.org/manual/Types/fileset.html for syntax
If you get a similar error it means you didn't give the proper path of the source in publish artifacts in S3 Bucket.