CI - CD With Dockers and Jenkins. CI - Continuous Integration - Involves - by Kubernetes Advocate - FAUN - Medium
CI - CD With Dockers and Jenkins. CI - Continuous Integration - Involves - by Kubernetes Advocate - FAUN - Medium
This gives you immediate feedback that the code builds and may doubtless be deployed.
CI/CD
. . .
Cloud Environments
The deployment environments for a cloud application can be summarized as follows:
Staging
Production
. . .
Follow the directions here to put in lowlife (if it’s not already installed).
Note that for this tutorial we’ll be victimization lowlife on the instruction solely.
While there are some nice lowlife GUIs (graphical user interfaces), I believe it’s easier to
nd out lowlife victimization lowlife-speci c commands 1st and so to undertake out a git
GUI
Once you’ve done that, produce a GitHub account here. (Accounts are free for public
repositories, but there’s a charge for private repositories.)
https://medium.com/faun/ci-cd-with-dockers-and-jenkins-70b6f801f9f7 2/20
9/21/2020 CI/CD with Dockers and Jenkins. CI — Continuous Integration: involves… | by Kubernetes Advocate | FAUN | Medium
If you don’t have abundant expertise with the terminal and basic commands, scrutinize
this tutorial (especially the ‘Navigating the Filesystem’ and ‘Moving Around’ sections).
To begin, open up a terminal and move to wherever you wish to put the project on your
native machine victimization the cd (change directory) command. For example, if you
have a ‘projects’ folder on your desktop, you’d do something like:
vineet@vineet-ndi-lap-688:~$ cd Desktop/Projects/maven-project/
vineet@vineet-ndi-lap-688:~/Desktop/Projects/maven-project$ ls
Jenkinsfile pom.xml server webapp
To initialize a git repository in the root of the folder, run the git init command:
Once you’ve added additional or changed les during a folder containing a git repo, git
can notice that changes are created within the repo.
But, git won’t formally keep track of the le (that is, place it during a commit — we’ll
speak a lot of regarding commits next) unless you expressly tell it to.
vineet-ndi-lap-688:~/Desktop/Projects/maven-project$ touch
website.txt
vineet-ndi-lap-688:~/Desktop/Projects/maven-project$ ls
Jenkinsfile pom.xml server webapp website website.txt
After creating the new le, you can use the git status command to see which les git
knows to exist.
https://medium.com/faun/ci-cd-with-dockers-and-jenkins-70b6f801f9f7 3/20
9/21/2020 CI/CD with Dockers and Jenkins. CI — Continuous Integration: involves… | by Kubernetes Advocate | FAUN | Medium
vineet@vineet-ndi-lap-688:~/Desktop/Projects/maven-project$ git
status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
Jenkinsfile
website
website.txt
nothing added to commit but untracked files present (use "git add" to
track)
What this primarily says is, “Hey, we tend to notice you created a brand new le known
as mnelson.txt, however, unless you employ the ‘git add’ command we tend to are not
reaching to do something
A commit could be a record of what les you’ve got modi ed since the last time you
created a commit.
Essentially, you create changes to your repo (for example, adding a le or modifying
one) so tell GIT to place those les into a commit.
Commits structure the essence of your project and permit you to travel back to the state
of a project at any purpose.
So, however, does one tell GIT the les to place into a commit?
As seen in Step two, after you build changes to your repo, GIT notices that a le has
modi ed however won’t do something with it (like adding it in a very commit).
https://medium.com/faun/ci-cd-with-dockers-and-jenkins-70b6f801f9f7 4/20
9/21/2020 CI/CD with Dockers and Jenkins. CI — Continuous Integration: involves… | by Kubernetes Advocate | FAUN | Medium
To do this, you’ll be able to use the GIT add the command (see Step three below).
Once you’ve used the git add a command to feature all the les you wish to the staging
surroundings, you’ll be able to then tell GIT to package them into a commit
Note: The staging surroundings, additionally known as ‘staging’, is that the new most
popular term for this, however, you’ll be able to additionally see it spoken because of the
‘index’.
If you rerun the GIT status command, you’ll see that GIT has another the le to the
staging surroundings (notice the “Changes to be committed” line).
To repeat, the le has not nonetheless been another to a commit, however, it is close to
being.
https://medium.com/faun/ci-cd-with-dockers-and-jenkins-70b6f801f9f7 5/20
9/21/2020 CI/CD with Dockers and Jenkins. CI — Continuous Integration: involves… | by Kubernetes Advocate | FAUN | Medium
Run the command skunk commit -m “Jenkins File created” The message at the top of the
commit ought to be one thing associated with what the commit contains — perhaps it’s
a new feature, perhaps it’s a bug x, perhaps it’s simply xing a mistake. Don’t place a
message like “asdfadsf” or “foobar”.
Say you wish to create a brand new feature however square measure disquieted
concerning creating changes to the most project whereas developing the feature.
Branches allow you to move back and forth between the ‘states’ of a project.
For instance, if you wish to feature a brand new page to your web site you’ll be able to
produce a brand new branch only for that page while not touching the most a part of the
project.
Once you’re nished the page, you’ll be able to merge your changes from your branch
into the master branch. After running the above command, you can use the git branch
The branch name with the asterisk next to it indicates which branch you’re pointed to at
that given time.
Now, if you switch back to the master branch and make some more commits, This
command can mechanically produce a brand new branch so mechanically you out’ on
that, which means GIT can move you merge a branch, o of the master branch.
https://medium.com/faun/ci-cd-with-dockers-and-jenkins-70b6f801f9f7 6/20
9/21/2020 CI/CD with Dockers and Jenkins. CI — Continuous Integration: involves… | by Kubernetes Advocate | FAUN | Medium
But if you wish to gure with a team, you’ll be able to use GitHub to collaboratively
modify the project’s code.
To create a brand new repo on GitHub, log in and move to the GitHub home page.
You should see an inexperienced ‘ New repository’ button: when clicking the button,
GitHub can raise you to call your repo and supply a quick description:
Step 7 Let’s push the Git code to the repository (Maven -Project)
Step 8 we can see that code has been successfully pushed to Github Repository
https://medium.com/faun/ci-cd-with-dockers-and-jenkins-70b6f801f9f7 7/20
9/21/2020 CI/CD with Dockers and Jenkins. CI — Continuous Integration: involves… | by Kubernetes Advocate | FAUN | Medium
. . .
https://medium.com/faun/ci-cd-with-dockers-and-jenkins-70b6f801f9f7 8/20
9/21/2020 CI/CD with Dockers and Jenkins. CI — Continuous Integration: involves… | by Kubernetes Advocate | FAUN | Medium
sudo vi /etc/tomcat8/tomcat-users.xml
. . .
Jenkins Installation
Follow the below steps:
Step 2: Add the key and source list to apt for Jenkins.
$ wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key |
sudo apt-key add -
Step 3: Now create source list for Jenkins, using the below commands
https://medium.com/faun/ci-cd-with-dockers-and-jenkins-70b6f801f9f7 9/20
9/21/2020 CI/CD with Dockers and Jenkins. CI — Continuous Integration: involves… | by Kubernetes Advocate | FAUN | Medium
Step 7: Now copy the password and paste it into the browser.
When nished, you should see a screen similar to the below one.
https://medium.com/faun/ci-cd-with-dockers-and-jenkins-70b6f801f9f7 10/20
9/21/2020 CI/CD with Dockers and Jenkins. CI — Continuous Integration: involves… | by Kubernetes Advocate | FAUN | Medium
. . .
Step 2 Search Github Plugin in the Available tab then click on Download now and install
after the restart.
https://medium.com/faun/ci-cd-with-dockers-and-jenkins-70b6f801f9f7 11/20
9/21/2020 CI/CD with Dockers and Jenkins. CI — Continuous Integration: involves… | by Kubernetes Advocate | FAUN | Medium
Step 3 Install Maven Plugin. Go to Jenkins- Manage Jenkins- Global Tool Con guration,
Click OK
. . .
https://medium.com/faun/ci-cd-with-dockers-and-jenkins-70b6f801f9f7 12/20
9/21/2020 CI/CD with Dockers and Jenkins. CI — Continuous Integration: involves… | by Kubernetes Advocate | FAUN | Medium
How to integrate Jenkins with GitHub so automatically CI/ CD takes place when any
commit made by developers
Step2 Go to Github Repository- click on settings- Go to webhook and add new webhook
https://medium.com/faun/ci-cd-with-dockers-and-jenkins-70b6f801f9f7 13/20
9/21/2020 CI/CD with Dockers and Jenkins. CI — Continuous Integration: involves… | by Kubernetes Advocate | FAUN | Medium
. . .
Step 2 Select the GitHub project checkbox and set the Project URL to point to your
GitHub Repository.
https://medium.com/faun/ci-cd-with-dockers-and-jenkins-70b6f801f9f7 14/20
9/21/2020 CI/CD with Dockers and Jenkins. CI — Continuous Integration: involves… | by Kubernetes Advocate | FAUN | Medium
Step 3 Under Source Code Management tab, select Git, and then set the Repository URL
to point to your GitHub Repository.
Step 4 Now Under Build Triggers tab, select the “Build when a change is pushed to
GitHub” checkbox.
https://medium.com/faun/ci-cd-with-dockers-and-jenkins-70b6f801f9f7 15/20
9/21/2020 CI/CD with Dockers and Jenkins. CI — Continuous Integration: involves… | by Kubernetes Advocate | FAUN | Medium
Step 5 In the end, execute the Shell script to take a clone from dev. When the
con guration is done, click on the Save button.
Step 6 Click OK and Build a Job and you will see that a war le is created and as soon as
build is successfully triggered, same war le is copied by other projects (Other projects
to build)
https://medium.com/faun/ci-cd-with-dockers-and-jenkins-70b6f801f9f7 16/20
9/21/2020 CI/CD with Dockers and Jenkins. CI — Continuous Integration: involves… | by Kubernetes Advocate | FAUN | Medium
Step7 Create one more project for Deployment into tomcat server hosted on an EC2
machine (Deploy- to -Staging)
You will see that it is copying artifacts from a previous project (Package) and also
mentioning to copy the latest successful build of the previous project
Step 8 Now we will deploy the war le to tomcat 8 server hosted on EC2 machine with IP
172.31.90.150:8080(Port number of Tomcat 8)
https://medium.com/faun/ci-cd-with-dockers-and-jenkins-70b6f801f9f7 17/20
9/21/2020 CI/CD with Dockers and Jenkins. CI — Continuous Integration: involves… | by Kubernetes Advocate | FAUN | Medium
Step 9 As soon as we create a build of this Job we will see that the Java application is
deployed on Tomcat 8 hosted on an EC2 machine
ubuntu@ip-172–31–90–150:~$ cd /var/lib/tomcat8/webapps/production/
ubuntu@ip-172–31–90–150:/var/lib/tomcat8/webapps/production$ ls
index.JSP META-INF WEB-INF
Step 11 We can now copy URL and paste on a browser with /Production
https://medium.com/faun/ci-cd-with-dockers-and-jenkins-70b6f801f9f7 18/20
9/21/2020 CI/CD with Dockers and Jenkins. CI — Continuous Integration: involves… | by Kubernetes Advocate | FAUN | Medium
Thanks
Subscribe to FAUN topics and get your weekly curated email of the must-read tech
stories, news, and tutorials 🗞
If this post was helpful, please click the clap 👏 button below a few times to
show your support for the author! ⬇
https://medium.com/faun/ci-cd-with-dockers-and-jenkins-70b6f801f9f7 19/20
9/21/2020 CI/CD with Dockers and Jenkins. CI — Continuous Integration: involves… | by Kubernetes Advocate | FAUN | Medium
https://medium.com/faun/ci-cd-with-dockers-and-jenkins-70b6f801f9f7 20/20