Skip to content

wzcwts521/Hello_Jenkins

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hello_Jenkins

This simple exercise is designed to introduce you to Jenkins and continuous integration. This will be done in teams of 5 but we will all be working on one Jenkins server.

Overview

  1. Fork the repo.
  2. Set up job in Jenkins to connect to your repository and build C++ hello.cpp.
  3. Set up build status badge.
  4. Set up second job to run the program after build completes.

Forking the repository

Someone on your team hopefully has a Github account. Sign in to Github and navigate to www.github.com/jbankes/Hello_Jenkins. Go ahead and fork this repository and clone it to a computer. To clone a repository using a Mac/Linux run

$ git clone https://github.com/<your_Github_username>/Hello_Jenkins

After you have cloned the code to a computer please open the README.md file in a text editor. Please put the full names of all group members at the top of the README. Commit the change and push back to Github. Run the following from inside the directory after adding the names to the README:

$ git add README.md
$ git commit -m "Updated README with Names"
$ git push

If there is an error or you can't see your commit in Github after refreshing then let me know.

Setting up a Job in Jenkins

Jenkins Landing Page

  1. Navtigate to Jenkins.
  2. Click New Item.
  3. Enter a name for your project, click Freestyle Project, then OK.
  4. Note: Please do not include a space.
  5. Name this something unique so there are no collisions.
  6. Set up Source Code Management.
  7. Select git.
  8. Enter the URL to your git repository
  9. Setting up Build Triggers
  10. Select Poll SCM.
  11. Set up cron job by putting in H/2 * * * *.
  12. Set up Build.
  13. Add build step Execute Shell.
  14. Enter make (This will run the Makefile).
  15. Click Save.

Set up Embeddable Build Status for Repo

Build status badge

The build status symbol often seen on a Github repository is normally connected to TravisCI or JenkinsCI. We are using JenkinsCI which requires a plugin called Embeddable Build Status. I have already installed it for you. You just need to add the proper information into your README.md file.

  1. Open the README file in a text editor.
  2. Go to the Embeddable Build Status page. The link is found on the main page of the job.
  3. Select the Markdown (with View) protected link and paste it in your README.
  4. Commit your README changes and push to Github.
  5. The change should automatically cause the job to build and after you can go to Github and check your repo. You should see the build status there

Because we selected With View you will be able to click the build status icon which will take you to the Job in Jenkins.

Set up Second Job to Run the Compiled Program

The final step to this demo is to set up a second job that automatically runs after the project builds. This is different than the other job because this will not have a git repository - it doesn't even build anything.

Just a note: In a real-life scenario you wouldn't run a program through a build job just like this because I/O is not possible via this console. There are other tools people use at this step like SeleniumHQ, SonarQube, or a Deployment. The point of this is to show downstream/upstream job relationships.

  1. Create a new Job in Jenkins
  2. Click New Item.
  3. Enter a name for your second job, click Freestyle Project, then OK.
  4. Go immediately to build step and select Execute Shell.
  5. Enter the following Command /var/lib/jenkins/workspace/<the name of your first project>/hello_exec
  6. Save
  7. Set your first job to call the second
  8. Go to your first job and open the Configure page.
  9. Scroll to bottom and add a Post-Build Action. Select Build other projects.
  10. Enter the name of your second job.
  11. Save
  12. Run your first job
  13. Do this by clicking build now on the main page.
  14. After that successfully builds go and check your second job.
  15. You should see it successfully run.
  16. Select a Build Job from History and go to the console log to see your program output. If you program has run there then you successfully set up a basic pipeline. Job history

Wrapping it up

As you can see, Jenkins has a ton of opportunity which makes it the leading CI tool for modern enterprise and software development. Jobs don't have to be explicitly build jobs which mean you can do other incredible things like deployments, promotions, testing, feedback, and much more.

Turn in Your Project

Please submit the URL of your group's Github fork to x01 Intro to Jenkins on Blackboard.

Thank You

Justin Bankes [email protected]
Shane MacBride [email protected]

About

A Jenkins Demo with a Hello World C++ program.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 79.6%
  • Makefile 20.4%