forked from dpac90/vivid-design-patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.publish
79 lines (68 loc) · 2.47 KB
/
Jenkinsfile.publish
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
def GIT_CREDENTIALS='github-username-and-token-as-password'
pipeline {
agent {
kubernetes {
label 'vivid-design-patterns-publish'
idleMinutes 2
yamlFile 'jenkins/kubernetes/build-pod-publish.yaml'
defaultContainer 'node'
}
}
environment {
GITHUB_AUTH = vault path: "jenkins/master", key: "GITHUB_TOKEN", engineVersion: "1"
NPM_AUTH = vault path: "ext/npm", key: "NPM_AUTH", engineVersion: "1"
}
parameters {
choice(choices: ['patch', 'minor', 'major'], description: 'What kind of change are you publishing? Major changes are breaking changes. Minor changes are new features, eg. new components, and patches are bug fixes on components. For more information, visit: https://semver.org/', name: 'SEM_VER_TYPE')
}
stages {
stage('Prepare git environment') {
steps {
sendSlackNotification(buildStatus: "Publishing ${params.SEM_VER_TYPE} update to Vivid Design Patterns", channel: "#eng-team-b2c")
withCredentials([
usernamePassword(
credentialsId: GIT_CREDENTIALS,
passwordVariable: 'GITHUB_TOKEN',
usernameVariable: 'GITHUB_USERNAME')]) {
sh """
git config --replace-all user.email ${env.GITHUB_USERNAME}@vividseats.com
git config --replace-all user.name ${env.GITHUB_USERNAME}
git config credential.helper store
echo https://${env.GITHUB_USERNAME}:${env.GITHUB_TOKEN}@github.com >> \$HOME/.git-credentials
"""
}
}
}
stage('Install dependencies') {
steps {
sh "yarn install"
}
}
stage('Publish') {
steps {
sh "./login.sh"
sh "yarn publish --new-version ${params.SEM_VER_TYPE}"
}
}
stage('Push version change') {
steps {
sh "git push origin HEAD:master --follow-tag"
}
}
stage('Generate Changelog') {
steps {
sh "yarn changelog"
sh "git add CHANGELOG.md"
sh "git commit -m 'Post publish change-log generation commit'"
sh "git push origin HEAD:master --follow-tag"
}
}
}
post {
always {
script {
sendSlackNotification(buildStatus: currentBuild.currentResult, channel: "#eng-team-b2c")
}
}
}
}