From 6f296626469ad91a6357d837479d6b6860b8cfc1 Mon Sep 17 00:00:00 2001 From: Jan Krems Date: Mon, 30 Oct 2017 11:43:02 -0700 Subject: [PATCH 1/3] Add pipeline script for node-inspect --- jenkins/node-inspect.jenkinsfile | 83 ++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 jenkins/node-inspect.jenkinsfile diff --git a/jenkins/node-inspect.jenkinsfile b/jenkins/node-inspect.jenkinsfile new file mode 100644 index 000000000..15bd49bde --- /dev/null +++ b/jenkins/node-inspect.jenkinsfile @@ -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 'curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash' + 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"]) +} From 5fafaf1b87bec4f2ef21c3274d3e66fa42083e90 Mon Sep 17 00:00:00 2001 From: Jan Krems Date: Wed, 8 Nov 2017 07:57:03 -0800 Subject: [PATCH 2/3] Move node-inspect to pipelines/ --- jenkins/{ => pipelines}/node-inspect.jenkinsfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename jenkins/{ => pipelines}/node-inspect.jenkinsfile (100%) diff --git a/jenkins/node-inspect.jenkinsfile b/jenkins/pipelines/node-inspect.jenkinsfile similarity index 100% rename from jenkins/node-inspect.jenkinsfile rename to jenkins/pipelines/node-inspect.jenkinsfile From 1fb7b6046ed7304fef291133a6599decb06243c7 Mon Sep 17 00:00:00 2001 From: Jan Krems Date: Wed, 8 Nov 2017 07:57:19 -0800 Subject: [PATCH 3/3] Do not use nvm install script --- jenkins/pipelines/node-inspect.jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jenkins/pipelines/node-inspect.jenkinsfile b/jenkins/pipelines/node-inspect.jenkinsfile index 15bd49bde..a623165ca 100644 --- a/jenkins/pipelines/node-inspect.jenkinsfile +++ b/jenkins/pipelines/node-inspect.jenkinsfile @@ -72,7 +72,7 @@ def doCheckout() { def runWithNodeVersionLinux(archName) { withEnv(["NVM_DIR=${pwd(tmp: true)}/.nvm"]) { sh 'echo \$NVM_DIR && rm -rf test/*.tap' - sh 'curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash' + 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'" } }