Code Interpreter using Jenkins

In this post we’ll learn how jenkins interprets the code and build the pipeline.

Depending upon the code commited by developer in Github Jenkins will download the code and execute it based upon the format of the code either python or php etc.

Lets look at the pipeline of jenkins.

1. Jenkins copy code from the Github .

2. Code Interpreter

3. Checking the status of the code and Notify using email if execution failed.

4. Relaunch the code if failed else continue.

First I have to setup Jenkins .So I have create a Dockerfile which has Jenkins and docker installed in docker.

Dockerfile
Dockerfile
docker  build  -t  userprashant/jenkins:v1  /lw_task2   
 

docker run -it  -p 8096:8080 --name jenkins_os userprashant/jenkins:v1

After that copy the password of jenkins and paste at the start of jenkins login via IP:port alloted.

Job 1: Copy code from Github.

Paste the github link.
Paste the github link.
Poll SCM
Poll SCM
Execute Shell
Execute Shell

Job 2: Interpret the type of code and execute it.

Job Chaining is done .

Job Chaining
Job Chaining
Execute code depending upon the format of the code
Execute code depending upon the format of the code.

Here if the code is in python then will be executed in python . If the code is in php then it will be hosted in Apache server using httpd image. Similarly , we can install as many softwares to run code depending upon the format of the code.

Job 3: Checking the status, if failed notify by sending email.

Here I am checking the status of the php code.

Job Chaining
Job Chaining
Checking the status.
Checking the status.

Here if the code will run then exit 1 i.e , successfully executed. Else notify the failed status via email. Follow the following steps to configure E-mail notification.

Email plugin.
Email plugin.

Go to Manage Jenkins > Configuration

Email notification configuration.
Email notification configuration.

Job 4: Relaunch the code if failed else continue.

Job Chaining.
Job Chaining.
Relaunch code
Relaunch code.

My Jobs.

Jobs
Jobs

My Build Pipeline.

Build Pipeline
Build Pipeline
Github
Github

If you have any queries post them in comment section below.



Categories: DevOps, Docker, Jenkins

Tags: , ,

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: