Continuous Deployment part 2

I have setup Jenkins now to create a Diamond Shaped Project.
This means i Have a Starting job, several Downstream Jobs and a Finishing Job which aggregates all the results.

I will show you step by step what i have done to achieve this.

Here is a list of plugins which i have installed.

Jenkins GIT Plugin
Config File Provider Plugin
Build Pipeline Plugin
Copy+Artifact+Plugin
Join Plugin
Chuck Norris build Facts!
EnvInject Plugin
Build Name Setter Plugin

We will need to create opt-in Branches as we do not want every push to go through the automated build Cycle.
For this i have followed this tutorial

Setup GIT to be used within jenkins.Navigate to manage Jenkins and follow the settings.

Just Setting where it shall find the git executable.


Setting git globals to recognize Jenkins as a comitter

Once we have this set we can go ahead and create our First Job.

My first job just Downloads and Install Dependencies by using Composer.
This is a new Package Manager which in my opinion is really good. One problem i had here is that every time this job starts, composer would check if new updates have to be installed. I prevented this by creating a small script which checks if the composer.lock file has changed within the repository. You can find this script here

My Project Settings:

Set Project Name

Set Parameters as described in the tutorial earlier for Opt-In Branches

Advanced Project Options

I want all my Pipeline jobs to finish before this Job can start again.

Source Code Management

The url to my repository e.g. ssh://jenkins@gitrepos.com/Project.git

Hit the second advanced before Repository Browser.
I want my branches to be merged on to the master before attempting to build

Optional: Add a gitweb url to see changes in the build information

Build Triggers

Set an Authentication Token as described in Opt-In branches

Build Environment
Here we have some more interesting options. In my earlier post i mentioned that we are using PHING. We have a build.properties file which we do not want to have in the scm as it is unique for every Build or workstation.

I have created multiple Configuration files using the Config File Provider Plugin.
In the section “Manage Jenkins” you should find Managed files if you have installed the plugin.

I am creating different Configurations and saving it as a global configuration file which can be used within any Jenkins job.

Select which configuration file you want to use in this section and in my case i needed to create the build.properties file within the workspace so i let Jenkins copy it to the target “build.properties”. This makes it easier for future slave configuration as you do not have to mess with the workspace using ssh or anything later. Jenkins just handles everything.

The next option “Set Build name” is from the “Build Name Setter Plugin” as when viewing Jenkins you only see a build number, but if multiple people start a build process and everyone is in a queue, no one really knows which branch is currently building or going to be built next. Sadly this does not resolve the problem to see who is next in the queue but makes it easier to identify which branch is currently in progress. I added ${GIT_BRANCH) which is an existing environment variable.

Build
Here i just execute the script i mentioned earlier to start a package update.
Select “Add BuildStep” -> “Execute Shell”

Here we add our downstream jobs to be executed
Select “Trigger/call builds on other projects”

Post-build Actions
Specify the Job which shall run after every downstream Job is completed. This is where i aggregate all my results to get the big picture of what is going on in the Project.

Editable Email notification – here i set who gets the email on which build status. Mostly i just set here to only notify on failure as we do not want to be spammed with mails.

Phew, that was a lot of writing already. Will continue the next job tomorrow. Stay tuned!

Share and Enjoy

This entry was posted in Methodology and tagged , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *