Feb 15, 2022

[DevOps] Create your first CI/CD pipeline!!

 

[DevOps] Create your first CI/CD pipeline!!

What is CI/CD pipeline?

A CI/CD pipeline is a series of steps that must be performed in order to deliver a new version of software.A CI/CD pipeline introduces monitoring and  to improve the process of application development, particularly at the integration and testing phases, as well as during delivery and deployment. Although it is possible to manually execute each of the steps of a CI/CD pipeline, the true value of CI/CD pipelines is realized through automation.

Elements of a CI/CD pipeline

  • Build — The stage where the application is compiled.
  • Test — The stage where code is tested. Automation here can save both time and effort.
  • Release — The stage where the application is delivered to the repository.
  • Deploy — In this stage code is deployed to production.
  • Validation and compliance — The steps to validate a build are determined by the needs of your organization. Image security scanning tools, like , can ensure the quality of images by comparing them to known .

Tools

Overview

This is what we will create in this article.

What we use?

  • Ec2 Ubuntu
  • Java, Jenkins, Maven
  • Tomcat
  • Docker, Jira
  • DefectDojo

Setup

1: prepare 2 Ubuntu server . Name one for “Jenkins”. one for “Tomcat” Recommend more than t2.small instance type.

2: make sure you can ssh into the both servers.

Setting up Jenkins server

1: update

sudo apt-get update -y

2: Install Java (Java Runtime Environment)

sudo apt search openjdk

3: Install the JDK

sudo apt-get install default-jdk -y

4: Check your version

ubuntu@jenkins:~$ javac -version
javac 11.0.13
ubuntu@jenkins:~$ java -version
openjdk version "11.0.13" 2021-10-19
OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)

5: Add the Jenkins Repository

curl -fsSL  | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null

6: install Jenkins

sudo apt updatesudo apt-get install jenkins

7: confirm it is running.

ubuntu@jenkins:~$ sudo systemctl status jenkins
● jenkins.service - LSB: Start Jenkins at boot time
Loaded: loaded (/etc/init.d/jenkins; generated)
Active: active (exited) since Fri 2021-12-31 23:28:46 UTC; 57s ago
Docs: man:systemd-sysv-generator(8)
Tasks: 0 (limit: 2355)
Memory: 0B
CGroup: /system.slice/jenkins.service
Dec 31 23:28:45 jenkins systemd[1]: Starting LSB: Start Jenkins at boot time...
Dec 31 23:28:45 jenkins jenkins[4565]: Correct java version found
Dec 31 23:28:45 jenkins jenkins[4565]: * Starting Jenkins Automation Server jenkins
Dec 31 23:28:45 jenkins su[4599]: (to jenkins) root on none
Dec 31 23:28:45 jenkins su[4599]: pam_unix(su-l:session): session opened for user jenkins by (uid=0)
Dec 31 23:28:45 jenkins su[4599]: pam_unix(su-l:session): session closed for user jenkins
Dec 31 23:28:46 jenkins jenkins[4565]: ...done.
Dec 31 23:28:46 jenkins systemd[1]: Started LSB: Start Jenkins at boot time.

Also check the IP + port 8080 to see the console.

Please enter this command to check the password.

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

8:install the suggested plugins

After the plugins installation, go to the console and choose “manage jenkins”

we need these ones. Start installing without restart

After completing that,

9:Install Docker

Update the apt package index and install packages to allow apt to use a repository over HTTPS:

sudo apt-get updatesudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release

Add Docker’s official GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Use the following command to set up the stable repository. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below.

echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Install Docker Engine

Update the apt package index, and install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:

sudo apt-get updatesudo apt-get install docker-ce docker-ce-cli containerd.io

List the versions available in your repo:

apt-cache madison docker-ce

Install a specific version using the version string from the second column, for example,

sudo apt-get install docker-ce=5:20.10.12~3-0~ubuntu-focal docker-ce-cli=5:20.10.12~3-0~ubuntu-focal containerd.io

Verify that Docker Engine is installed correctly by running the hello-world image.

sudo docker run hello-worldUnable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:2498fce14358aa50ead0cc6c19990fc6ff866ce72aeb5546e1d59caac3d0d60f
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
For more examples and ideas, visit:

check the status

ubuntu@jenkins:~$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-12-31 23:40:27 UTC; 4min 55s ago
TriggeredBy: ● docker.socket
Docs:
Main PID: 6261 (dockerd)
Tasks: 9
Memory: 34.4M
CGroup: /system.slice/docker.service
└─6261 /usr/bin/docke

