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

Drone CI流水线无法被GitHub部署事件触发求助

Troubleshooting Drone Pipeline Not Triggered by GitHub Deployment Events

Let's break down why your Drone pipeline isn't firing on GitHub deployment events—even though the webhook is delivering successfully with a 204 response. Here are the key checks and fixes to try:

1. Verify Drone's Enabled Events Configuration

First, confirm your Drone server is set to process deployment events. Some installations might restrict enabled events via environment variables. If you're running Drone via Docker, check your startup command for the DRONE_ENABLED_EVENTS flag. It should explicitly include deployment, like:

docker run ... -e DRONE_ENABLED_EVENTS=push,pull_request,deployment ...

If this variable is missing or doesn't list deployment, Drone will ignore those events entirely.

2. Validate Your .drone.yml When Condition Syntax

YAML is strict about indentation—double-check that your when block is formatted correctly. The correct structure for triggering on deployment events is:

kind: pipeline
type: docker
name: default

steps:
  - name: build
    image: alpine
    commands:
      - echo "Building..."
    when:
      event: deployment

If you have indentation errors (e.g., extra spaces before event) or placed the condition in the wrong section, Drone won't recognize it. Also, ensure the condition is applied at the step level or root pipeline level (to apply to all steps).

3. Check Deployment Payload Details & Matching Conditions

Your GitHub deployment payload uses ref: "master", but:

  • If your .drone.yml includes a branch restriction in the when block (e.g., branch: main), it will filter out the master deployment event.
  • Some Drone versions require an explicit environment match. Try updating your JSON payload to include an environment:
    {
      "ref": "master",
      "auto_merge": false,
      "payload": "{}",
      "description": "this is test deployment from Jenkins pipeline",
      "environment": "test"
    }
    
    Then update your .drone.yml to match:
    when:
      event: deployment
      environment: test
    

4. Inspect Drone Server Logs for Clues

This is the most critical step—Drone's logs will tell you exactly why the event was rejected. For Docker deployments, run:

docker logs <your-drone-server-container-id>

Look for lines mentioning "deployment"—you might see errors like:

  • event not allowed (if deployment events aren't enabled)
  • branch not matched (if your branch restriction doesn't align with the payload)
  • signature invalid (if your webhook secret doesn't match between GitHub and Drone)

5. Confirm Webhook Secret & GitHub Permissions

Even though GitHub shows a 204 response, a mismatched webhook secret can cause Drone to silently discard the event. Double-check that the secret in GitHub's webhook settings matches Drone's DRONE_GITHUB_SECRET environment variable.

Also, ensure your Drone GitHub OAuth app has the repo_deployment permission:

  1. Go to your GitHub App settings
  2. Under Permissions > Repository permissions, set Deployments to "Read-only" or higher

6. Test with a Simplified Pipeline

Temporarily replace your .drone.yml with a minimal test pipeline to rule out complex step configurations:

kind: pipeline
type: docker
name: test-deployment-trigger

steps:
  - name: test
    image: alpine
    commands:
      - echo "Deployment event triggered!"
    when:
      event: deployment

Push this simplified config and re-run your GitHub deployment API call. If it triggers, the issue was with your original pipeline's conditions or steps.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 04:01:12