Cannot execute a pipeline on either tag or push to specific branch

Consider this pipeline:

# Build a release when tagging
kind: pipeline
name: deploy
depends_on:
  - testing

workspace:
  base: /srv/app
  path: src/code.vikunja.io/api

clone:
  depth: 50

trigger:
  branch:
    - master
  event:
    - push
    - tag

steps:
...

It only triggers when a push to master occures, not when I push a tag. The logs say:

{"commit":"c6f188745e9f07123ba7096f6b2e5de3af667c52","event":"tag","level":"info","msg":"trigger: skipping pipeline, does not match branch","pipeline":"deploy","ref":"refs/tags/v0.6","repo":"vikunja/api","time":"2019-01-15T13:31:30Z"}

So it looks like this does not work because Drone only runs the pipeline when all conditions are met as opposed to either a push to a specific branch or a tag (like it was in drone 0.8.x).

Is this a bug in drone or is there a way to let a pipeline execute on either a tag push or push to a specific branch?

This is the expected behavior and is not considered a bug. We are planning to add additional trigger parameters, such as ref which could then be used to solve this problem:

trigger:
  ref:
  - refs/heads/master
  - refs/tags/*

Alternatively you can always create multiple pipelines and use something like jsonnet to eliminate duplicate code in the your configuration.

---
kind: pipeline
name tag

trigger:
  event: [ tag ]

---
kind: pipeline
name branch

trigger:
  branch: [ master ]
  event: [ push ]

Ok, I’ll look into jsonnet, thanks!

I tried this method in drone v1.2.1 version on my server, tag is not working , the logs still say:

but on the cloud.drone.io , the method work well.

What is the difference between the two?Is it what configuration I missed? thanks.

In order to provide support we require the following, unedited information:

  1. the full yaml
  2. the results of drone build info <repo> <build> for your build
  3. your provider (github, gogs, etc)

The full yaml are as follows:

---
kind: pipeline
name: drone

steps:
  - name: restore-cache  
    image: drillster/drone-volume-cache  
    settings:  
      restore: true  
      mount:  
        - ./node_modules  
    volumes:  
      - name: cache  
        path: /cache  

  - name: install
    image: node
    commands:
      - sh ./build/pre-install.sh

  - name: build
    image: node
    commands:
      - yarn build

  - name: rebuild-cache  
    image: drillster/drone-volume-cache  
    settings:  
      rebuild: true  
      mount:    
        - ./node_modules  
    volumes:  
      - name: cache  
        path: /cache

trigger:
  ref:
  - refs/heads/master
  - refs/tags/*

volumes:
  - name: cache
    host:
      path: /var/drone-cache

in my server, drone build info are as follows:

Get 45.76.84.10/api/repos/Damo-web/docs/builds/latest: unsupported protocol scheme ""

Here’s the github webhook post that was sent:

my server

Request Headers:

Request URL: http://45.76.84.10/hook
Request method: POST
content-type: application/json
Expect: 
User-Agent: GitHub-Hookshot/71faf64
X-GitHub-Delivery: bdf785e4-905a-11e9-84a8-2b85956b87e0
X-GitHub-Event: push
X-Hub-Signature: sha1=741231cf304b08cdbb0f1dd9492f64f95f0f6faf

Request Payload:

{
 "ref": "refs/tags/v1.0.1",
 "before": "0000000000000000000000000000000000000000",
 "after": "2969e2181514b78854334f1a462393ea371357d8",
 "created": true,
 "deleted": false,
 "forced": false,
 "base_ref": null,
 "compare": "https://github.com/Damo-web/docs/compare/v1.0.1",
 "commits": [

 ],
 "head_commit": {
   "id": "2969e2181514b78854334f1a462393ea371357d8",
   "tree_id": "a4d84356f93f2d106a5badd43ca418f3d09443dc",
    ...
  },
 ...
}

Response Headers ( 200 ):

Cache-Control: no-cache, no-store, must-revalidate, private, max-age=0
Connection: keep-alive
Content-Length: 5
Content-Type: application/json
Date: Sun, 16 Jun 2019 17:18:22 GMT
Expires: Thu, 01 Jan 1970 00:00:00 UTC
Pragma: no-cache
Server: nginx/1.17.0
X-Frame-Options: DENY
X-Xss-Protection: 1; mode=block

Response Body:

null

drone cloud server

Request Headers:

Request URL: https://cloud.drone.io/hook
Request method: POST
content-type: application/json
Expect: 
User-Agent: GitHub-Hookshot/71faf64
X-GitHub-Delivery: bdf785e4-905a-11e9-84a8-2b85956b87e0
X-GitHub-Event: push
X-Hub-Signature: sha1=acb069024dcb1c6057293faa3ea0975f609ec590

Request Payload:

{
 "ref": "refs/tags/v1.0.1",
 "before": "0000000000000000000000000000000000000000",
 "after": "2969e2181514b78854334f1a462393ea371357d8",
 "created": true,
 "deleted": false,
 "forced": false,
 "base_ref": null,
 "compare": "https://github.com/Damo-web/docs/compare/v1.0.1",
 "commits": [

 ],
 "head_commit": {
   "id": "2969e2181514b78854334f1a462393ea371357d8",
   "tree_id": "a4d84356f93f2d106a5badd43ca418f3d09443dc",
    ...
  },
 ...
}

Response Headers ( 200 ):

Cache-Control: no-cache, no-store, must-revalidate, private, max-age=0
Content-Length: 731
Content-Type: application/json
Date: Sun, 16 Jun 2019 17:18:22 GMT
Expires: Thu, 01 Jan 1970 00:00:00 UTC
Pragma: no-cache
Strict-Transport-Security: max-age=315360000
X-Accel-Expires: 0
X-Frame-Options: DENY
X-Xss-Protection: 1; mode=block

Response Body:

{"id":77779,"repo_id":214059,"trigger":"","number":197,"status":"error","error":"linter: untrusted repositories cannot mount host volumes","event":"tag","action":"create","link":"https://github.com/Damo-web/docs/compare/v1.0.1","timestamp":0,"message":":wrench: update config","before":"0000000000000000000000000000000000000000","after":"2969e2181514b78854334f1a462393ea371357d8","ref":"refs/tags/v1.0.1","source_repo":"","source":"","target":"","author_login":"snowball1990","author_name":"snowball1990","author_email":"[email protected]","author_avatar":"https://avatars2.githubusercontent.com/u/44635219?v=4","sender":"snowball1990","started":0,"finished":1560705502,"created":1560705502,"updated":1560705502,"version":1}

“error”,“error”:“linter: untrusted repositories cannot mount host volumes”

this error indicated that you are mounting host machine volumes in your yaml, but you do not have adequate permission to do so. This is a trusted operation and requires that the repository trusted flag is set to true.

See Linter: untrusted repositories cannot mount host volumes

Thanks for your reply!

I know this error on the drone cloud server, but i can not get machine access to run build.I try to install and run drone on my own server, and the question of trusted repository is solved.

The difference between drone cloud server and my own server is that refs/tags/* is not working on my server. The push event is working,but tag event only work well on the drone cloud server.

on my server, the logs say:

{“commit”:“ae409411ac0ab5f8d0261cc8389a86e9918b623c”,“event”:“tag”,“level”:“info”,“msg”:“trigger: skipping pipeline, does not match branch”,“pipeline”:“drone”,“ref”:“refs/tags/v1.0.3”,“repo”:“Damo-web/docs”,“time”:“2019-06-16T13:48:19Z”}

I tried to run drone cloud server and my own server under the same repo,response body of the github webhook post are not the same. The response body of my own server is null.

I don’t understand the difference between my own server and drone cloud server. I think they should be consistent.