Solution
Update the Octopus Deploy plugin for Jenkins to 4.1.3+:
- Go to Manage Jenkins > Plugins > Updates.
- Select Octopus Deploy and choose Update.
- Restart Jenkins when the download finishes.
Then rerun the build. The update keeps your Octopus server settings and jobs.
If you can't update the plugin right away, run a Jenkins version that still includes Apache Commons Lang 2: the 2.580.x LTS line, or a weekly release up to 2.578. This is only a workaround until you can update the plugin.
Installing the commons-lang3 v3.x Jenkins API Plugin (commons-lang3-api) doesn't fix this. Older versions of the Octopus plugin need Commons Lang 2, which is a different library.
Don't copy a Commons Lang 2 JAR (commons-lang-2.6.jar) into Jenkins or the plugin's folder to get around the error. Jenkins removed the library because it's no longer maintained and has known vulnerabilities, and Jenkins can replace those files when it updates. Update the plugin instead.
Cause
After a Jenkins upgrade, the first Octopus step in a build fails before it runs. The console output shows an error like this:
hudson.remoting.ProxyException: java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils
Caused: hudson.remoting.ProxyException: java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
at PluginClassLoader for octopusdeploy//hudson.plugins.octopusdeploy.services.StringUtil.sanitizeValue(StringUtil.java:7)
at PluginClassLoader for octopusdeploy//hudson.plugins.octopusdeploy.OctopusDeployPackRecorder.<init>(OctopusDeployPackRecorder.java:66)
Caused: hudson.remoting.ProxyException: java.lang.reflect.InvocationTargetException
Caused: hudson.remoting.ProxyException: java.lang.IllegalArgumentException: Could not instantiate {...} for hudson.plugins.octopusdeploy.OctopusDeployPackRecorder: java.lang.reflect.InvocationTargetException
Caused: hudson.remoting.ProxyException: java.lang.IllegalArgumentException: Failed to prepare octopusPack step
Finished: FAILURE
Version 4.1.2 and earlier of the Octopus Deploy plugin use Apache Commons Lang 2 (org.apache.commons.lang), and expect Jenkins to provide it. Jenkins 2.579 removed Commons Lang 2 from Jenkins core. On those Jenkins versions the plugin can't load the library, so every Octopus step fails.
Version 4.1.3 of the plugin uses Commons Lang 3 instead, and includes it in the plugin. It works with Jenkins versions with or without Commons Lang 2.
| Jenkins version | Includes Commons Lang 2 | Octopus plugin 4.1.2 and earlier |
|---|---|---|
| 2.578 and earlier | Yes | Works |
| 2.579+ (weekly) | No | Fails |
| 2.580.x (LTS) | Yes, added back for compatibility | Works |
Diagnosis and fix
Check the plugin version
Go to Manage Jenkins > Plugins > Installed plugins and search for Octopus Deploy. If the version is 4.1.2 or earlier and you're on Jenkins 2.579+ (weekly), update the plugin to 4.1.3+ under Manage Jenkins > Plugins > Updates, then restart Jenkins.
When the Octopus plugin is the cause, the stack trace includes hudson.plugins.octopusdeploy. If it names a different plugin instead, that plugin needs an update.
The error names a different Octopus step
You'll see the same ClassNotFoundException, ending with a different step:
Caused: hudson.remoting.ProxyException: java.lang.IllegalArgumentException: Failed to prepare octopusPushPackage step
Every Octopus step fails the same way: octopusPack, octopusPushPackage, octopusPushBuildInformation, octopusCreateRelease, and octopusDeployRelease. In Freestyle jobs, the Octopus build steps fail too. The build stops at the first Octopus step, so you'll only see that step in the error.
To fix it, update the plugin to 4.1.3+.
Saving an Octopus server in the Jenkins settings fails
When you add or change an Octopus server under Manage Jenkins > System > Octopus Deploy Plugin, the Server Id and API Key fields show:
An internal error occurred during form field validation (HTTP 500). Please reload the page and if the problem persists, ask the administrator for help.
When you choose Save, Jenkins shows Oops! A problem occurred while processing the request with a logging ID. The Jenkins log has the same error for that ID:
WARNING h.i.i.InstallUncaughtExceptionHandler#handleException: Caught unhandled exception with ID <logging ID>
java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils
Caused: java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
at PluginClassLoader for octopusdeploy//hudson.plugins.octopusdeploy.services.StringUtil.sanitizeValue(StringUtil.java:7)
at PluginClassLoader for octopusdeploy//hudson.plugins.octopusdeploy.OctopusDeployServer.<init>(OctopusDeployServer.java:57)
Jenkins keeps the Octopus servers you saved before the upgrade, but you can't add or edit them until you update the plugin.
To fix it, update the plugin to 4.1.3+, restart Jenkins, and save the settings again.
The update isn't listed
If Octopus Deploy doesn't show under Plugins > Updates, choose Check now to refresh the update list.
The error comes from a different plugin
You'll see org/apache/commons/lang/StringUtils or another org.apache.commons.lang class, but the stack trace doesn't include hudson.plugins.octopusdeploy.
Several other Jenkins plugins relied on Commons Lang 2 from Jenkins core and broke in Jenkins 2.579 for the same reason. Look for an update to the plugin named in the stack trace. The Jenkins project lists the affected plugins in Jenkins issue 27351 on GitHub.