Lets add our username to the docker group

sudo usermod -aG docker jenkins

install maven

sudo apt updatesudo apt install mavenubuntu@jenkins:~$ mvn -version
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 11.0.13, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.11.0-1022-aws", arch: "amd64", family: "unix"

Setting up Tomcat server

1: install java (please see the previous steps)

ubuntu@tomcat:~$ java -version
openjdk version "11.0.13" 2021-10-19
OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.18.04)
OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.18.04, mixed mode, sharing)

2: install tomcat

mkdir /prod
cd /prod
sudo wget
sudo apt install unzipsudo unzip apache-tomcat-9.0.56.zip

3: start tomcat

cd apache-tomcat-9.0.56/binchmod +x catalina.shubuntu@tomcat:/prod/apache-tomcat-9.0.56/bin$ sudo bash startup.sh
Using CATALINA_BASE: /prod/apache-tomcat-9.0.56
Using CATALINA_HOME: /prod/apache-tomcat-9.0.56
Using CATALINA_TMPDIR: /prod/apache-tomcat-9.0.56/temp
Using JRE_HOME: /usr
Using CLASSPATH: /prod/apache-tomcat-9.0.56/bin/bootstrap.jar:/prod/apache-tomcat-9.0.56/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.

we can see it is running.

4: config settings (For tomcat 9)

sudo vi /prod/apache-tomcat-9.0.56/webapps/manager/META-INF/context.xml

Please comment out

  • add <role rolename="manager-gui"/>
  • add <user username="tomcat" password="<yourpassword>" roles="manager-gui"/>

Also, we need to add the username

cd ../bin/ubuntu@tomcat:/prod/apache-tomcat-9.0.56/bin$ sudo bash shutdown.shubuntu@tomcat:/prod/apache-tomcat-9.0.56/bin$ sudo bash startup.sh

Creating build pipeline in Jenkins

create a new item (pipeline)

Provide a name for your new item (e.g. Pipeline webapp) and select Multibranch Pipeline

Click the Add Source button, choose the type of repository you want to use and fill in the details.

put your GitHub repo address and click validate.

It shows ok if there is no credentials and click save.

After saving that, you can see it on the console.

Go to the GitHub repos you put in the preveious steps and create new file there.

Make a file called “jenkinsfile” and the inside

pipeline {
agent { docker { image 'maven:3.8.4-openjdk-11-slim' } }
stages {
stage('build') {
steps {
sh 'mvn --version'
}
}
}
}



Sep 26, 2019

40+ Motivational Quotes for Creatives

Sometimes we all need a little motivation. The road to creating something great can be tough. There are many twists and turns, failures, trials and tribulations. We all grow a little weary.
The goal of this article is to reinvigorate your creativity with empowering quotes from creators, inventors, and entrepreneurs of all backgrounds.
These quotes vary in nature. Some apply to work ethic, some for inspiration and determination, and others are just great phrases to live by. Get inspired with these quotes for creators below and then get creating!

Be Inspired to Create

