Force a build on a certain branch

Hi,

I like Drone, but the dependency to Github is a little bit annoying today.

It would be great to have a button to push a build on a branch and so on. Right now the webhooks in Github are turned off and my CI system is on hold and I cannot deploy Bugfixes.

Is this already possible?

Sebastian

Hi Sebastian,

You can trigger a build using the API by sending an http Request that is compatible with the GitHub payload. You can do so with the following:

  1. copy paste an existing github webhook (via github settings)
  2. modify the webhook payload to use the preferred sha, branch, etc
  3. post the webhook to the webhook address (copy pasted from github, must include token)
  4. make sure the posted webhook includes relevant header variables (X-GitHub-Event)

you could get slightly more sophisticated by:

  1. use the github API to get commit details by branch
  2. use these details to build the webhook payload
  3. send the webhook payload to drone

You could write a small command-line utility and share with the community. I’m sure others would find such a utility useful.

drone-send-hook \
  --branch=master \
  --repo=octocat/hello-world \
  --token=$GITHUB_TOKEN \
  --target=$DRONE_WEBHOOK_URL

You could even add a --poll flag that polls GitHub for changes so that you do not have to manually trigger builds …

1 Like

I think it is easier to do it on the drone cli, I mean use drone cli as you would to restart a build, if no build number is used, assume a new build.

drone build start {repo/name} -branch {branch}

No need to webhook at all, you are already authenticated, most of the code is already there, just allow a new build to start, could use a branch or a commit number

There is currently no code (across the 5 providers, github, bitbucket, stash, gitea and gogs) to fetch commit details via API and trigger a build. The only way to do this today is via a mocked webhook message. We have some code in place in the next planned release that may enable this capability in the future, but that won’t help you with today’s outage … if you want an immediate workaround, mocking a webhook is your only option.

I am sorry, but probably there is something I am missing. By your suggestion, drone only seems to need the repo and the branch name. To solve today issue, one could only need to trigger a build on a branch, something like drone pulling the code from the requested branch and start a build, Again, I am probably missing the ‘details’ but a blind build from the requested branch is not feasible?