Skip to content

Commit

Permalink
jenkins: refactor version selector script
Browse files Browse the repository at this point in the history
simplify with regexes, a closure and shorter names
  • Loading branch information
rvagg committed Apr 12, 2018
1 parent 8bd5635 commit cdf46d5
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions jenkins/scripts/VersionSelectorScript.groovy
Original file line number Diff line number Diff line change
@@ -1,72 +1,72 @@
def canBuild(nodeMajorVersion, builderLabel, buildType) {
def canBuild(nodeVersion, builderLabel, buildType) {
def isRelease = buildType == 'release'
def matches = { match -> builderLabel =~ match }

// Linux
if (builderLabel.indexOf('centos5') == 0 && nodeMajorVersion >= 8)
if (matches(/^centos5/) && nodeVersion >= 8)
return false
if (buildType == 'release' && builderLabel.indexOf('centos6') == 0 && nodeMajorVersion < 8)
if (isRelease && matches(/^centos6/) && nodeVersion < 8)
return false
if (builderLabel =~ /centos[67]-(arm)?(64|32)-gcc48/ && nodeMajorVersion >= 10)
if (matches(/centos[67]-(arm)?(64|32)-gcc48/) && nodeVersion >= 10)
return false
if (builderLabel =~ /centos[67]-(arm)?(64|32)-gcc6/ && nodeMajorVersion < 10)
if (matches(/centos[67]-(arm)?(64|32)-gcc6/) && nodeVersion < 10)
return false
if (buildType == 'release' && builderLabel =~ /centos6-32-gcc6/ && nodeMajorVersion >= 10) // 32-bit linux for <10 only
if (isRelease && matches(/centos6-32-gcc6/) && nodeVersion >= 10) // 32-bit linux for <10 only
return false
if (builderLabel.indexOf('ubuntu1804') == 0 && nodeMajorVersion < 10) // probably temporary
if (matches(/^ubuntu1804/) && nodeVersion < 10) // probably temporary
return false
if (builderLabel.indexOf('ubuntu1204') == 0 && nodeMajorVersion >= 10)
if (matches(/^ubuntu1204/) && nodeVersion >= 10)
return false

// Windows
if (builderLabel.indexOf('vs2013-') == 0 && nodeMajorVersion >= 6)
if (matches(/^vs2013-/) && nodeVersion >= 6)
return false
if (builderLabel.indexOf('vs2015-') == 0 && (nodeMajorVersion < 6 || nodeMajorVersion >= 10))
if (matches(/^vs2015-/) && (nodeVersion < 6 || nodeVersion >= 10))
return false
if (builderLabel.indexOf('vs2017-') == 0 && nodeMajorVersion < 10)
if (matches(/^vs2017-/) && nodeVersion < 10)
return false

// SmartOS
if (builderLabel.indexOf('smartos13') == 0) // Node.js 0.x
if (matches(/^smartos14/) && nodeVersion >= 8)
return false
if (builderLabel.indexOf('smartos14') == 0 && nodeMajorVersion >= 8)
if (matches(/^smartos15/) && nodeVersion < 8)
return false
if (builderLabel.indexOf('smartos15') == 0 && nodeMajorVersion < 8)
if (isRelease && matches(/^smartos15/) && nodeVersion >= 10)
return false
if (buildType == 'release' && builderLabel.indexOf('smartos15') == 0 && nodeMajorVersion >= 10)
if (matches(/^smartos16/) && nodeVersion < 8)
return false
if (builderLabel.indexOf('smartos16') == 0 && nodeMajorVersion < 8)
return false
if (builderLabel.indexOf('smartos17') == 0 && nodeMajorVersion < 10)
if (matches(/^smartos17/) && nodeVersion < 10)
return false

if (builderLabel.equals('debian7-docker-armv7') && nodeMajorVersion >= 10)
if (matches(/^debian7-docker-armv7$/) && nodeVersion >= 10)
return false
if (buildType == 'release' && builderLabel.equals('debian8-docker-armv7') && nodeMajorVersion < 10)
if (isRelease && matches(/^debian8-docker-armv7$/) && nodeVersion < 10)
return false
if (builderLabel.equals('debian9-docker-armv7') && nodeMajorVersion < 10)
if (matches(/^debian9-docker-armv7$/) && nodeVersion < 10)
return false

// PPC BE
if (builderLabel.indexOf('ppcbe-ubuntu') == 0 && nodeMajorVersion >= 8)
if (matches(/^ppcbe-ubuntu/) && nodeVersion >= 8)
return false

// s390x
if (builderLabel.indexOf('s390x') > -1 && nodeMajorVersion < 6)
if (matches(/s390x/) && nodeVersion < 6)
return false

// AIX61
if (builderLabel.indexOf('aix61') > -1 && nodeMajorVersion < 6)
if (matches(/aix61/) && nodeVersion < 6)
return false

// sharedlibs containered
if (builderLabel.indexOf('sharedlibs_openssl111') > -1 && nodeMajorVersion < 9)
if (matches(/sharedlibs_openssl111/) && nodeVersion < 9)
return false
if (builderLabel.indexOf('sharedlibs_openssl110') > -1 && nodeMajorVersion < 9)
if (matches(/sharedlibs_openssl110/) && nodeVersion < 9)
return false
if (builderLabel.indexOf('sharedlibs_openssl102') > -1 && nodeMajorVersion > 9)
if (matches(/sharedlibs_openssl102/) && nodeVersion > 9)
return false
if (builderLabel.indexOf('sharedlibs_fips20') > -1 && nodeMajorVersion > 9)
if (matches(/sharedlibs_fips20/) && nodeVersion > 9)
return false
if (builderLabel.indexOf('sharedlibs_withoutintl') > -1 && nodeMajorVersion < 9)
if (matches(/sharedlibs_withoutintl/) && nodeVersion < 9)
return false

return true
Expand All @@ -77,8 +77,8 @@ def canBuild(nodeMajorVersion, builderLabel, buildType) {
int nodeMajorVersion = -1
if (parameters['NODEJS_MAJOR_VERSION'])
nodeMajorVersion = parameters['NODEJS_MAJOR_VERSION'].toString().toInteger()
println 'Node.js major version: ' + nodeMajorVersion
println 'Node.js version: ' + parameters['NODEJS_VERSION']
println "Node.js major version: $nodeMajorVersion"
println "Node.js version: ${parameters['NODEJS_VERSION']}"

result['nodes'] = []

Expand All @@ -93,10 +93,10 @@ combinations.each{
def builderLabel = it.nodes
if (nodeMajorVersion >= 4) {
if (!canBuild(nodeMajorVersion, builderLabel, _buildType)) {
println 'Skipping ' + builderLabel + ' for Node.js ' + nodeMajorVersion
println "Skipping $builderLabel for Node.js $nodeMajorVersion"
return
}
}
result['nodes'] << it
result['nodes'].add(it)
}

0 comments on commit cdf46d5

Please sign in to comment.