Continuous Deployment : Using AWS Code Commit, AWS Code Deploy and Jenkins (Part 2)

Jenkins Server

Jenkins is an open source automation server. With Jenkins, organizations can accelerate the software development process through automation. Jenkins manages and controls development lifecycle processes of all kinds, including build, document, test, package, stage, deployment, static analysis and many more.
You can set up Jenkins to watch for any code changes in places like SVN and Git, automatically do a build with tools like Ant and Maven, initiate tests and then take actions like rolling back or rolling forward in production.

Set Up the Jenkins Server

Create an instance using the Amazon Linux AMI. Make sure you associate the instance with the CodeCommitRole role (Created in previous step) and configure the security group associated with the instance to allow incoming traffic on ports 22 (SSH) and 8080 (Jenkins). You may further secure your server by restricting access to only the IP addresses of local development environment connecting to Jenkins
Use SSH to connect to the instance. Update the AWS CLI and install Jenkins, Git, and the Java JDK.
sudo yum install -y git java-1.8.0-openjdk-devel
sudo yum update -y aws-cli
Add the Jenkins repository and install Jenkins.
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
sudo yum install -y jenkins
Configure the AWS CLI on Jenkins Server
cd ~jenkins
sudo -u jenkins aws configure
Accept the defaults for the AWS access key and AWS secret access key; enter us-east-1 for the region name; and enter json for the output format. 
AWS Access Key ID [None]: Press Enter
AWS Secret Access Key [None]: Press Enter
Default region name [None]: Type us-east-1 here, and then press Enter
Default output format [None]: Type json here, and then press Enter
Configure Git to use IAM credentials and an HTTP path to access the repositories hosted by AWS CodeCommit.
sudo -u jenkins git config --global credential.helper '!aws codecommit credential-helper $@'
sudo -u jenkins git config --global credential.useHttpPath true
sudo -u jenkins git config --global user.email "name@mycompany.com"
sudo -u jenkins git config --global user.name "MyJenkinsServer"

Start Jenkins. 
sudo service jenkins start
sudo chkconfig jenkins on
Configure Jenkins
Once the installation is done open the Jenkins home page (http://<public DNS name of EC2 instance>:8080) in your browser. Well, the Jenkins is not secure now. To secure you can go to
Manage Jenkins -> Configure Global Security -> tick Enable Security Under Security Realm -> tick Jenkin’s own user database  & Under Authorization -> tick Logged-in users can do anything.
jenkins-configure-security2
This will take you to the signup page.
Since we are using GIT (AWS CodeCommit) as version control tool and AWS Code Deploy as Deployment tool, we need to install these plugins in Jenkins Manage Plugins option.
To install the plugin
Go to Jenkins Manage Jenkins -> Manage Plugins
In the Available tab search and select Git Plugin and AWS CodeDeploy plugin. After selecting click Download and Install after restart.
This will download and install both the plugins and restart Jenkins .
image2
After Jenkins has restarted, add a project that will execute a build each time a change is pushed to the AWS CodeCommit hosted repository. Before we need to configure AWS CodeDeploy 

Comments

Popular posts from this blog

Datastax Error : Cannot start node if snitch's data center (dc1) differs from previous data center (dc2)

Datastax Error : Cassandra - Saved cluster name Test Cluster != configured name

Configure Nagios plugin " check_logfiles " for scanning log file

Popular posts from this blog

Datastax Error : Cannot start node if snitch's data center (dc1) differs from previous data center (dc2)

Datastax Error : Cassandra - Saved cluster name Test Cluster != configured name

Configure Nagios plugin " check_logfiles " for scanning log file