forked from as-ideas/oil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsFileEndToEndRemote
55 lines (46 loc) · 1.48 KB
/
JenkinsFileEndToEndRemote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!groovy
def sendPerSlack(color, status) {
def committerEmail = sh (
script: 'git --no-pager show -s --format=\'%an\'',
returnStdout: true
).trim()
def buildUser = wrap([$class: 'BuildUser']) {
sh (
script: 'echo ${BUILD_USER}',
returnStdout: true
)
}
slackSend color: color, message: "${status}: Job '${env.JOB_NAME} for ${params.browser} [${env.BUILD_NUMBER}]' (${env.BUILD_URL}) - Committer: ${committerEmail} - Job started by: ${buildUser}"
}
node {
//Setup nodeJS from nodeJS Jenkins Plugin
env.NODEJS_HOME = "${tool 'NodeJs 11.14.0'}"
env.PATH="${env.NODEJS_HOME}/bin:${env.PATH}"
try {
stage('Checkout') {
currentBuild.description = "E2E for ${params.browser}"
checkout scm
sendPerSlack('#000000', "STARTED")
}
stage('Install dependencies') {
sh "npm i"
}
stage('Perform E2E') {
withCredentials([usernamePassword(credentialsId: '30302798-a3dc-49fc-a263-3616fd24f792', passwordVariable: 'ENV_KEY', usernameVariable: 'ENV_USER')]) {
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) {
sh "./node_modules/.bin/nightwatch -c etc/nightwatch.remote.conf.js -e ${params.browser}"
}
}
}
currentBuild.result = 'SUCCESS'
} catch (e) {
currentBuild.result = 'FAILED'
throw e
} finally {
if (currentBuild.result == 'SUCCESS') {
sendPerSlack('#00FF00', "SUCCESSFUL")
} else {
sendPerSlack('#FF0000', "FAILED")
}
}
}