[Fixed] Deploy with build number - can't work with my schedule task


Why I need to run schedule task separately via drone command line to drone server?

Because currently drone server doesn’t support schedule job.

The problem.

I can get build job list to a particular repository (via API /api/repos/:owner/:name/builds or drone cli), but seems only latest 50 jobs mixed with push and deployment events. When the schedule task runs every hour, build number easily increased to hundreds of deploy jobs, which I can’t find out the first available build job (push event) on master branch.

I set a schedule task to

(1) get latest build number from master branch. I need exclude all deployment event builds first. support this build number is 50, and it is a push event.
(2) Schedule task runs for one week every hour, generate 168 deployment event build. So the latest build number is 218.
(3) there is no update in last week.

Then the schedule task can’t find out what’s the latest push event build number, because drone build list command only list latest 50 builds, they are all deployment event build, not push event build. For deploy, drone cli need a build number to run with.

drone deploy --branch master <owner>/<name> 50 development-apply

So can we simplify the deploy command, if provide the option of --branch, always build from the latest commit from that branch? So I needn’t provide the build number every time.

Even if you can provide a command to get a full list of build numbers, it is not effective, because the schedule job can easily go up to thousands and more.

Integrated cron scheduling is planned for an upcoming release of the enterprise edition. Stay tuned for future announcements.

Thanks for the updating, even it is for Enterprise version only.

But regarding the drone deploy option, could you make it smarter to defaultly pick up the latest commit from the branch if I nominated.

You can use drone build last --branch=foo to get the last branch from the database. You can then pass this build number to the drone deploy command, like this:

See http://readme.drone.io/questions/how-to-schedule-builds/ for a full example.

1 Like

That’s what I am looking for. Thanks a lot.

drone build last --branch=master <owner/repo>