Followers

Jenkins- CICD Pipeline

  Github with Jenkins 1. Create a freestyle project in jenkins (Githubjob) 2. Configure GitHub url in the property  GithubProject-->URL  ...


 

Github with Jenkins

1. Create a freestyle project in jenkins (Githubjob)

2. Configure GitHub url in the property  GithubProject-->URL  https://github.com/onlineTrainingguy/jenkinscicd.git/

3.Provide same Github url In Source Code Management --> git  --->   https://github.com/onlineTrainingguy/jenkinscicd.git/

4. Save this project 

5. Build the project which will provide you the workspace folder.


Maven Integration with Githubjob

1. Create a freestyle project in jenkins (Mavenjob)

2. Configure this job by using the Build -> ExecuteShell and use below command

        cd /var/lib/jenkins/workspace/Githubjob

        sudo mvn clean package

3. Goto Github project and in Post Build Action select MavenJob

4. Build Github project it should automatically trigger MavenJob 


Maven Integration Plugin

In the above example, you have created 2 jobs (Github,Maven) but with the help of Maven Integration plugin, we can create a single job that can perform the same operations as these 2 jobs are doing.

1. Goto Manage Jenkins---> Add Plugin -->Available-->Maven Integration

  then install without restart

2. Goto Manage Jenkins---> Global Tool Configuration--> Maven and provide some valid name like mvn1 and save the settings.

3. Create Maven Project with Project type Maven Project ( new project type is added after adding the Maven Integration Plugin)

4. Configure github url in the property  GithubProject-->URL  https://github.com/onlineTrainingguy/jenkinscicd.git/

5.Provide same Github url In Source Code Management --> git  --->   https://github.com/onlineTrainingguy/jenkinscicd.git/

6. Provide Maven Build Goal :- clean package

7. Save it and Build the project

8. On-Command terminal goto the workspace folder and there you will find the target folder with jar file.


Docker job to Create a docker image and container

In the repository, there is a docker file that has the code to create a docker image as per the maven jar file.

1. Create a freestyle docker project.

2. Goto Build option and change directory to Maven project folder

  • cd /var/lib/jenkins/workspace/Maven-Project
  • sudo cp target/myproj-1.0-SNAPSHOT.jar .
  • sudo docker build . -t mvnimg:$BUILD_NUMBER
  • sudo docker container run -it -d mvnimg:$BUILD_NUMBER

3. save this project

4. Goto Maven Project and in Post Build Action select docker job project.

5. Run Maven Project it will execute the docker job once it is finished successfully.

6. Check-in Jenkins server, docker images, and docker container ls --all

7. Image and container should be created.


Configure Email Notification.

1. Manage Jenkins---> Configure System---> At the bottom select the option Email Notification and provide SMTP server, user name , password details..


Test Dummy Job

In post-build action of Test job add Email notification detail.

Create a dummy freestyle project and make it as a part of post build action of docker project


Github Webhook.

1. Goto github project and select Settings--->Webhook---> Add Webhook ---> PayLoad URL--> provide jenkins url like http://3.110.175.77:8080/github-webhook/   and click on Add Webhook

2. Goto Maven Project and select configure Build Triggers --> GitHub hook trigger for GITScm polling

Create CICD Pipeline

1. Manage Jenkins --> Manage Plugins---> Build Pipeline--> Install without restart

2. In the Dashboard click on + and select Build Pipeline project

3. Select Initial job as Maven Project

4. Update a code in github and it should automatically trigger complete CICD pipeline.




COMMENTS

Name

Ansible,6,AWS,1,Azure DevOps,1,Containerization with docker,2,DevOps,2,Docker Quiz,1,Docker Swarm,1,DockerCompose,1,ELK,2,git,2,Jira,1,Kubernetes,1,Kubernetes Quiz,5,SAST DAST Security Testing,1,SonarQube,3,Splunk,2,vagrant kubernetes,1,YAML Basics,1,
ltr
item
DevOpsWorld: Jenkins- CICD Pipeline
Jenkins- CICD Pipeline
DevOpsWorld
https://www.devopsworld.co.in/2022/02/jenkins-github-and-maven-integration.html
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/2022/02/jenkins-github-and-maven-integration.html
true
5997357714110665304
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content