I originally wrote on spinning up a Jenkins server for intra-OpenShift deployments with an external repository in Jenkins build server on OpenShift. This post will detail the basic process and major changes that have been required as the OpenShift platform has evolved to the General Availability release.
This assumes you already have an OpenShift account, an application server cartridge, a Jenkins cartridge, and a new diy project created in Jenkins. I would advise against using OpenShift's Jenkins-app-server-integration, and just spin them up separately. At time of writing the OpenShift maintained Jenkins cartridge still reads Jenkins Server 1.4, but it is actually 1.509.1.
Create an SSH key on the fresh Jenkins cartridge in
ssh-keygen -C jenkins@openshift, and add it to the
Account Settings. This will
ensure that authentications with the key are accepted on any of your
# set deploy user and endpoint DEPLOY_ENDPOINT=[alpha-num username]@[cart name]-[namespace].rhcloud.com # Push content to server scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/app-root/data/.ssh/id_rsa $WORKSPACE/*.war $DEPLOY_ENDPOINT:~/jbossews/webapps/ # Reload server with new version ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/app-root/data/.ssh/id_rsa $DEPLOY_ENDPOINT "~/jbossews/bin/control restart"
As one can see, I am deploying to a JBoss EWS cartridge.
For the JBoss EWS instance to automatically pick up WAR changes and redeploy the context, we have to add in the hot deploy marker file.
git rm -r src pom.xml
touch .openshift/markers/hot_deploy; git add .openshift/markers/hot_deploy
Your application should be listening for WAR changes, so remove the last line from the shell script
in the previous section -
~/jbossews/bin/control restart - as there is no more need to do a full
You can emulate what Bitbucket will do with the following command:
wget --auth-no-challenge --post-data="" http://[user]:[API token]@[cart]-[ns].rhcloud.com/job/[project name]/build?token=[token]
http://[user]:[API token]@[cart]-[ns].rhcloud.com/ should be equivalent to what
you have in the Endpoint field.
Be sure to configure Jenkins’ Global Security properly so that
is able to start builds:
20130929 EDIT: Seems as though the Bitbucket POST service doesn't want
to play ball anymore with my hosted Jenkins instance. Updated the
Build Triggers section to Poll SCM every three minutes:
*/3 * * * *.