Upgrading to Jenkins 2.x

Upgrading to Jenkins 2.x

From the Jenkins 2.0 page:

Screen Shot 2016-07-18 at 10.32.01

This was supposed to be a “drop in replacement”.. however I encountered the following problems:

  • New bouncy castle libs for crypto not compatible with jenkins-jclouds plugin, this caused all jobs that use single-use cloud slaves to fail. Resolved by restoring old bouncy castle jars. https://issues.jenkins-ci.org/browse/JENKINS-30099
  • Undefined parameters are no longer injected into the job environment. This means that if you use a plugin that adds env vars (such as the github pull request builder) you now need to define all the environment variables you wish to use as job parameters. https://jenkins.io/blog/2016/05/11/security-update/ As a temporary work around jenkins can be invoked with a switch to enable the old behaviour:
    java -Dhudson.model.ParametersAction.keepUndefinedParameters=true -jar jenkins.war

    Note: This change was made to fix a security issue so by enabling this option you may expose a vulnerability.

  • The github pull request trigger plugin disappeared, not sure why, had to reinstall it
  • The github auth plugin needed to be upgraded to avoid a stack trace concerning authentication:
    Build step 'Trigger/call builds on other projects' changed build result to SUCCESS
    FATAL: org.acegisecurity.providers.UsernamePasswordAuthenticationToken cannot be cast to org.jenkinsci.plugins.GithubAuthenticationToken
    java.lang.ClassCastException: org.acegisecurity.providers.UsernamePasswordAuthenticationToken cannot be cast to org.jenkinsci.plugins.GithubAuthenticationToken
    	at org.jenkinsci.plugins.GithubSecurityRealm.loadUserByUsername(GithubSecurityRealm.java:542)
    	at hudson.model.User$UserIDCanonicalIdResolver.resolveCanonicalId(User.java:1050)
    	at hudson.model.User.get(User.java:395)
    	at hudson.model.User.get(User.java:364)
    	at hudson.plugins.git.GitChangeSet.findOrCreateUser(GitChangeSet.java:374)
    	at hudson.plugins.git.GitChangeSet.getAuthor(GitChangeSet.java:443)
    	at hudson.model.AbstractBuild.getCulprits(AbstractBuild.java:350)
    	at hudson.model.AbstractBuild.getCulprits(AbstractBuild.java:346)
    	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:669)
    	at hudson.model.Run.execute(Run.java:1766)
    	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    	at hudson.model.ResourceController.execute(ResourceController.java:98)
    	at hudson.model.Executor.run(Executor.java:410)
  • Git git scm plugin’s refspec field now appears to replace the default fetch rather than add to it. I had some jobs which had a refspec specified to fetch PR refs from github repos. This still worked, but the standard branch refs were not fetched. Thankfully multiple refspec mappings can be specified by space separating them. The final string is:
    +refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/*

The upgrade may be straight forward if you use vanilla Jenkins, but if you use any plugins, even well known ones, be sure to test the upgrade first.