Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to run part of Job on master and the other part on slave?

I'm new to Jenkins. I have a requirement where I need to run part of a job on the Master node and the rest on a slave node.

I tried searching on forums but couldn't find anything related to that. Is it possible to do this?

If not, I'll have to break it into two separate jobs.

EDIT

Basically I have a job that checks out source code from svn, then compiles and builds jar files. After that it's building a wise installer for this application. I'd like to do source code checkout and compilation on the master(Linux) and delegate Wise Installer setup to a Windows slave.

like image 417
sasankad Avatar asked Feb 21 '14 00:02

sasankad


2 Answers

It's definitely easier to do this with two separate jobs; you can make the master job trigger the slave job (or vice versa).

If you publish the files that need to be bundled into the installer as build artifacts from the master build, you can pull them onto the slave via a Jenkins URL and create the installer. Use the "Archive artifacts" post build step in the master build to do this.

like image 114
gareth_bowles Avatar answered Oct 05 '22 14:10

gareth_bowles


The Pipeline Plugin allows you to write jobs that run on multiple slave nodes. You don't even have to go create other separate jobs in Jenkins -- just write another node statement in the Pipeline script and that block will just run on an assigned node. You can specify labels if you want to restrict the type of node it runs on.

For example, this Pipeline script will execute parts of it on two different nodes:

node('linux') {
  git url: 'https://github.com/jglick/simple-maven-project-with-tests.git'
  sh "make"
  step([$class: 'ArtifactArchiver', artifacts: 'build/program', fingerprint: true])
}
node('windows && amd64') {
  git url: 'https://github.com/jglick/simple-maven-project-with-tests.git'
  sh "mytest.exe"
}

Some more information at the Pipeline plugin tutorial. (Note that it was previously called the Workflow Plugin.)

like image 37
Colin D Bennett Avatar answered Oct 05 '22 14:10

Colin D Bennett