This repository has been archived by the owner on Sep 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Jenkinsfile
63 lines (60 loc) · 1.8 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
node {
checkout scm
def branch = env.BRANCH_NAME.toLowerCase()
def registry = "716309063777.dkr.ecr.us-east-1.amazonaws.com"
def build = env.BUILD_NUMBER
def image
stage("Build image") {
sh 'docker build -t rabbitmq-operator .'
image = docker.image("rabbitmq-operator")
}
stage("Push image") {
docker.withRegistry("https://"+registry+"/", 'ecr:us-east-1:3c5c323b-afed-4bf0-ae1a-3b19d1c904fe') {
image.push("${branch}-${build}")
}
}
// check branch and select cluster to deploy
if (branch == 'master') {
stage ('Wait for confirmation of build promotion') {
input message: 'Is this build ready for production?', submitter: 'tekliner'
}
stage ('Deploy to production') {
writeFile file: 'operator.yaml', text: """
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: rabbitmq-operator
spec:
replicas: 1
selector:
matchLabels:
app: rabbitmq-operator
template:
metadata:
labels:
app: rabbitmq-operator
spec:
serviceAccountName: rabbitmq-operator
containers:
- name: rabbitmq-operator
image: 716309063777.dkr.ecr.us-east-1.amazonaws.com/rabbitmq-operator:${branch}-${build}
command:
- rabbitmq-operator
imagePullPolicy: Always
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: OPERATOR_NAME
value: "rabbitmq-operator"
- name: WATCH_NAMESPACE
value: ""
"""
archiveArtifacts: 'operator.yaml'
sh "kubectl apply -f operator.yaml -n messaging"
sh "kubectl apply -f deploy/deploy-operator-default/clusterrole.yaml"
}
}
}