“…If one advances confidently in the direction of his dreams, and endeavors to live the life which he has imagined, he will meet with a success unexpected in common hours…If you have built castles in the air, your work need not be lost; that is where they should be. Now put the foundations under them.” – Henry David Thoreau
“To know your life purpose is to connect with a higher power.” – Shannon L. Alder
“Inspiration exists, but it has to find you working.” – Pablo Picasso
Success is not the key to happiness. Happiness is the key to success. If you love what you are doing, you will be successful.” – Albert Schweitzer
“It’s never too late to be who you might have been.” – George Eliot
“If you cannot do great things, do small things in a great way.” – Napoleon Hill
A person holding a small plant.
“With the advent of spring and beginning of the new harvest season the creators of abundance, our peasants, come out to the fields to sow with good aspirations and hopes.” – Islom Karimov
“To dare is to lose one’s footing momentarily. To not dare is to lose oneself.” – Soren Kierkegaard
“Success is going from failure to failure without losing enthusiasm.” – Winston Churchill
“The other side of every fear is a freedom.” – Marilyn Ferguson
“Opportunity is missed by most because it is dressed in overalls and looks like work.” – Thomas Edison
“Problems cannot be solved at the same level of awareness that created them.” – Albert Einstein
“A creative man is motivated by the desire to achieve, not by the desire to beat others.” – Ayn Rand
“What we see depends mainly on what we look for.” – John Lubbock
A rocky coastline.
“Whether you think that you can, or that you can’t, you are usually right.” – Henry Ford
“I always prefer to believe the best of everybody; it saves so much trouble.”  – Rudyard Kipling
“You don’t need money to be creative. The ghetto builds champions every day.” – DJ Snake
“The most dangerous idea is silencing people.” – Naval Ravikant
“A busy calendar and a busy mind will destroy your ability to do great things in this world. If you want to be able to do great things, whether you’re a musician, or whether you’re an entrepreneur, or whether you’re an investor, you need free time and you need a free mind.” – Naval Ravikant
“The cure for boredom is curiosity. There is no cure for curiosity.” – Dorothy Parker
“Go into yourself. Find out the reason that commands you to write; see whether it has spread its roots into the very depths of your heart; confess to yourself whether you would have to die if you were forbidden to write.” – Rainer Maria Rilke
“So go on, get angry. But keep your mouth shut and go do your work.” – Austin Kleon
“Somewhere, something incredible is waiting to be known.” – Carl Sagan
A mountain on a starry night.
“The world always seems brighter when you’ve just made something that wasn’t there before.” – Neil Gaiman
“We don’t make mistakes, just happy little accidents.” – Bob Ross
“Many prefer not to exercise their imaginations at all. They choose to remain comfortably within the bounds of their own experience, never troubling to wonder how it would feel to have been born other than they are.” – J.K. Rowling
“A new idea is delicate. It can be killed by a sneer or a yawn; it can be stabbed to death by a quip and worried to death by a frown on the right man’s brow.” – Charles Brower
“Remember the two benefits of failure. First, if you do fail, you learn what doesn’t work; and second, the failure gives you the opportunity to try a new approach.” – Roger Von Oech
“I’m convinced that about half of what separates successful entrepreneurs from the non-successful ones is pure perseverance.” – Steve Jobs
“Anxiety is the handmaiden of creativity.” – T. S. Eliot
Waves crashing on a beach.
“You can’t use up creativity the more you use the more you have.” – Maya Angelou
“There is only one of you in all time. This expression is unique and if you block it, it will never exist through any other medium and it will be lost.” – Martha Graham
“Creative people are curious, flexible, persistent, and independent, with a tremendous spirit of adventure and a love of play.” – Henri Matisse
“Curiosity about life in all of its aspects, I think, is still the secret of great creative people.” – Leo Burnett
“You can’t wait for inspiration, you have to go after it with a club.” – Jack London
“To raise new questions, new possibilities, to regard old problems from a new angle, requires creative imagination and marks real advance in science.” – Albert Einstein
“The essential part of creativity is not being afraid to fail.” – Edwin H. Land
“Creative activity could be described as a type of learning process where teacher and pupil are located in the same individual.” – Arthur Koestler
“Don’t think. Thinking is the enemy of creativity. It’s self-conscious, and anything self-conscious is lousy. You can’t try to do things. You simply must do things.” – Ray Bradbury
“Blessed are the curious, for they shall have adventures.” – L. Drachman
“In the beginner’s mind there are many possibilities, but in the expert’s mind there are few.” – Shunryu Suzuki
A young girl looks off into the distance.

Quotes That Will Make You Think…

For this last section, we’re featuring just a few more quotes for creators that are less motivational and moreso thought-provoking.
“We call ourselves creators and we just copy.” – Lauryn Hill
“The most regretful people on earth are those who felt the call to creative work, who felt their own creative power restive and uprising, and gave to it neither power nor time.” – Mary Oliver
“If you’re creating anything at all, it’s really dangerous to care about what people think.” – Kristen Wiig
“Great is the human who has not lost his childlike heart.” – Mencius (Meng-Tse)
“When Alexander the Great visited Diogenes and asked whether he could do anything for the famed teacher, Diogenes replied: “Only stand out of my light.” Perhaps some day we shall know how to heighten creativity. Until then, one of the best things we can do for creative men and women is to stand out of their light.” – John W. Gardner
“Don’t worry about people stealing your ideas. If your ideas are any good, you’ll have to ram them down people’s throats.” – Howard Aiken
“Some men look at things the way they are and ask why? I dream of things that are not and ask why not?” – Robert Kennedy

Words of Wisdom

Which quote stood out the most to you? We hope you use these motivational and thought-provoking words to boost your creativity and make the world a more beautiful place. You can do it!