Saturday, 5 November 2016

How to create jobs in Jenkins?

74. How to create jobs in Jenkins?

Go to Jenkins top page, select "New Job", then choose "Build a free-style software project". This job type consists of the following elements:
  • optional SCM, such as CVS or Subversion where your source code resides.
  • optional triggers to control when Jenkins will perform builds.
  • some sort of build script that performs the build (ant, maven, shell script, batch file, etc.) where the real work happens
  • optional steps to collect information out of the build, such as archiving the artifacts and/or recording javadoc and test results.
  • optional steps to notify other people/systems with the build result, such as sending e-mails, IMs, updating issue tracker, etc.
For screenshots.

What is the difference between target and task in ant?

Q. 76. What is the difference between target and task in ant?

Targets contain one or more tasks.

Another fundamental difference is that when you run ant you indicate a target (not atask) to be executed. So, when you call ant via command line, you specify ant[options] [target] . If you don't specify the target, the one indicated as default in your build file (build.xml) is executed.

How you setup jenkins slave?

 77. How you setup slave?

Login to your Master Jenkins http://abcdomain: 8080 with your Username and Password.

Click on ‘Manage Jenkins’ → Manage Nodes. Now Click on ‘New Node’ and fill in the details like this :
Few things to note:
  • # of executor: You should put it to 1 or 2
  • Remote FS root : Better to have jenkins directory as /var/jenkins
  • Host : This must be a ip address of your slave machine
  • Username : you must run all your tests as a jenkins_user
  • Password : you can use password but I would prefer private key. It’s upto you and your companies security policy.Once you happy save the config.


How you launch jenkins slave?

Q. 78. How you launch slave?

configure your slave as per your requirement.
Few things to note:

  • # of executor: You should put it to 1 or 2
  • Remote FS root : Better to have jenkins directory as /var/jenkins
  • Host : This must be a ip address of your slave machine
  • Username : you must run all your tests as a jenkins_user
  • Password : you can use password but I would prefer private key. It’s upto you and your companies security policy.Once you happy save the config.

How to run a specific jenkins job on slave?

Q. 80. How to run a specific job on slave?


By default, Jenkins will simply use the first available slave node, which usually results in the best overall turn-around time.
 If you need to tie a build job to a particular machine or group of machines, you need to tick the “Restrict where this project can be run” checkbox in the build configuration page.
 Next, enter the name of the machine, or a label identifying a group of machines, into the Label Expression field. Jenkins will provide a dynamic dropdown showing the available machine names and labels as you type.


How to run a specific jenkins job on slave?

Q. 80. How to run a specific job on slave?


By default, Jenkins will simply use the first available slave node, which usually results in the best overall turn-around time.
 If you need to tie a build job to a particular machine or group of machines, you need to tick the “Restrict where this project can be run” checkbox in the build configuration page.
 Next, enter the name of the machine, or a label identifying a group of machines, into the Label Expression field. Jenkins will provide a dynamic dropdown showing the available machine names and labels as you type.


What is the connection between jenkins master and slave?

Q 81.  What is the connection between master and slave?

In a standard Jenkins master/slave setup, Jenkins is only installed on the master. That is where you see the user interface and start/configure build jobs.
The slaves execute the jobs. 

There is no Jenkins installation here other than a small Java app to have Jenkins communicate to/from the slave. Jenkins talks to these slaves through the slave.jar app over e.g. SSH via the SSH Slaves Plugin and can monitor if the slave is running, etc.
Tricks and Tips