Building using alternative drone.yml

Hello Drone team,

Is there a way to do a build with an alternative .drone.yml?

When building our nightlies we publish artifacts to Sonatype and can do this via the tooling infrastructure for Scala. According to previous answers I googled up - we should use the drone command in combination with cron to do scheduled events.

Basically for nightlies we’d have a yml file like:

      - sbt publishSigned -secret-key="..." -moar-define="..."

It would be a bonus if we could actually take the latest successful build and apply the deploy to it. Storing secrets in Drone is possible for our usecase if the deploy part has to be a part of the public .drone.yml.


EDIT: drone 0.5

You can retrieve the latest successful build using either the Drone API or the Drone CLI.

You can then use the build number of this build to trigger a Drone deploy event: drone deploy {org}/{project} {buildNumber} {target}. As the target you could specify ‘nightly’.
Then add a step to your .drone.yml file containing a deploy step for your nightlies and make sure you add this to the step’s conditions:

  event: deployment
  environment: nightly

I think this will do exactly what you want, if you combine it with a scheduled cron job.

1 Like

Thanks! This seems to be exactly what I needed. Passwords managed by drone secrets and this build step is triggered by the cron job.


Just to add to the excellent advice from @mjwwitt, you can get the latest build number for a repository and branch using the following command:

$ drone build last --format="{{ .Number }}" --branch=master foo/bar

This could be combined with the deploy command for use in a cron job:

drone deploy foo/bar ${drone build last --format="{{ .Number }}" --branch=master foo/bar} nightly