Skip to content

Commit

Permalink
jenkins: add workaround for groovy script & Java 11+
Browse files Browse the repository at this point in the history
The Matrix Groovy Execution Strategy plugin appears to have an issue
on Java 11+ where string parameters are appearing as byte arrays
instead of strings. Implement a workaround to detect this and convert
the byte array back into a string.

Refs: jenkinsci/matrix-groovy-execution-strategy-plugin#20
  • Loading branch information
richardlau committed Aug 25, 2022
1 parent 17762db commit baeaffa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion jenkins/scripts/VersionSelectorScript.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,12 @@ def canBuild = { nodeVersion, builderLabel, buildType ->

int nodeMajorVersion = -1
if (parameters['NODEJS_MAJOR_VERSION'])
nodeMajorVersion = parameters['NODEJS_MAJOR_VERSION'].toString().toInteger()
// Workaround for issue with Matrix Groovy Execution Strategy and Java 11+.
// https://github.com/jenkinsci/matrix-groovy-execution-strategy-plugin/issues/20
if (parameters['NODEJS_MAJOR_VERSION'].getClass().isArray())
nodeMajorVersion = new String(parameters['NODEJS_MAJOR_VERSION']).toInteger()
else
nodeMajorVersion = parameters['NODEJS_MAJOR_VERSION'].toString().toInteger()
println "Node.js major version: $nodeMajorVersion"
println "Node.js version: ${parameters['NODEJS_VERSION']}"

Expand Down

0 comments on commit baeaffa

Please sign in to comment.