Forum Discussion
jontwy
Jun 16, 2021Copper Contributor
Setting ENV in pipeline
We have a devops setup where when we set a new tag in Azure Repos, it sets off a docker image build in Azure pipelines and passes the image over to Docker Hub. I have been asked to automate the final...
jontwy
Jun 16, 2021Copper Contributor
Just an update, I actually managed to figure this out. In the Dockerfile I added the following:
ARG REPO_TAG
ENV APP_VERSION=$REPO_TAG
In the azure-pipeline.yml I added:
arguments: --build-arg REPO_TAG=$(tag)
This then placed the Repo tag in the ARG REPO_TAG and then on build this REPO_TAG variable was placed into the ENV APP_VERSION on build of the image.
ARG REPO_TAG
ENV APP_VERSION=$REPO_TAG
In the azure-pipeline.yml I added:
arguments: --build-arg REPO_TAG=$(tag)
This then placed the Repo tag in the ARG REPO_TAG and then on build this REPO_TAG variable was placed into the ENV APP_VERSION on build of the image.