9

There are build environment variables (https://argoproj.github.io/argo-cd/user-guide/build-environment/) so can inject something like $ARGOCD_APP_NAME on the application/helm yaml file and it resolves to the actual value.

Is there a way we can set custom environment variables so it can be resolved on the argocd application yaml file?

For example on below argocd application yaml, need to set the ENV value so helm can know which values.yaml to use.

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
    ...
spec:
    ...
    source:
       ...
        helm:
            valueFiles:
                - values_${ENV}.yaml
2
  • did you ever get this working ? Commented May 16, 2021 at 21:54
  • Hi @Sirex, so we ended up having different branches per environment, like the targetRevision field under Application yaml refers to the branch name. This way also, to promote changes from one env to another, we could just raise a pull request from one env branch to another. Commented May 19, 2021 at 5:30

1 Answer 1

2

It's a late answer, but you can. You can use the plugin field to add the ENV variables in the application level, the example follows:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  ...
spec:
  ...
  source:
    plugin:
      env:
          - name: ENV_VARIABLE
            value: ENV_VALUE
Sign up to request clarification or add additional context in comments.

1 Comment

When using Helm this won't going to work. Error form ArgoCD: rpc error: code = Unknown desc = multiple application sources defined: Helm,Plugin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.