-
Notifications
You must be signed in to change notification settings - Fork 5
/
Jenkinsfile
110 lines (108 loc) · 4.78 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
107
108
109
110
def ORG = "mayadataio"
def REPO = "kubera-charts"
pipeline {
agent {
label {
label ""
customWorkspace "/var/lib/jenkins/workspace/charts/"
}
}
stages {
stage('test') {
steps {
script {
sh "pwd && helm lint kubera-classic/ && helm lint kubera-enterprise/"
TAG = sh(returnStdout: true, script: "git tag --contains").trim()
sh "echo ${TAG}"
}
}
}
stage('publish charts ') {
steps {
script {
if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME == '3.0' ) {
withCredentials([usernamePassword( credentialsId: 'dd46bd83-0e93-492b-bc43-fcb671b135c3', usernameVariable: 'user', passwordVariable: 'pass')]) {
sh """
sed 's/name: kubera-enterprise/name: kubera-enterprise-ci/g' -i ./kubera-enterprise/Chart.yaml
helm package ./kubera-classic
helm package ./kubera-enterprise
helm package ./solution_guides/percona-openebs
git clone https://${user}:${pass}@github.com/mayadata-io/${REPO}.git
cd ${REPO}
git checkout gh-pages
mkdir tmp
mv ../*.tgz ./tmp
helm repo index --url http://asset.mayadata.io/charts/ --merge ./index.yaml tmp
mv tmp/index.yaml .
aws s3 cp ./tmp/ s3://asset.mayadata.io/charts/ --recursive --acl public-read
rm -rf tmp
git add .
git commit -m "release new charts"
git push https://${user}:${pass}@github.com/mayadata-io/${REPO}.git --all
"""
}
}
}
}
}
stage('Build for tag release') {
steps {
echo "Workspace dir is ${pwd()}"
script {
withCredentials([usernamePassword( credentialsId: 'dd46bd83-0e93-492b-bc43-fcb671b135c3', usernameVariable: 'user', passwordVariable: 'pass')]) {
if (TAG) {
sh """
sed 's/tag: master-ci/tag: ${TAG}/g' -i ./kubera-enterprise/values.yaml
helm package ./kubera-classic
helm package ./kubera-enterprise
git clone https://${user}:${pass}@github.com/mayadata-io/${REPO}.git
cd ${REPO}
git checkout gh-pages
mkdir tmp
mv ../*.tgz ./tmp
helm repo index --url http://asset.mayadata.io/charts/ --merge ./index.yaml tmp
mv tmp/index.yaml .
aws s3 cp ./tmp/ s3://asset.mayadata.io/charts/ --recursive --acl public-read
rm -rf tmp
git add .
git commit -m "release new charts"
git push https://${user}:${pass}@github.com/mayadata-io/${REPO}.git --all
"""
}
}
}
}
}
}
post {
always {
echo 'This will always run'
deleteDir()
}
success {
echo 'This will run only if successful'
// slackSend channel: '#jenkins-builds',
// color: 'good',
// message: "The pipeline ${currentBuild.fullDisplayName} completed successfully :dance: :thumbsup: "
}
failure {
echo 'This will run only if failed'
// slackSend channel: '#jenkins-builds',
// color: 'RED',
// message: "The pipeline ${currentBuild.fullDisplayName} failed. :scream_cat: :japanese_goblin: "
}
unstable {
echo 'This will run only if the run was marked as unstable'
// slackSend channel: '#jenkins-builds',
// color: 'good',
// message: "The pipeline ${currentBuild.fullDisplayName} is unstable :scream_cat: :japanese_goblin: "
}
changed {
/* slackSend channel: '#jenkins-builds',
color: 'good',
message: "Build ${currentBuild.fullDisplayName} is now stable :dance: :thumbsup: "
echo 'This will run only if the state of the Pipeline has changed'
*/ echo 'For example, if the Pipeline was previously failing but is now successful'
}
}
}