Drone exec not executing pipeline on tag event

I’m not sure what i’m doing wrong here, any help would be greatly appreciated.

Building a pipeline where certain events (like deployments) happen on tags. I’m using drone exec to test said pipeline and i can’t seem to be able to trigger any steps on tag events.

Sample Pipeline

---
name: Build
kind: pipeline


steps:
  - name: Build
    image: maven:3.6.0-jdk-11
    commands:
      - echo "Build"
    when:
      branch:
        - feature/*
        - master
  - name: Build Image
    image: docker
    commands:
      - apk add bash git make
      - echo "build image"
    when:
      branch:
        - feature/*
        - master        

---
name: Deploy
kind: pipeline

trigger:
  event: 
    - tag
  ref: 
    - rc-v*

steps:
  - name: Tag Image
    image: docker
    commands:
      - echo "tag image"

if i test a branch push event using

drone exec --branch master --event push

i can see the steps been executed

# drone exec --branch master --event push                    
[Build:0] + echo "Build"
[Build:1] Build
[Build Image:0] + apk add bash git make
[Build Image:1] fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
[Build Image:2] fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
[Build Image:3] (1/11) Installing ncurses-terminfo-base (6.1_p20190518-r0)
[Build Image:4] (2/11) Installing ncurses-terminfo (6.1_p20190518-r0)
[Build Image:5] (3/11) Installing ncurses-libs (6.1_p20190518-r0)
[Build Image:6] (4/11) Installing readline (8.0.0-r0)
[Build Image:7] (5/11) Installing bash (5.0.0-r0)
[Build Image:8] Executing bash-5.0.0-r0.post-install
[Build Image:9] (6/11) Installing nghttp2-libs (1.38.0-r0)
[Build Image:10] (7/11) Installing libcurl (7.65.1-r0)
[Build Image:11] (8/11) Installing expat (2.2.7-r0)
...

when i want to test the tag event like this

drone exec --event tag --ref rc-v0.1.09

no steps are executed. what am i doing wrong? i tried various combinations for ref like refs/tags/rc-v0.1.09 and nothing seems to be working

i’m using drone version 1.1.2 MacOsX

#drone --version
drone version 1.1.2

I see two issues.

First is that your pipeline steps are limited to master and feature/* branches. A Tag is a pointer to a commit sha and has no formal association with a branch. Your steps will therefore never execute for a branch. Consider the following modification:

    when:
-     branch:
-       - feature/*
-       - master
+     ref:
+       - refs/heads/feature/*
+       - refs/heads/master
+       - refs/tags/*

The second is that the ref format is incorrect

-rc-v0.1.09
+refs/tags/rc-v0.1.09

i think i figure out what my problem is: drone exec seems to be evaluating one single pipeline and in my case i have two of them. if i pass --pipeline Deploy to docker exec the execution is as expected.

i honestly expected that drone exec behaves similar to a drone agent in case of multiple pipelines and it will execute the first one that matches the criteria. doesn’t seem to be the case. is it by design or a bug?

doesn’t seem to be the case. is it by design or a bug?

It is by design

i honestly expected that drone exec behaves similar to a drone agent in case of multiple pipelines and it will execute the first one that matches the criteria.

It does. the agent only executes the named pipeline that the server tells it to execute. In this way the CLI behaves the same.

i see, thank you so much for the info. if you don’t mind me asking: how does the server figures out which pipeline to run?

i’m pretty sure in our setup we don’t have anything that we configure to pick the right pipeline so there must be something somewhere that figures out which pipeline to execute. all our services have multiple pipelines in a single .drone.yml

Drone has an internal fifo queue of scheduled pipelines. The server assigns a single named pipeline to an agent based on availability, and the agent then executes the named pipeline.

hmm…i don’t think we are talking about the same thing here. how does the named pipeline gets picked? or maybe i should ask: how does the server knows which named pipeline to send to the agent?

above i have two named pipelines in the same file and i definitely don’t pick which one to run, something is doing that.

if you look at my example i have two pipelines: one named Build which triggers by a push to certain branch names and one named Deploy that is triggered by a tag. so something decides…oh, the event i received from the hook is a tag event…let me see which pipeline would match event: tag AND the tag name matches"…that piece. makes sense?