Jenkins Upload to S3 From Pipeline Script

Using Jenkins for File Upload to AWS S3: Step-by-Pace Guide

Photo by Engin Akyurt on Unsplash

Hello readers, nosotros'll be performing some nice operations together but for us to do that, there are some things that I'll love you to have/set in place of which are:

  • An AWS business relationship with root privileges.
  • Root privilege permissions for a concluding tool.

If you're ready, let's get started. In this article, you'll learn how to:

  • Create an IAM user from a user group with a customer managed policy.
  • Add IAM user credentials to Jenkins.
  • Build a Jenkins Pipeline using Source Control Manager (SCM) technique with declarative syntax.

AWS

We'll start by logging in to AWS Management console equally a root user and search for the IAM Service.

On the left manus navigation pane, select Policies. A policy is set of permissions for various services connected together as a single entity. To create a policy, click Create Policy, for the service, search and select S3. For the deportment and for simplicity purpose, cheque the All S3 actions (s3:*) and for resource, select All resources.

For the purpose of this article, Jenkins will be installed locally. If you desire to harness AWS EC2 you can use the same technique in a higher place to configure permission for EC2 service. Jenkins uses port 8080 and so, do well to configure your security group to allow TCP connection on port 8080.

It'south a good do to tag resources for piece of cake identification and hence, adding a key-value pair tag to the policy would exist prissy.

Later on selecting the service for the policy, click Review and name the policy with its description. Click Create Policy to create your client managed policy.

As an organisation, there are times new people would be joining the team equally well as others leaving. To avoid the repeated tasks of setting upwards user permissions, user groups are used. On the left navigation pane, select User groups. Click Create group and enter a User grouping proper noun. In the attach permissions policy, select the policy created in the previous step and click Create group.

Let'southward create a user having the same permissions of the group. On the left hand navigation plane, select Users. Click Add users and enter a User proper noun for the user. Give Programmatic and AWS Direction Panel Access to the user. Add together the user to the grouping created in the previous step and after review, Create user.

The Access ID, Secret access central and password are very important and announced in one case. It will be necessary to copy them and continue in a prophylactic place. Follow the AWS link to login to the created IAM user account.

On the IAM user management panel, navigate to S3 service and create bucket attainable to the public.

Jenkins

Install Jenkins on your local machine by following the installation from hither.

I am using Ubuntu terminal and to start Jenkins, run systemctl start jenkins

To confirm Jenkins started, its status is checked using: systemctl condition jenkins

Let's access the Jenkins platform. On your browser, open the Jenkins classic UI with localhost:8080 (if you're using an EC2 instance, public_ip:8080 ). Follow the instructions to set upward a user and password for the Jenkins console. After the user has been created, login to Jenkins using the created credentials.

Jenkins allows for the usage of plugins for some of its functionality and we will be using the Pipeline AWS Steps and S3 Publisher plugins. Click Manage Jenkins > Manage Plugins > Available Tab. Search and install Pipeline: AWS Steps and S3 publisher plugins. Subsequently the plugin installation, restart Jenkins.

Credentials serve as keys in which a guest (Jenkins) can have admission to a detail host (AWS). To add the IAM user credential to Jenkins, click Manage Jenkins > Manage Credentials > Click Jenkins store > Global credentials. From the left pane, click Add Credentials. Specify the post-obit in their respective fields:

          Kind: AWS Credentials          Telescopic: Global (Jenkins, nodes, items, …, etc)          ID: # Specify an ID of your option          Clarification: #Specify its description          Access ID: #IAM user Access ID          Undercover Access Key: #IAM user Secret Admission ID        

The repository containing the Jenkinsfile can be institute here. Fork, clone and modify the contents to suite your credentials and resource specifications.

Practice not exist tempted to apply mine, it won't piece of work 😄 unless plain, you created your resources with exactly what I used.

Let'due south fix our outset Jenkins project. From the left pane, select New Item. Enter a new item name and select Pipeline as the item blazon.

Since we volition be using a Jenkinsfile that was committed to a repository, we'll apply the Source Control Manager equally the source of our pipeline script. Click Pipeline tab and change the Definition to Pipeline script from SCM. Specify the following in their respective fields:

          SCM: Git          Repository URL: https://github.com/Wach-Due east/jenkins-aws-upload          Branch Specifier: */chief          Script Path: Jenkinsfile        

Click Utilize and Save.

From the left pane, click Build Now. After the build of each stage, the time spent per stage is displayed on the projection dashboard. Bank check the content of the S3 bucket to confirm the file upload was successful.

From the left pane, whorl down to Build History, select the build number and select Console Output to see the stride wise build output.

Congratulations! You lot take successfully implemented AWS best do in creating an IAM user and created a Jenkins Pipeline for file upload to an S3 bucket. 👏

Jenkins is a very powerful CI/CD tool and can be used to perform various operations with different techniques that suites the production pattern. Yous can take this learning further by configuring Build Triggers 💥 for this project.

If y'all constitute this article helpful, exit some claps 👏 and share to assistance others see information technology 🙂

More than content at plainenglish.io

edwardsfoustion.blogspot.com

Source: https://aws.plainenglish.io/step-by-step-approach-using-jenkins-for-file-upload-to-aws-s3-c2f395d01b7d

0 Response to "Jenkins Upload to S3 From Pipeline Script"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel