-
Notifications
You must be signed in to change notification settings - Fork 7
/
Jenkinsfile
80 lines (70 loc) · 2.22 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
pipeline {
agent { docker { image 'node:lts' } }
stages {
stage('Build') {
steps {
sh 'rm -rf .npmrc dist node_modules'
sh 'npm ci'
}
}
stage('Analyze') {
steps {
withCredentials([string(credentialsId: 'sonarqube-analysis-token', variable: 'TOKEN')]) {
sh 'npm run sonar -- -Dsonar.host.url=https://ia-tools-sonarqube.doit.wisc.edu/ -Dsonar.login="$TOKEN"'
}
}
}
stage('Publish PR Version') {
when { changeRequest() }
environment {
PR_VERSION="PR-$env.CHANGE_ID"
}
steps {
withCredentials([[
$class: 'AmazonWebServicesCredentialsBinding',
credentialsId: 'ia-tools-jenkins-myuw-s3'
]]) {
sh 'ARTIFACT_VERSION="$PR_VERSION" node publish.js'
sh 'ARTIFACT_VERSION="unstable" node publish.js'
}
}
}
stage('Publish Release Version') {
when { branch 'master' }
steps {
withCredentials([[
$class: 'AmazonWebServicesCredentialsBinding',
credentialsId: 'ia-tools-jenkins-myuw-s3'
]]) {
sh 'node publish.js'
sh 'ARTIFACT_VERSION="latest" node publish.js'
}
}
}
stage('Tag Distributable') {
when { branch 'master' }
environment {
VERSION=sh(script: '''node -p "require('./package.json').version"''', returnStdout: true).trim()
}
steps {
sh 'git add dist --force'
sh 'git commit -m "Tagging v$VERSION-dist for $VERSION"'
sh 'git tag v$VERSION-dist'
withCredentials([string(credentialsId: 'github-api-token', variable: 'TOKEN')]) {
sh 'git push https://adi-ia-jenkins:[email protected]/myuw-web-components/myuw-drawer.git --tags'
sh 'git checkout -B gh-pages'
sh 'git push https://adi-ia-jenkins:[email protected]/myuw-web-components/myuw-drawer.git gh-pages --force'
}
}
}
stage('Publish to NPM') {
when { branch 'master' }
steps {
sh '''echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc'''
withCredentials([string(credentialsId: 'npm-token', variable: 'NPM_TOKEN')]) {
sh 'npm publish'
}
}
}
}
}