Task 1

Prudhvi Kumar Danapana
3 min readJul 18, 2021

JOB#1
If Developer push to dev branch then Jenkins will fetch from dev and deploy on dev-docker environment.

  • Firstly upload any code in any format in git and that too in dev branch.

Following are the commands we have to run in order to push the code in git hub.

  • git init
  • notepad hi.html (similarly)
  • git status
  • git add hi.html
  • git commit . -m “sec”
  • git push

Firstly create a free style project as shown:

After pushing the code in dev branch then copy the code link to paste in jenkins job.

Then in the build click on execute shell as shown:

Then finally save it and click on build now.

JOB#2
If Developer push to master branch then Jenkins will fetch from master and deploy on master-docker environment.
both dev-docker and master-docker environment are on different docker containers.

Simply perform all the steps done in the job expect the git link and the code that we built in execute shell.

Copy the git url of master in the SCM option of jenkins.

In the execute shell type the code as shown:

Finally , save it and click on build now.

JOB#3
Manually the QA team will check (test) for the website running in dev-docker environment. If it is running fine then Jenkins will merge the dev branch to master branch and trigger #job 2

For this we have to create an another freestyle job and give your description of that project as your wish:

Give the git hub url with credentials so that for merging them would be easy without any error:

In the SCM of jenkins click on Additional behaviours and select merge before build:

In the build triggers option add the master one and select build after other projects are built and in that select trigger only if build is stable as shown:

At last in the post build actions click on projects to build and also add git publisher and in that select Push Only If Build Succeeds and also Merge Results:

  • That means here we telling the jenkins to to push the code from dev1 to master until and unless the dev1 job run sucessfully.

Finally the code ran succesfully:

Finally the dev branch code has been merged to master branch:

--

--