forked from superstreamlabs/memphis-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
106 lines (94 loc) · 3.48 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
101
102
103
104
105
106
def gitBranch = "latest"
def gitURL = "[email protected]:Memphisdev/memphis-k8s.git"
def repoUrlPrefix = "memphisos"
import hudson.model.*
import groovy.transform.Field
node {
git credentialsId: 'main-github', url: gitURL, branch: gitBranch
try{
stage('Login to Docker Hub') {
withCredentials([usernamePassword(credentialsId: 'docker-hub', usernameVariable: 'DOCKER_HUB_CREDS_USR', passwordVariable: 'DOCKER_HUB_CREDS_PSW')]) {
sh 'docker login -u $DOCKER_HUB_CREDS_USR -p $DOCKER_HUB_CREDS_PSW'
}
}
stage('Import version number from broker'){
dir('memphis-broker'){
git credentialsId: 'main-github', url: '[email protected]:memphisdev/memphis.git', branch: gitBranch
}
sh "cat memphis/version.conf > version.conf"
sh "rm -rf memphis"
}
stage('Edit helm files') {
sh"""
sed -i -r "s/memphis:[0-9].[0-9].[0-9]/memphis:\$(cat version.conf)/g" memphis/values.yaml
sed -i -r "s/[0-9].[0-9].[0-9]/\$(cat version.conf)/g" memphis/Chart.yaml
sed -i -r "s/appVersion: [0-9].[0-9].[0-9]/appVersion: \$(cat version.conf)/g" memphis/index.yaml
sed -i -r "s/version: [0-9].[0-9].[0-9]/version: \$(cat version.conf)/g" memphis/index.yaml
sed -i -r "s/[0-9].[0-9].[0-9].tgz/\$(cat version.conf).tgz/g" memphis/index.yaml
"""
}
stage('helm merge'){
dir ('charts'){
sh"helm repo index . --merge ../memphis/index.yaml"
}
}
stage('helm package'){
sh"helm package memphis -d charts"
}
stage('Install gh + jq') {
sh """
sudo yum-config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
sudo yum install gh -y
sudo yum install jq -y
"""
}
stage('Push to latest'){
withCredentials([sshUserPrivateKey(keyFileVariable:'check',credentialsId: 'main-github')]) {
//sh "git reset --hard origin/master" //change to latest
sh"""
GIT_SSH_COMMAND='ssh -i $check' git add charts/memphis-*
GIT_SSH_COMMAND='ssh -i $check' git commit -m "Version \$(cat version.conf)" -a
GIT_SSH_COMMAND='ssh -i $check' git push --set-upstream origin latest
"""
}
withCredentials([string(credentialsId: 'gh_token', variable: 'GH_TOKEN')]) {
sh """
gh release create v\$(cat version.conf) --generate-notes --target latest
"""
}
}
stage('Checkout to version branch'){
withCredentials([sshUserPrivateKey(keyFileVariable:'check',credentialsId: 'main-github')]) {
sh"""
GIT_SSH_COMMAND='ssh -i $check' git checkout -b \$(cat version.conf)
GIT_SSH_COMMAND='ssh -i $check' git push --set-upstream origin \$(cat version.conf)
"""
}
}
stage('Merge to gh-pages'){
}
notifySuccessful()
}
catch (e) {
currentBuild.result = "FAILED"
cleanWs()
notifyFailed()
throw e
}
}
def notifySuccessful() {
emailext (
subject: "SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':
Check console output and connection attributes at ${env.BUILD_URL}""",
recipientProviders: [requestor()]
)
}
def notifyFailed() {
emailext (
subject: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':
Check console output at ${env.BUILD_URL}""",
recipientProviders: [requestor()]
)
}