-
Notifications
You must be signed in to change notification settings - Fork 1
/
JenkinsfileRelease
116 lines (102 loc) · 2.72 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
pipeline {
parameters {
gitParameter name: 'branch',
description: 'The branch to check out',
branchFilter: 'origin/(.*)',
defaultValue: 'main',
selectedValue: 'DEFAULT',
type: 'PT_BRANCH',
listSize: '0',
quickFilterEnabled: true
string name: 'ReleaseVersion',
description: 'Version to release',
defaultValue: ''
text name: 'ReleaseDescription',
description: 'Release description',
defaultValue: ''
booleanParam name: 'PreRelease',
description: 'This is a pre-release. Will not publish to npm if selected ',
defaultValue: true
string name: 'auth',
description: 'Jenkins credential ID'
}
agent {
label 'graphdb-jenkins-node'
}
tools {
nodejs 'nodejs-14.17.0'
}
options {
disableConcurrentBuilds()
timeout(time: 15, unit: 'MINUTES')
timestamps()
}
environment {
NPM_TOKEN = credentials('npm-token')
API_URL = "https://github.com/Ontotext-AD/ontotext-yasgui.git"
AUTH = credentials("${auth}")
}
stages {
stage ('Checkout branch') {
steps {
sh "git checkout ${branch}"
}
}
stage ('Update version') {
steps {
script {
if (params.PreRelease == false) {
sh 'npm run version-all ${ReleaseVersion}'
}
}
}
}
stage ("Installing ontotext-yasgui") {
steps {
sh 'npm install yarn'
sh 'npm install'
}
}
stage ("Building ontotext-yasgui") {
steps {
sh "npm run build"
}
}
stage ('Publishing ontotext-yasgui') {
steps {
// Publish on npm
script {
if (params.PreRelease == false) {
sh 'npm run publish ${NPM_TOKEN}'
}
}
}
}
}
post {
success {
script {
if (params.PreRelease == false) {
// 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 "rm -f .npmrc"
}
}
}