0

I've never done any CI work before, so I'm struggling to decide how to set up Jenkins as my first project at my new job.

From what I (sort of) understand:

  • Jobs are the generic work unit

  • Pipelines are like a job but are defined from a series of steps from scripts stored in a VCS repo

  • Matrix is like a job, but you can define axes to execute commands across

The basic setup for my project is 2 git repositories serving 3 platforms (one Windows, one Mac/Unix), each of which has 3 branches for different phases (so 9 builds total). The team wants something that will automate builds from each branch as things are committed to them, and then run some tests (which I'm also going to write). There are 2 machines dedicated to each branch. This will not include any kind of general deployment. It'll only be to the test machines.

I've set up a Jenkins master server that each branch stack connects to. I have 3 jobs set up at the moment targets a label I've assigned to the test machines, since I'm just testing with one branch for each platform. Each job uses the "run script" option, and contains something like:

# sets up the required authentication
$SLAVE_HOME/pre-build.sh

# then run the build script
./build.sh

# then a post-build/install script that automates installation of the packages,
# runs the product, and verifies it's started properly.
$SLAVE_HOME/install.sh

The scripts are unique to platform, and may eventually be unique to branch depending on if build steps change

I'll also need to integrate testing at some point - I'm planning to try using SikuliX for mac/unix and either that or Selenium+Winium for Windows. This will include aggregating results and build status to post on a not-yet-written monitoring page. That will add another couple platform-specific "global" steps.

Setting up 9 jobs that are very similar feels like I'm doing something wrong. I've considered a matrix per platform with branch axis, but I'll also need to report on build status/outputs, and having 6 outputs tied into one job might be problematic. Tests may also differ between branches as features are changed.

2

You can use the Jenkins pipeline (Jenkinsfile) to run the multiple branches in multiple stages, with the conditional 'IF'. Below is an example from Jonico. I always use this example to create continuous delivery of monolithic applications. https://gist.github.com/jonico/e205b16cf07451b2f475543cf1541e70

1

To be honest, I'm not sure exactly what your question is here (StackExchange sites usually work best when you formulate your post as a single question rather than just generally asking for help). So I'm going to attempt to address what appears to be your main issue:

Setting up 9 jobs that are very similar feels like I'm doing something wrong. I've considered a matrix per platform with branch axis, but I'll also need to report on build status/outputs, and having 6 outputs tied into one job might be problematic. Tests may also differ between branches as features are changed.

This is where Shared Libraries come in. Jenkins Shared Libraries allow you to refactor common code into their own individual repositories outside of your project repos. This allows you to treat your Pipeline code, or snippets of your Pipeline code, as independently-versioned libraries.

For instance, my team has 150+ repos which require near-identical Pipelines. Instead of synchronizing 150 Jenkinsfiles, I have one Shared Library which is used by all of these repos to run tests and deploys.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.