-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
100 lines (91 loc) · 2.72 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
pipeline {
agent {
kubernetes {
// Change the name of jenkins-maven label to be able to use yaml configuration snippet
label "maven-gke-preemtible"
// Inherit from Jx Maven pod template
inheritFrom "maven"
// Add scheduling configuration to Jenkins builder pod template
yamlFile "gke-preemptible.yaml"
}
}
environment {
RELEASE_BRANCH = "master"
ORG = "introproventures"
APP_NAME = "aps"
CHARTMUSEUM_CREDS = credentials("jenkins-x-chartmuseum")
}
stages {
stage("CI Build and push snapshot") {
when {
branch "PR-*"
}
environment {
PREVIEW_VERSION = "0.0.0-SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER"
PREVIEW_NAMESPACE = "$APP_NAME-$BRANCH_NAME".toLowerCase()
HELM_RELEASE = "$PREVIEW_NAMESPACE".toLowerCase()
}
steps {
container("maven") {
dir("preview") {
// Let's build preview chart
sh "make preview"
// Let create preview environment
sh "jx preview --app $APP_NAME"
}
}
}
}
stage("Build Release") {
when {
branch "$RELEASE_BRANCH"
}
steps {
// Working directory name must match with chart name
container("maven") {
dir("$APP_NAME") {
// ensure we're not on a detached head
sh "make checkout"
// so we can retrieve the version in later steps
sh "make next-version"
// Let's build first
sh "make build"
// Let's test chart
sh "make test"
// Let's make tag in Git
sh "make tag"
// Publish release to Github
sh "make changelog"
// Release Helm chart in Chartmuseum
sh "make release"
}
}
}
}
stage("Promote to Environments") {
when {
branch "$RELEASE_BRANCH"
}
environment {
GITHUB_REPO_NAME = "aps-chart"
GITHUB_CHARTS_REPO = "https://github.com/${ORG}/${GITHUB_REPO_NAME}.git"
PROMOTE_HELM_REPO_URL = "https://${ORG}.github.io/${GITHUB_REPO_NAME}"
}
steps {
container("maven") {
dir("$APP_NAME") {
// Let's publish in Github Charts Repo
sh "make github"
// Let's promote to environments
sh "make promote"
}
}
}
}
}
post {
always {
cleanWs()
}
}
}