forked from scm-manager/website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
89 lines (79 loc) · 2.08 KB
/
Jenkinsfile
File metadata and controls
89 lines (79 loc) · 2.08 KB
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
#!/usr/bin/env groovy
def version = 'UNKNOWN'
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
}
agent {
node {
label 'docker'
}
}
stages {
stage('Environment') {
steps {
script {
def commitHashShort = sh(returnStdout: true, script: 'git rev-parse --short HEAD')
version = "${new Date().format('yyyyMMddHHmm')}-${commitHashShort}".trim()
}
}
}
stage('Docker') {
agent {
node {
label 'docker'
}
}
steps {
script {
withCredentials([usernamePassword(credentialsId: 'cesmarvin-github', passwordVariable: 'GITHUB_API_TOKEN', usernameVariable: 'GITHUB_ACCOUNT')]) {
docker.withRegistry('', 'hub.docker.com-cesmarvin') {
def image = docker.build("scmmanager/website:${version}", "--build-arg GITHUB_API_TOKEN=${GITHUB_API_TOKEN} .")
image.push()
}
}
}
}
}
stage('Deployment Staging') {
when {
branch 'develop'
}
agent {
docker {
image 'lachlanevenson/k8s-helm:v3.2.1'
args '--entrypoint=""'
}
}
steps {
withCredentials([file(credentialsId: 'helm-client-scm-manager', variable: 'KUBECONFIG')]) {
sh "helm upgrade --install --values=deployment/staging.yml --set image.tag=${version} staging-website deployment/website"
}
}
}
stage('Deployment Production') {
when {
branch 'master'
}
agent {
docker {
image 'lachlanevenson/k8s-helm:v3.2.1'
args '--entrypoint=""'
}
}
steps {
withCredentials([file(credentialsId: 'helm-client-scm-manager', variable: 'KUBECONFIG')]) {
sh "helm upgrade --install --set image.tag=${version} website deployment/website"
}
}
}
stage('Trigger API Build') {
when {
branch 'master'
}
steps {
build job: 'scm-manager-github/plugin-center-api/master', wait: false
}
}
}
}