# Allow Drone to deploy Running Builds

**URL:** <https://drone.discourse.group/t/allow-drone-to-deploy-running-builds/9255>\
**Category:** Drone Support\
**Created:** [March 28, 2018, 3:59pm UTC](https://drone.discourse.group/t/allow-drone-to-deploy-running-builds/9255 "2018-03-28T15:59:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fbcbarbosa](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/fbcbarbosa/32/3770_2.png) [@fbcbarbosa](https://drone.discourse.group/u/fbcbarbosa)\
**Post date:** [March 28, 2018, 3:59pm UTC](https://drone.discourse.group/t/allow-drone-to-deploy-running-builds/9255/1 "2018-03-28T15:59:24Z")

</div>

To sum it up, would it be ok to remove [Line 500 here](https://github.com/drone/drone/blob/master/server/build.go#L500) and allow the `drone deploy` CLI to deploy a still running build?

Let me explain my use case:

I’d like to start using the “deployment” event so developers have a simple way for triggering a deployment manually. So far so good. But, in _some cases_, I’d like for the deployment to happen _automatically_.

_Also_ I’d like to use the deployment API so I have access to the $DRONE\_DEPLOY\_TO variable, and can configure my deployments dynamically. That’s really important because I have some pipelines which deploy multiple applications to multiple environments, and without an “environment” variable I need to configure `Nenvironmnets X Napplications` deployment steps.

One solution I’ve come up with is to trigger a deployment event as part of the pipeline:

```auto
# just an example, didn't test it out with the drone/cli image specifically
trigger: 
  image: drone/cli
  commands:
     - drone deploy fbcbarbosa/myrepo $DRONE_BUILD_NUMBER staging
  environment:
    - DRONE_SERVER=foo
    - DRONE_TOKEN=bar
  when:
    event: push
    branch: master

# plugin to deploy on a DCOS cluster
deploy:
  image: 'quintoandar/drone-marathon'
  server: 'http://my-dcos-cluster.$DRONE_DEPLOY_TO.quintoandar.com.br'
  marathonfile: $DRONE_DEPLOY_TO/marathon.yml
  when:
    event: deployment

```

However, I’m getting this error:

```auto
client error 500: cannot restart a build with status running

```

If I use “last” instead of $DRONE\_BUILD\_NUMBER, I’d get the _previous_ build, which is not really what I’m aiming for here.

I assume the same could be achieved if we had a more advanced conditional logic (e.g. replay this deploy step with this particular set of environment variables), but given the current Drone capabilities this seems like the best option.
