-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathargocd-app-create.jenkinsfile
37 lines (32 loc) · 1.21 KB
/
argocd-app-create.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
// argocd app create and sync
pipeline {
agent any
parameters {
string(name : 'application_name', defaultValue : 'helloworld-jenkins', description : 'application name')
}
environment {
ARGOCD_NAMESPACE = "argo"
}
stages {
stage('initalize repo') {
steps {
withCredentials([usernamePassword(credentialsId: 'argocd-cred', passwordVariable: 'password', usernameVariable: 'username')]) {
sh """
echo "y" | argocd login ${argocd_url} --username ${username} --password ${password} --insecure
if argocd app get ${ARGOCD_NAMESPACE}/${params.application_name} | grep "NotFound":
then
echo "argocd app ${params.application_name} does not exist. create argocd app ${params.application_name}"
argocd app create ${params.application_name} \
--repo https://github.com/argocd-manifest-test/demo_application2.git \
--path . \
--dest-namespace default \
--dest-server https://kubernetes.default.svc
fi
echo "argocd app sync ${params.application_name}"
argocd app sync ${params.application_name}
"""
}
}
}
}
}