argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
18.01k stars 5.49k forks source link

Build environment variable for the resolved target revision #20768

Open eadred opened 1 week ago

eadred commented 1 week ago

Summary

Tag tracking allows us to set a target revision for a git repo or Helm chart as a range (eg 1.*). It would be useful if there were a build environment variable which contains the tag/revision which the target revision range resolved to, for example 1.2.3.

None of the existing build environment variables do this. ARGOCD_APP_SOURCE_TARGET_REVISION will be set to 1.* (in this example), and ARGOCD_APP_REVISION will be set to the commit hash (eg f913b6cbf58aa5ae5ca1f8a2b149477aebcbd9d8).

Motivation

Consider a git repo containing service code and a Helm chart, and an accompanying CI build process which builds a docker image from the service code. When tagging the repo with a release tag (eg 1.2.3) the image gets built with a tag matching the release tag.

In this case when setting a target revision like 1.* we would also need to set/override a Helm value for the image tag too. It would be useful to be able to do this with a build variable, for example:

source:
  targetRevision: 1.*
  helm:
    parameters:
      - name: imageTag
        value: "$<some build var that will resolve to 1.2.3>"

Proposal

Adding a new build environment variable called ARGOCD_APP_SOURCE_TARGET_REVISION_RESOLVED or similar, which will be set to the resolved SemVer value. If the target revision is not a SemVer range then ARGOCD_APP_SOURCE_TARGET_REVISION_RESOLVED can be set to the target revision (ie the same as ARGOCD_APP_SOURCE_TARGET_REVISION.

p7ayfu77 commented 1 week ago

Yeah, this would help us tremendously too. Would love to see this feature. It would simplify the reconciliation of artifact versions helm charts, images etc without needing to alter appset parameters via a secondary ci/cd process.

+1

sams3pi commented 1 week ago

Yeah! Would love to see this as well!