Manually trigger a build

Heyo! Is there any way to trigger a build manually? I’m building some internal tools for my company and we’d like to integrate with the existing drone API to manually create builds. Ideally, is there an API that supports passing a commit or branch name to start such build?

1 Like

You can control the build with event type deployment by drone cli drone deploy

http://docs.drone.io/promoting-builds/

Hey Bill — yeah, but that’s not exactly what I’m looking for. Let’s say that I want to drone to be idle on my repo, and I manually trigger which commits or branch to build. Would that be possible?

What I was thinking here is… maybe I could just “fake” the GitHub WebHook push event, but I would still need a way to tell drone not to build any commits except the ones requested. Crazy huh?

Ideally, not sure if there would need any necessary code for that on your end — but if some APIs were exposed (such as the deployment one I couldn’t find) and add the ability to trigger specific build steps, that would get me very very close!

When you deploy, you are essentially “promoting” a build, which means you need to provide the build number you are promoting, and the environment you are promoting to. For example:

drone build promote octocat/hello-world 42 production

In the above example, you are promoting build 42 to production. This will execute a deployment event in the system with environment name production. I recommend the following article, which might be a useful resource http://docs.drone.io/promoting-builds/

1 Like

I have a repo that has a .drone.yml in it, but I haven’t built it yet. I don’t want to change the repo, but I want to trigger a build. I can’t do a drone deploy because there haven’t been any builds yet to deploy. Is there a way to do this?

I have a repo that has a .drone.yml in it, but I haven’t built it yet. I don’t want to change the repo, but I want to trigger a build.

The only way to trigger a build is via webhook, so you would have to push a commit to trigger a build. Perhaps consider adding the badge to your README which would give you an excuse to modify the repository, and thus trigger a build :slight_smile:

http://docs.drone.io/badges/

Alternatively if you just want to test your yaml configuration, I recommend using the command line utility, which allows you to test locally using the drone exec command.

Thanks. I was looking for a way to run the build locally earlier.

Badges are cool, so I’ll go ahead and put the badge on there. :slight_smile:

@bradrydzewski is it possible to manually trigger a build from branch name instead of build_id?

1 Like

There are API endpoints for this starting with Drone 1.2.0 and higher. See https://github.com/drone/drone/issues/2679#issue-435262568

1 Like

Everything was fine but today we found out that pushing to master branch does not trigger the pipeline.
I tried using drone build API on a specific commit but still got nothing.
I got the following log from server:
drone-server | {"commit":"a14bxxxxx","error":"","event":"push","level":"warning","msg":"trigger: cannot find yaml","ref":"refs/heads/master","repo":"abc/xyz","time":"2019-07-28T10:33:17Z"}
Why server says cannot find yaml ?!

@bradrydzewski would you please help me on this issue?

cannot find yaml means the API request to get your .drone.yml returned an error. You will need to look at your version control system logs (i.e. gogs, gitea, gitlab logs) to see why it returned an error. It is not something I can tell you.

Thank you. We are using gitlab. I’ll check it to see what i can get from.

When I test webhook I got this from gitlab Hook execution failed: Net::ReadTimeout and the status of webhook in Integration settings of gitlab is internal error with blank response header and body.
I just disabled and re-activated the repository and now everything back to normal.

It would be nice to have such a button in the graphical user interface.

3 Likes

existing issue at https://github.com/drone/drone-ui/issues/298

1 Like