Skip to content

Commit 241b5fb

Browse files
author
Bernie Zang
committed
fix(tooling): Move jenkinsfile.tap to procedural groovy
1 parent c572a9e commit 241b5fb

File tree

1 file changed

+49
-59
lines changed

1 file changed

+49
-59
lines changed

Jenkinsfile.tap

Lines changed: 49 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,63 @@
11
#!groovy
22

33
def tapTest = { ->
4-
sh '''#!/bin/bash -ex
5-
source ~/.nvm/nvm.sh
6-
nvm use v7
7-
CISCOSPARK_CLIENT_ID=C873b64d70536ed26df6d5f81e01dafccbd0a0af2e25323f7f69c7fe46a7be340 SAUCE=true npm run test:tap
8-
'''
9-
}
10-
11-
// We only retry once. If it fails again we fail the build
12-
def runTapTests = { ->
13-
echo 'Running Tests'
14-
try {
15-
tapTest()
16-
}
17-
catch(error) {
18-
echo "Test Failed"
19-
sleep 30s
20-
tapTest()
4+
withCredentials([
5+
string(credentialsId: 'ddfd04fb-e00a-4df0-9250-9a7cb37bce0e', variable: 'CISCOSPARK_CLIENT_SECRET'),
6+
usernamePassword(credentialsId: 'SAUCE_LABS_VALIDATED_MERGE_CREDENTIALS', passwordVariable: 'SAUCE_ACCESS_KEY', usernameVariable: 'SAUCE_USERNAME'),
7+
]) {
8+
sh '''#!/bin/bash -ex
9+
source ~/.nvm/nvm.sh
10+
nvm use v7
11+
CISCOSPARK_CLIENT_ID=C873b64d70536ed26df6d5f81e01dafccbd0a0af2e25323f7f69c7fe46a7be340 SAUCE=true npm run test:tap
12+
'''
2113
}
2214
}
2315

2416

25-
pipeline {
26-
agent{
27-
label 'NODE_JS_BUILDER'
28-
}
29-
30-
options {
31-
timeout(time: 1, unit: 'HOURS')
32-
timestamps()
33-
ansiColor('xterm')
34-
}
35-
36-
stages {
37-
stage('Install') {
38-
steps {
39-
withCredentials([
40-
string(credentialsId: 'NPM_TOKEN', variable: 'NPM_TOKEN')
41-
]) {
42-
sh 'echo \'//registry.npmjs.org/:_authToken=${NPM_TOKEN}\' > $HOME/.npmrc'
43-
sh '''#!/bin/bash -ex
44-
source ~/.nvm/nvm.sh
45-
nvm install 7
46-
nvm use v7
47-
npm install
48-
rm -f $HOME/.npmrc
49-
'''
17+
ansiColor('xterm') {
18+
timestamps {
19+
timeout(60) {
20+
node('NODE_JS_BUILDER') {
21+
try {
22+
stage('Install') {
23+
withCredentials([
24+
string(credentialsId: 'NPM_TOKEN', variable: 'NPM_TOKEN')
25+
]) {
26+
sh 'echo \'//registry.npmjs.org/:_authToken=${NPM_TOKEN}\' > $HOME/.npmrc'
27+
sh '''#!/bin/bash -ex
28+
source ~/.nvm/nvm.sh
29+
nvm install 7
30+
nvm use v7
31+
npm install
32+
rm -f $HOME/.npmrc
33+
'''
34+
}
35+
}
36+
37+
stage('Test') {
38+
echo "Starting Tap Tests"
39+
try {
40+
tapTest()
41+
}
42+
catch(error) {
43+
echo "Test Failed"
44+
sleep 30s
45+
tapTest()
46+
}
47+
echo "Finised with Tap Tests"
48+
}
5049
}
51-
}
52-
}
5350

54-
stage('Test') {
55-
steps {
56-
withCredentials([
57-
string(credentialsId: 'ddfd04fb-e00a-4df0-9250-9a7cb37bce0e', variable: 'CISCOSPARK_CLIENT_SECRET'),
58-
usernamePassword(credentialsId: 'SAUCE_LABS_VALIDATED_MERGE_CREDENTIALS', passwordVariable: 'SAUCE_ACCESS_KEY', usernameVariable: 'SAUCE_USERNAME'),
59-
]) {
60-
echo "Starting Tap Tests"
61-
runTapTests()
62-
echo "Finised with Tap Tests"
51+
52+
catch(error) {
53+
if (currentBuild.result != 'UNSTABLE') {
54+
currentBuild.result = 'FAILURE'
55+
}
56+
cleanup()
57+
emailext body: '<p>Spark-js-sdk--react-widget--tap build number $BUILD_NUMBER has failed. For detailed information, please refer to $BUILD_URL</p><pre>${BUILD_LOG_EXCERPT, start="^Starting Tap Tests", end="^Finised with Tap Tests"}</pre>', subject: 'Spark-js-sdk--react-widget--tap Failure', to: 'spark-js-sdk-gating-pipeline-email.94d222a7@ciscospark.pagerduty.com'
58+
throw error
6359
}
6460
}
6561
}
6662
}
67-
68-
post {
69-
failure {
70-
emailext body: '<p>Spark-js-sdk--react-widget--tap build number $BUILD_NUMBER has failed. For detailed information, please refer to $BUILD_URL</p><pre>${BUILD_LOG_EXCERPT, start="^Starting Tap Tests", end="^Finised with Tap Tests"}</pre>', subject: 'Spark-js-sdk--react-widget--tap Failure', to: 'spark-js-sdk-gating-pipeline-email.94d222a7@ciscospark.pagerduty.com'
71-
}
72-
}
7363
}

0 commit comments

Comments
 (0)