-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
69 lines (60 loc) · 2.33 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
#!groovy
properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '7', numToKeepStr: ''))])
// Branch names
DEV_BRANCH = 'development'
MASTER_BRANCH = 'master'
node {
stage("Clean workspace") {
deleteDir()
}
stage("Checkout") {
checkout scm
}
stage("Run CI?") {
sh "git log -1 --pretty=%B > commitMessage"
commitMessage = readFile 'commitMessage'
if (commitMessage.contains('[skip ci]')) {
echo "Skipping CI"
currentBuild.result = 'SUCCESS'
}
}
if (currentBuild.result != 'SUCCESS') {
stage("Install dependencies & build") {
sh "npm install"
}
stage("Run tests") {
withCredentials([string(credentialsId:'ConnectionString', variable: 'CONNECTION_STRING')]) {
withCredentials([string(credentialsId:'SchemaName', variable: 'SCHEMA_NAME')]) {
withCredentials([string(credentialsId:'PermissionsServiceUrl', variable: 'PERMISSIONS_SERVICE_URL')]) {
sh "npm t"
}
}
}
}
stage("Pre publish") {
withCredentials([string(credentialsId:'GitHubToken', variable: 'GITHUB_TOKEN')]) {
sh "git remote add pub https://enigmatis324:[email protected]/enigmatis/polaris-united.git -f"
}
withCredentials([string(credentialsId:'NpmToken', variable: 'NPM_TOKEN')]) {
sh 'echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc'
}
sh "git config --global user.email '[email protected]' && git config --global user.name 'Jenkins Agent'"
sh "git checkout --track pub/${env.BRANCH_NAME}"
}
stage("Lerna publish") {
withCredentials([string(credentialsId:'GitHubToken', variable: 'GITHUB_TOKEN')]) {
if (env.BRANCH_NAME == MASTER_BRANCH) {
echo "release branch: ${env.BRANCH_NAME}"
sh "npm run publish"
}
if (env.BRANCH_NAME == DEV_BRANCH) {
echo "release branch: ${env.BRANCH_NAME}"
sh "npm run publish-beta"
}
}
}
}
stage("Clean workspace") {
deleteDir()
}
}