-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1
44 lines (40 loc) · 1.79 KB
/
1
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
#!/usr/bin/env groovy
properties([
parameters([
choice(choices: ['stg-config','iwt-config'], description: 'Which Environment?', name: 'EKSCONFIG'),
string(defaultValue: "stg", description: 'Which Git Branch to clone?', name: 'GIT_BRANCH'),
string(defaultValue: "1", description: 'AWS ECR Repository where built docker images will be pushed.', name: 'DEPLOYMENT_REPLICAS'),
[$class: 'ChoiceParameter', choiceType: 'PT_SINGLE_SELECT', description: 'Select Docker Image Tag to deploy.', name: 'IMAGETAG', script: [$class: 'GroovyScript', script: [script: '''def choices=[]
textFile= new File("/var/lib/jenkins/workspace/CD/ctx-oauth-CD/DOCKER_TAGS")
textFile.eachLine{
choices.add(it)
}
return choices''']]]
])
])
try
{
node('master'){
stage('Clone Gitlab CD repo'){
cleanWs()
checkout([$class: 'GitSCM', branches: [[name: '*/master']], userRemoteConfigs: [[credentialsId: 'gitlab-admin',url: 'https://gitlab.ctx.com.sg/cd/staging.git']]])
}
stage('Deploy on STG K8s') {
sh "sed -i 's|DEPLOYMENT_REPLICAS|${DEPLOYMENT_REPLICAS}|g' oauth/*.yaml"
sh "sed -i 's|TAG|${IMAGETAG}|g' oauth/*.yaml"
sh "sed -i 's|SERVICE_INSTANCE_NAME|${SERVICE_INSTANCE_NAME}|g' oauth/*.yaml"
if ( "${EKSCONFIG}" == 'iwt-config'){
sh "sed -i 's|stg|iwt|g' oauth/*.yaml"
}
withEnv(["KUBECONFIG=${JENKINS_HOME}/.kube/${EKSCONFIG}"]){
echo "Deploying Docker Tag ${IMAGETAG} for stg-ctx-oauth ..."
sh "kubectl apply -f ctx-oauth"
}
currentBuild.displayName = "${IMAGETAG} ($EKSCONFIG)"
}
}
}
catch (err){
currentBuild.result = "FAILURE"
throw err
}