forked from rcarrata/devsecops-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
task-argo-sync-and-wait.yaml.j2
45 lines (41 loc) · 1.45 KB
/
task-argo-sync-and-wait.yaml.j2
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
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: argocd-task-sync-and-wait
namespace: cicd
labels:
app.kubernetes.io/version: "0.1"
annotations:
tekton.dev/pipelines.minVersion: "0.12.1"
tekton.dev/tags: deploy
tekton.dev/displayName: "argocd"
spec:
description: >-
This task syncs (deploys) an Argo CD application and waits for it to be healthy.
To do so, it requires the address of the Argo CD server and some form of
authentication either a username/password or an authentication token.
params:
- name: application-name
description: name of the application to sync
- name: revision
description: the revision to sync to
default: HEAD
- name: flags
default: --
- name: argocd-version
default: v2.2.5
stepTemplate:
envFrom:
- configMapRef:
name: argocd-env-configmap # used for server address
- secretRef:
name: argocd-env-secret # used for authentication (username/password or auth token)
steps:
- name: login-sync-wait
image: quay.io/rcarrata/argocd:$(params.argocd-version)
script: |
if [ -z $ARGOCD_AUTH_TOKEN ]; then
yes | argocd login $ARGOCD_SERVER --username=$ARGOCD_USERNAME --password=$ARGOCD_PASSWORD ;
fi
argocd app sync $(params.application-name) --revision $(params.revision) $(params.flags) && sleep 3
argocd app wait $(params.application-name) --health $(params.flags)