forked from molgenis/molgenis-ui-form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
126 lines (119 loc) · 3.54 KB
/
Jenkinsfile
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
pipeline {
agent {
kubernetes {
label 'node-carbon'
}
}
stages {
stage('Prepare') {
steps {
script {
env.GIT_COMMIT = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()
}
container('vault') {
script {
env.TUNNEL_IDENTIFIER = sh(script: 'echo ${GIT_COMMIT}-${BUILD_NUMBER}', returnStdout: true)
env.GITHUB_TOKEN = sh(script: 'vault read -field=value secret/ops/token/github', returnStdout: true)
env.CODECOV_TOKEN = sh(script: 'vault read -field=molgenis-ui-form secret/ops/token/codecov', returnStdout: true)
env.SAUCE_CRED_USR = sh(script: 'vault read -field=username secret/ops/token/saucelabs', returnStdout: true)
env.SAUCE_CRED_PSW = sh(script: 'vault read -field=value secret/ops/token/saucelabs', returnStdout: true)
env.NPM_TOKEN = sh(script: 'vault read -field=value secret/ops/token/npm', returnStdout: true)
}
}
container('node') {
sh "daemon --name=sauceconnect -- /usr/local/bin/sc -u ${SAUCE_CRED_USR} -k ${SAUCE_CRED_PSW} -i ${TUNNEL_IDENTIFIER}"
}
}
}
stage('Build: [ pull request ]') {
when {
changeRequest()
}
steps {
container('node') {
sh "yarn install"
sh "yarn unit"
sh "yarn e2e --env ci_chrome,ci_safari,ci_ie11,ci_firefox"
}
}
post {
always {
container('node') {
sh "curl -s https://codecov.io/bash | bash -s - -c -F unit -K"
}
}
}
}
stage('Build: [ master ]') {
when {
branch 'master'
}
steps {
milestone 1
container('node') {
sh "yarn install"
sh "yarn unit"
sh "yarn e2e --env ci_chrome,ci_safari,ci_ie11,ci_firefox"
}
}
post {
always {
container('node') {
sh "curl -s https://codecov.io/bash | bash -s - -c -F unit -K"
}
}
}
}
stage('Release: [ master ]') {
when {
branch 'master'
}
environment {
REPOSITORY = 'molgenis/molgenis-ui-form'
}
steps {
timeout(time: 30, unit: 'MINUTES') {
script {
env.RELEASE_SCOPE = input(
message: 'Do you want to release?',
ok: 'Release',
parameters: [
choice(choices: 'patch\nminor\nmajor', description: '', name: 'RELEASE_SCOPE')
]
)
}
}
milestone 2
container('node') {
sh "git remote set-url origin https://${GITHUB_TOKEN}@github.com/${REPOSITORY}.git"
sh "git checkout -f ${BRANCH_NAME}"
sh "npm config set unsafe-perm true"
sh "npm version ${RELEASE_SCOPE} -m '[ci skip] [npm-version] %s'"
sh "git push --tags origin ${BRANCH_NAME}"
sh "echo //${env.NPM_REGISTRY}/:_authToken=${NPM_TOKEN} > ~/.npmrc"
sh "npm publish"
hubotSend(message: '${env.REPOSITORY} has been successfully deployed on ${env.NPM_REGISTRY}.', status:'SUCCESS')
}
}
}
}
post {
always {
container('node') {
sh "daemon --name=sauceconnect --stop"
}
}
success {
notifySuccess()
}
failure {
notifyFailed()
}
}
}
def notifySuccess() {
hubotSend(message: 'Build success', status:'INFO', site: 'slack-pr-app-team')
}
def notifyFailed() {
hubotSend(message: 'Build failed', status:'ERROR', site: 'slack-pr-app-team')
}