InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Jenkis

  • Install Jenkins on Linux
  • Clone a project
  • Setup build failure email
  • Setup build cron
  • Shell - how to continue on error
  • Delete old builds
 
  • Home
  • > Tutorials
  • > CI
  • > Jenkins

Install and setup Jenkins on Ubuntu Linux

By admin on Dec 30, 2015

Jenkins is an open source continuous integration (CI) tool written in java. It can be used to run (on-demand or periodic) build and test jobs based on scm tools like subversion and git. Here are steps to install and setup a test Jenkins job on Ubuntu Linux.

Install Jenkins package using apt-get

$ wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
$ sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'
$ sudo apt-get update
$ sudo apt-get install jenkins

View jenkins package files

$ dpkg -L jenkins
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/jenkins
/usr/share/doc/jenkins/changelog.gz
/usr/share/doc/jenkins/copyright
/usr/share/jenkins
/usr/share/jenkins/jenkins.war
/etc
/etc/logrotate.d
/etc/logrotate.d/jenkins
/etc/default
/etc/default/jenkins
/etc/init.d
/etc/init.d/jenkins
/var
/var/cache
/var/cache/jenkins
/var/lib
/var/lib/jenkins
/var/log
/var/log/jenkins

Check jenkins service status

$ sudo service jenkins status
Jenkins Continuous Integration Server is running with the pid 1029

Access remote jenkins using port forwarding

In case your jenkins installation is on a remote machine (e.g. Amazon EC2), you can forward local port 8080 (or some other in case this is occupied) to remote port 8080. This way you won’t have to open port 8080 to public. Here is the command to do the port forwarding

$ ssh -L 8080:localhost:8080 user@machinename

Now view the jenkins page by visiting localhost:8080.
jenkins-initial-screen

Create new jenkins job

Click on create new job and enter the job name and select Freestyle project as shown below. Click OK.
jenkins-create-new-job-screen

Setup Jenkins source code using subversion

We’ll use subversion for the purpose of this tutorial. Enter the subversion repository urls and enter credentials for the same. You may want to specify repository path till the directory having test code.
jenkins-job-setup-subversion

Setup Jenkins Build step

Scroll to Build section and click on add build step and then select execute shell.
jenkins-add-build-step-execute-shell-menu

Enter the command to run your tests. We will use the following pytest command

$ py.test --junitxml=result.xml

You must have a python test written in pytest in the directory path provided above during subversion setup. You can refer to pytest tutorial for creating a simple test.

jenkins-add-build-step-execute-shell-command

Setup post build step – archive the artifacts

Scroll to add post-build action section and click on it and select Archive the artifacts. Enter * in Files to archive textbox.
jenkins-post-build-step-archive-the-artifacts

Setup post build step – publish junit test results report

Add one more post-build action by selecting publish junit test results report this time. Enter result.xml in Test report XMLs text box and click save.
jenkins-post-build-step-publish-junit-test-result-report

Run the Jenkins job

Click on Build Now to run the job as shown below:
jenkins-job-build-now

See build details

You should be able to see all the jobs in job build history.
jenkins-job-build-history

Click on a specific job number to see build details of that specific build.
jenkins-job-specific-build-details

View text results

Click on view test results on build details page to view test results.
jenkins-job-specific-build-test-results

Suggested posts:

  1. Jenkins – how to setup build failure email
  2. Python selenium – print browser log (including javascript errors) with phantomjs
  3. How to use ssh port forwarding to surf a site from different location
  4. Why and how to log Content-Type in apache access log
  5. How to migrate your site from one domain to another
  6. How to create facebook page username for vanity url
  7. How to set up google analytics profiles for domain and sub-domain tracking
  8. Php apc vs memcache
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged CI, Jenkins, Linux, Tutorials, Ubuntu Linux
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress