Jenkins Maven builds on OpenShift
Short version: If you want proper Maven builds with Jenkins on OpenShift, please vote for change request JENKINS-19844.
Then I logged into my new Jenkins using the auto-generated “admin” login. I created a “New Item” to “Build a maven2/3 project”, i.e. a new Maven build job, and configured it: Selected “Git” SCM and pasted the github URL of the project I want to build.
At first all “Build Now” attempts failed silently, until I realized I had to go into “Manage Jenkins” – “Configure System” page to change the “# of executors” from 0 to 1.
Next thing was that the Maven installation was not found. I set up ssh access to my OpenShift Jenkins (paste contents of ~/.ssh/id_rsa.pub from my Linux laptop into web console, then find the ssh hostname to connect) and ran a “find -name mvn /usr” on the host which located a Maven installation at /usr/share/java/apache-maven-3.0.4. I entered this in the “Maven installation” section on the Jenkins “Configure System” page.
Now I got at least some “Console output” when I clicked “Build Now” and navigated to the page of that build. The next error, however, has so far been a blocker for me. It is described here and seems to be a limitation of the Maven agent binding address in Jenkins.
I found several blogs recommending the “free-style” Jenkins job type as a workaround, instead of “maven2/3 project”. But that has many limitations and is not an acceptable solution for me.
Finally I noticed that the issue has already been reported in 2013 as JENKINS-19844 “Maven agent socket bind too inflexible (allow Jenkins in virtualized environment)”, but was closed by mistake due to a mix-up of JIRA issue numbers (19844 vs 19884).
I used my account at jenkins-ci.org and reopened the Jenkins issue. Now I can only hope that someone from Jenkins committers team will care enough about this and apply the suggested code changes. Then we have to wait until OpenShift provides a Jenkins version that contains the fix.
Additional Note: I also read about other issues with Maven on OpenShift, e.g. Jenkins having no write access to ~/.m2/repository. I could not verify those problems but they seem to be fixable in ~/.m2/settings.xml, using $OPENSHIFT_DATA_DIR. Via ssh, I was able to create and edit ~/.m2/settings.xml.