-
Notifications
You must be signed in to change notification settings - Fork 12
/
Jenkinsfile
103 lines (88 loc) · 3.5 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
#!/usr/bin/groovy
String slackChannel = 'dpe-build-notification'
def decodedJobName = env.JOB_NAME.replaceAll("%2F", "/")
pipeline {
options {
disableConcurrentBuilds()
buildDiscarder logRotator(artifactDaysToKeepStr: '5', artifactNumToKeepStr: '5', numToKeepStr: '10')
timeout(time: 10, unit: 'MINUTES')
}
agent {
kubernetes {
yamlFile 'builderPodTemplate.yaml'
defaultContainer 'talend-tsbi-dev'
}
}
environment {
ARTIFACTORY_URL = 'https://artifactory.datapwn.com/artifactory'
PUBLIC_REPO_URL = 'https://talend.github.io/helm-charts-public'
GIT_USER = 'ci-build-dpe'
GIT_EMAIL = '[email protected]'
GIT_CREDS = credentials('github-credentials')
}
parameters {
string(name: 'CHART_NAME', defaultValue: '', description: 'Chart name + version to the internal chart to deploy (ie: dpe-remote-engine-client-1.2.0)')
string(name: 'CHART_REPO', defaultValue: 'tlnd-helm-ce-dev', description: 'The repo to use')
string(name: 'CHART_PUBLIC_FOLDER', defaultValue: 'engine', description: 'Chart root folder')
}
stages {
stage('Initialisation') {
steps {
sh '''
#! /bin/bash
set +x
echo https://$GIT_CREDS_USR:[email protected] > /tmp/.git-credentials
git config credential.helper 'store --file /tmp/.git-credentials\'
git config user.name "$GIT_USER"
git config user.email "$GIT_EMAIL"
'''
}
}
stage('Download chart') {
steps {
withCredentials([
usernamePassword(credentialsId: 'artifactory-datapwn-credentials', passwordVariable: 'ARTIFACTORY_DOCKER_PASSWORD', usernameVariable: 'ARTIFACTORY_DOCKER_LOGIN')
]) {
sh '''
mkdir -p $CHART_PUBLIC_FOLDER/$CHART_NAME
cd $CHART_PUBLIC_FOLDER/$CHART_NAME
helm pull $ARTIFACTORY_URL/$CHART_REPO/$CHART_NAME.tgz --username $ARTIFACTORY_DOCKER_LOGIN --password $ARTIFACTORY_DOCKER_PASSWORD
'''
}
}
}
stage('Update chart repo index') {
steps {
script {
env.name = "${CHART_NAME}".replace('tgz', '')
sh '''
cd $CHART_PUBLIC_FOLDER/$CHART_NAME
helm repo index --merge ../index.yaml --url $PUBLIC_REPO_URL/$CHART_PUBLIC_FOLDER/$name/ .
mv -f index.yaml ../index.yaml
'''
}
}
}
stage('Push git') {
when {
branch 'master'
}
steps {
sh '''
git checkout master
git add -A
git commit -m "Added chart $CHART_NAME/$CHART_VERSION"
git push origin master
'''
}
}
}
post {
unstable {
slackSend(color: 'warning', channel: "${slackChannel}", message: "UNSTABLE: `${decodedJobName}` #${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)")
}
failure {
slackSend(color: '#e81f3f', channel: "${slackChannel}", message: "FAILED: `${decodedJobName}` #${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)")
}
}
}