You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否通过Drone API触发Tag事件?Downstream插件仅支持Push事件

Can the Drone API Trigger Tag Events?

Great question—let me break this down based on my hands-on experience with Drone CI:

First, the short answer: Drone doesn’t have a dedicated API endpoint for triggering Tag events directly, but you can simulate a Tag event by crafting a custom build request via its generic build creation API. The downstream plugin’s limitation (only supporting Push events) is intentional, since it’s designed to propagate the current pipeline’s context—which is typically a Push event.

Here’s how to make it work:

  1. Use the generic build creation API endpoint
    Drone’s POST /api/repos/{owner}/{repo}/builds endpoint lets you define the event type in your request body. You just need to set the event field to tag and provide the necessary tag reference details.

    Example curl command (replace placeholders with your instance values):

    curl -X POST \
      https://your-drone-instance.com/api/repos/your-username/your-downstream-repo/builds \
      -H "Authorization: Bearer YOUR_DRONE_PERSONAL_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{
        "event": "tag",
        "ref": "refs/tags/v1.2.3",
        "commit": "a1b2c3d4e5f6", # The commit hash linked to your target tag
        "branch": "main",
        "title": "Triggered tag build via API",
        "message": "Initiated tag build for v1.2.3 from upstream pipeline"
      }'
    
  2. Ensure your downstream repo accepts Tag events
    Double-check that your downstream pipeline’s .drone.yml is configured to trigger on Tag events. Update the trigger section like this:

    kind: pipeline
    type: docker
    name: default
    
    trigger:
      event:
        - tag # Add this to enable tag-based triggers
        - push # Keep if you still need Push event support
    
    # ... rest of your pipeline steps
    
  3. Why you didn’t find a dedicated method in drone-go
    The official drone-go client doesn’t have a pre-built method for Tag events because this functionality is wrapped into the generic build creation logic. You can replicate the curl payload using the client’s RepoCreateBuild method, passing a Build struct with the Event field set to tag.

Alternative: Customize the downstream plugin (if preferred)

If you’d rather stick with the downstream plugin instead of calling the API directly, you’d need to fork the plugin and modify it to support passing the tag event type and reference. That said, using the API directly is usually simpler and more flexible for this specific use case.

内容的提问来源于stack exchange,提问作者jmoney

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:12:58