Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions jenkins/pipelines/node-inspect.jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env groovy

pipeline {
agent any

parameters {
string(defaultValue: "nodejs/node-inspect", description: 'The Github repository to build', name: 'projectRepo')
string(defaultValue: "master", description: 'The remote ref to build', name: 'projectRef')
booleanParam(defaultValue: false, description: 'Treat PROJECT_REF as a pull request id', name: 'isPR')
string(defaultValue: '8', description: 'The node version to build against', name: 'nodeVersion')
string(
defaultValue: 'all',
description: 'Space-separated list of nodes, e.g. debian8-64 fedora22 fedora23 osx1010 ppcle-ubuntu1404 ubuntu1204-64 ubuntu1404-64 ubuntu1604-64 rhel72-s390x aix61-ppc64 ppcbe-ubuntu1404 smartos16-64 smartos15-64 win10 win2012r2',
name: 'machines'
)
}

stages {
stage("Build") {
parallel {
stage('ubuntu1404-64') {
when {
expression { params.machines =~ /^all$|\bubuntu1404-64\b/ }
}

agent any

steps {
doCheckout()
runWithNodeVersionLinux('ubuntu1404-64')
}

post {
always { collectTestResults() }
}
}

stage('ubuntu1604-64') {
when {
expression { params.machines =~ /^all$|\bubuntu1604-64\b/ }
}

agent any

steps {
doCheckout()
runWithNodeVersionLinux('ubuntu1604-64')
}

post {
always { collectTestResults() }
}
}
}
}
}
}

def doCheckout() {
checkout(poll: false, scm: [
$class: 'GitSCM',
branches: [[
name: (params.isPR ? "pr/${params.projectRef}/head" : params.projectRef)
]],
userRemoteConfigs: [[
url: "https://github.com/${params.projectRepo}",
refspec: '+refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/*',
]],
])
}

def runWithNodeVersionLinux(archName) {
withEnv(["NVM_DIR=${pwd(tmp: true)}/.nvm"]) {
sh 'echo \$NVM_DIR && rm -rf test/*.tap'
sh 'if [ ! -d "$NVM_DIR/.git" ]; then mkdir -p "$NVM_DIR" && git init "$NVM_DIR"; fi && cd "$NVM_DIR" && git fetch https://github.com/creationix/nvm.git v0.33.6 && git reset --hard FETCH_HEAD'
sh "bash -c '. $NVM_DIR/nvm.sh && nvm install ${params.nodeVersion} && npm install && npm test -- --output-file=test/${archName}.tap'"
}
}

def collectTestResults() {
archive 'test/*.tap'
step([$class: "TapPublisher", testResults: "test/*.tap"])
}