How to get tag from git repo?

Hi all
Every time, when I push changes into git repo and afterwards I tag it.

---
kind: pipeline
type: docker
name: ArgoCD CLI

steps:
  - name: Build docker image
    image: plugins/docker
    pull: if-not-exists
    settings:
      username: user
      password: password
      repo: hub.pod.example.io/devops/argcd-cli
      dockerfile: ./Dockerfile
      registry: https://hub.pod.example.io/
      tags: ${TAG_FROM_REPO}

trigger:
  branch:
    - master  

How to apply tag from git repo?

Thanks

Hi
I am not sure if you want to build on the push also or just the tags should release your docker image.
But if you just want your tag to build and push the image you should probably trigger on tag event instead of branch.

Then in your tags setting you can use the DRONE_TAG variable.

So ending up with something like this.

---
kind: pipeline
type: docker
name: ArgoCD CLI

steps:
  - name: Build docker image
    image: plugins/docker
    pull: if-not-exists
    settings:
      username: user
      password: password
      repo: hub.pod.example.io/devops/argcd-cli
      dockerfile: ./Dockerfile
      registry: https://hub.pod.example.io/
      tags: ${DRONE_TAG}

trigger:
  event:
    - tag

Environment variables are documentation

1 Like