-
Notifications
You must be signed in to change notification settings - Fork 16
/
JenkinsfileRelease
98 lines (84 loc) · 2.3 KB
/
JenkinsfileRelease
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
pipeline {
tools {
nodejs 'nodejs-20.11.1'
}
parameters {
gitParameter name: 'branch',
description: 'The branch to check out',
branchFilter: 'origin/(.*)',
defaultValue: 'master',
selectedValue: 'DEFAULT',
type: 'PT_BRANCH',
listSize: '0',
quickFilterEnabled: true
string name: 'ReleaseVersion',
description: 'Version to release',
defaultValue: ''
}
agent {
label 'graphdb-jenkins-node'
}
options {
disableConcurrentBuilds()
timeout(time: 15, unit: 'MINUTES')
timestamps()
}
environment {
CI = "true"
NPM_TOKEN = credentials('npm-token')
// Needed for our version of webpack + newer nodejs
NODE_OPTIONS = "--openssl-legacy-provider"
}
stages {
stage ('Prepare') {
steps {
// Switch to branch
sh "git checkout ${branch}"
// Change versions
sh "npm version --git-tag-version=false ${ReleaseVersion}"
dir("test-cypress/") {
sh "npm version --git-tag-version=false ${ReleaseVersion}"
}
// Install
sh "npm ci"
// Build
sh "npm run build"
}
}
stage ('Publish') {
steps {
// Publish on npm
sh "echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc && npm publish"
// Publish cypress tests on npm
dir("test-cypress/") {
sh "echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc && npm publish"
}
}
}
}
post {
success {
// Commit, tag and push the changes in Git
sh "git commit -a -m 'Release ${ReleaseVersion}'"
sh "git tag -a v${ReleaseVersion} -m 'Release v${ReleaseVersion}'"
sh "git push --set-upstream origin ${branch} && git push --tags"
}
failure {
wrap([$class: 'BuildUser']) {
emailext(
to: env.BUILD_USER_EMAIL,
from: "Jenkins <[email protected]>",
subject: '''[Jenkins] $PROJECT_NAME - Build #$BUILD_NUMBER - $BUILD_STATUS!''',
mimeType: 'text/html',
body: '''${SCRIPT, template="groovy-html.template"}'''
)
}
}
always {
sh "git checkout .npmrc"
dir("test-cypress/") {
sh "rm .npmrc"
}
}
}
}