Jenkins - Build, Deploy and Promote - maven

Recently, I started learning how to use Jenkins CI. So I am a little bit of a noob at jenkins. I am about to start to try and do the following:
I have setup a maven multi-module job on jenkins, which builds, tests, and finally creates 4 seperate war applications. I archive the war artifacts as part of this job. These war files will only ever be built once, they contain multiple environment properties, and the war file along with each environments server will manage the profile it runs in, eg dev, test, staging, prod, etc
I have another job on jenkins which will deal with the deployment to multiple environments.
This second job, uses the copy artifact plugin, and uses a post build action to deploy to a dev environment.
The job in step 2 will hopefully be able to have multiple promotions, allowing deployment to multiple environments: test/staging/performance/production etc.
I have searched stackoverflow and google, and all the posts I see, always use the parameterized plugin, specifying a parameter for the environment. This means there is a seperate build for each env which I don't like.
Can anyone tell me if this is the right way to go? Or direct me to some tutorial on how to do this properly.

Looks like what you need is a matrix-project build.
P.S.
A good introduction to Jenkins could be found in Jenkins: The Definitive Guide

After playing around with the jenkins configuration. I have this working very nicely now.
In the deployment job, I didn't see the "Add another promotion process" button, which allows me to promote the same build to multiple environments manually or automatically.

Related

Is there a way to specify several Jenkins files for the pipeline?

At the moment, we are generating Jenkins jobs using the Job DSL plugin. Typically, we have the following jobs per project:
CI build (SNAPSHOT build)
Deployment, one per stage
Integration test (nightly build)
Creation of a release
Reports (Maven site, during the night)
Am I right that there can be only one Jenkins file in the project's repository? How could I map our requirements to the new Jenkins pipeline?
I'm asking because we're going to install version 2 of Jenkins, and I'm not sure whether we should abandon our Jenkins job generation and use Jenkins files.
There are a couple of options, which might help you to migrate over to Jenkins pipelines. But you don't have to, especially not all at once.
You can use a shared library to define functions that can be used in multiple jobs, e.g. a buildOurThing function.
You can trigger an existing job (of whatever kind) using the build step. So you could model your new pipeline around existing jobs.
You can still use parameterized builds, if you want to use the deployment job with different targets.
Jenkins pipeline is really worth using, but maybe don't force you to an immediate switch. If JobDSL works for you, keep it. If you have new jobs (pipelines) to create, get familiar with pipelines.

Combining Jenkins Pipeline and UrbanCode Deploy to achieve Continuously Delivery?

The best part of UrbanCode Deploy is it models a component based architecture application, and its deployment environment so well that everybody can understand in 10 minutes. Very initiative, flexible and powerful. Don't know if there is another tool does this well.
Jenkins Pipeline can orchestra the Continuously Delivery workflow at the higher level to include the build, test, etc.
Does it make sense?
There's a new UCD plugin for Jenkins that adds nice integrations with the Jenkins 2.0 pipeline. I'm going to poke the developers since there doesn't seem to be a nice video showing it, but there is documentation (and a link to the plugin) out here:
https://developer.ibm.com/urbancode/docs/jenkins-build-step-integration-with-ibm-urbancode-deploy/
I think the idea is that you can use Jenkins pipeline to govern the flow of a build through early test environments, while UCD owns the late test environments / production when the pipeline operates more at the snapshot level. Would love your feedback!
Today, in my production environment, i use Jenkins to manage my build (like a "build pipeline" with some tests) and put all my build results into Urbancode Code station. Urbancode is doing all my deploy work perfectly, the integration with Jenkins is beautiful, easy and fast. I have read some articles about Jenkins delivery pipeline and do not recommend use it.
Check it out
https://www.thoughtworks.com/radar/tools

Skip deployment steps during automatic octopus deployment from TeamCity

I want to skip certain steps on a Octopus project while doing automated deployment from Teamcity. I have read through the docs on how to set this up, and got it to do the deployment.
How do I go about skipping some Octopus deployment steps while using this ? Or should I create a seperate octopus project for automated deployments that only contain the basic steps, then another project containing all the steps ?
Please any help would be appreciated.
I achieved this (or something similar) with a fake environment.
We have an environment called "live - inactive" which only contains the octopus server machine. This step queries our load balancer and promotes the deployment to one of our real live environments. Our deployment process steps are not configured to run in this fake environment. So the iis config etc is skipped
As you can see in the following documentation http://docs.octopusdeploy.com/display/OD/Deploying+releases
--skip=step name as part of
Additional command line arguments for OctopusDeploy: Create release Step in Teamcity

Maven, switching to a different profile

I have a problem with proper maven profile configuration of a project that is deployed to a continuous integration server.
In my project, there are some resources that needs to be included only during tests at the daily building phase and others that needs to be included during nightly builds, and they can never be included both at the same time, because building process will fail, I can achive this locally by activating one profile at the same time.
Continuous integration server runs following maven commands:
-during daily builds:
mvn clean package -Pci -Dci
-during nightly builds
mvn clean install -Dmaven.test.failure.ignore -Pci,nightly -Dci -Dnightly
As you see, nightly build command include maven variables and profiles defined in daily build command, which makes some troubles for me, becouse I want to have only one profile activated at the same time.
Specifically, what I want is having 3 separate profiles:
-my-pforile (activated by default, not used on CI server)
-ci-profile (activated only on daily builds, used on CI server)
-nightly-profile (activated only on nightly builds, used on CI server)
How can I achieve that? I tried almost everything. Reconfiguring CI server is not an option.
When I have to configure the same build with different profiles, using Jenkins as a CI,
I usually create as much builds as profiles, so each build uses the correct configuration.
If adding a new build is not an option probably you can try to create a workaround
using something like the exec plugin (http://mojo.codehaus.org/exec-maven-plugin/) to download
the resources from a ftp (or something else).
You will have also to create a cron job (or equivalent) to replace the correct resources between the builds:
in the evening you put there the resources for the night, in the morning the ones for the day.
But considering how cumbersome this process will be, probably it is better to try to add
a new build.

Template plugin for Jenkins

Is there any plugin available in Jenkins which allows you to reuse shared configuration across the jobs.. e.g I can define a template for Continuous Integration and other template for Running Tests and create multiple jobs from these template for different branches.
I know template plugin is available in Enterprise Jenkins but is there something similar available for jenkins open source?
I am looking for something similar to
here
I have found ez-templates plugin to behave well for Jobs templating. It is very young project and you will have to build it by yourself (which is very simple, see below), but still it is much more powerful than Template Project Plugin as it supports any types of jobs.
How to build:
Install Maven 3
Clone/download the ez-templates git repo
Run 'mvn install' from the ez-templates checkout folder
Once build is ready go to the 'target' folder and find the ez-templates.hpi which is self contained plugin binary.
How about the Template Project Plugin?
The Job Generator Plugin was released after this question was asked, which may fulfil some people's needs.
Unfortunately the Template Project Plugin still has some issues, particularly in that it lacks support for job parameters.
We use the Jenkins job builder to automate creation and management of our jenkins jobs. It was basically built to allowing share configurations across jobs so you can easily create the same jobs with multiple configurations. Check it out: http://docs.openstack.org/infra/jenkins-job-builder
You can use the Copy Project Link plugin. https://wiki.jenkins-ci.org/display/JENKINS/Copy+project+link+plugin
What I have done is to create a disabled (dummy) pre-configured job and when I want to create another one with the same configuration I just copied by using this plugin.

Resources