Deploy Argo CD
Synchronizes an existing Argo CD Application from a GitLab pipeline and waits for the application to become Synced and Healthy.
include:
- component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/deploy-argocd@$CI_COMMIT_SHA
inputs:
application: my-app
server: argocd.example.com
token-variable: ARGOCD_AUTH_TOKEN
The component uses the argocd CLI from the ci-tools tools image, reads the token from ARGOCD_AUTH_TOKEN, and runs argocd app sync only when automated sync is not enabled on the Application. It always waits for Synced and Healthy unless wait-enabled: false is set.
Set insecure: true for internal or self-signed Argo CD API servers where certificate validation is intentionally skipped.
Setup
Create a dedicated Argo CD local account for GitLab CI and allow it to read and sync the target Applications.
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-cm
namespace: argocd
data:
accounts.gitlab-ci: apiKey
---
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-rbac-cm
namespace: argocd
data:
policy.csv: |
p, role:gitlab-deploy, applications, get, default/my-app, allow
p, role:gitlab-deploy, applications, sync, default/my-app, allow
g, gitlab-ci, role:gitlab-deploy
Generate a token with argocd account generate-token --account gitlab-ci and store it as the masked CI/CD variable ARGOCD_AUTH_TOKEN. Set ARGOCD_SERVER or the component server input to the Argo CD API server hostname.
Inputs
| Name | Description | Default | Type |
| --- | --- | --- | --- |
| application | The Argo CD Application name. | string | |
| insecure | Skip Argo CD server TLS certificate verification. | false | boolean |
| needs | The jobs that this job depends on. | [] | array |
| rules | Rules that control when the deployment job runs. | [{"if":"$CI_PIPELINE_SOURCE == \"schedule\"","when":"never"},{"if":"$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH","when":"on_success"},{"when":"never"}] | array |
| server | Argo CD API server. Defaults to ARGOCD_SERVER when unset. | string | |
| stage | The pipeline stage for the deployment job. | deploy | string |
| sync-enabled | Run an explicit Argo CD sync before waiting. | true | boolean |
| tag | Runner tag for the deployment job. | string | |
| timeout | Timeout for sync and wait operations. | 15m | string |
| token-variable | Environment variable that contains an Argo CD auth token. | ARGOCD_AUTH_TOKEN | string |
| wait-enabled | Wait for the Argo CD Application to become synced and healthy. | true | boolean |