Skip to content

Commit

Permalink
added VersionSelectorScript.groovy to select builders for Node version
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Apr 23, 2018
1 parent 228a598 commit 2611799
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions jenkins/scripts/VersionSelectorScript.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
def canBuild(nodeMajorVersion, builderLabel) {

// Linux
if (builderLabel.indexOf('centos5') == 0 && nodeMajorVersion >= 8)
return false
if (builderLabel.indexOf('centos6') == 0 && nodeMajorVersion < 8)
return false

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

// SmartOS
if (builderLabel.indexOf('smartos13') == 0) // Node.js 0.x
return false
if (builderLabel.indexOf('smartos14') == 0 && nodeMajorVersion >= 8)
return false
if (builderLabel.indexOf('smartos15') == 0 && nodeMajorVersion < 8)
return false


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

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

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

return true
}

// setup for execution of the above rules

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']

result['nodes'] = []

combinations.each{
def builderLabel = it.nodes
if (nodeMajorVersion >= 4) {
if (!canBuild(nodeMajorVersion, builderLabel)) {
println 'Skipping ' + builderLabel + ' for Node.js ' + nodeMajorVersion
return
}
}
result['nodes'] << it
}

0 comments on commit 2611799

Please sign in to comment.