能否通过Drone API触发Tag事件?Downstream插件仅支持Push事件
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:
Use the generic build creation API endpoint
Drone’sPOST /api/repos/{owner}/{repo}/buildsendpoint lets you define the event type in your request body. You just need to set theeventfield totagand 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" }'Ensure your downstream repo accepts Tag events
Double-check that your downstream pipeline’s.drone.ymlis 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 stepsWhy 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’sRepoCreateBuildmethod, passing aBuildstruct with theEventfield set totag.
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

