Execute a step only once via manual trigger


#1

There is a use case where i would like to run cloudformation only once and not part of pipeline every time.

It would be preferred if an step could be run manually.

Does any such mechanism exists with drone 1.0 rc-4


#2

Is there any way to do this? I could also need this feature :slight_smile:


#3

We have some k8s Job type resources that we deploy and expect them to run once, never restart, and complete one time. We use Drone to manage the interpolation of env vars to a k8s manifest. The instantiation trigger is through the drone deploy verb in the CLI. We set a conditional in the .drone.yml file to only execute from this manual intervention (the actions are all automated). The condition looks like:

the YAML tabbing in the example below might be skewed. #Dragons

pipeline:
  pipeline-build-step:
    <<: *proddrone
    <<: *engscale
    <<: *deployment
    <<: *clustername
    image: our-registry/our-repo:our-tag
    commands:
      - echo "I love the smell of drone deployments in the morning"

prod_drone: &proddrone
  when:
    instance: our.prod.drone.server.xyz

engscale: &engscale
  when:
    environment: engscale

deployment: &deployment
  when:
    branch: master
    event: deployment

eng_cluster: &clustername
  when:
    matrix:
      CLUSTER: alpha-cluster
      ENV_VAR_1: env_value_1
      ENV_VAR_2: env_value_2

A Github repo owner can then execute a drone CLI command to trigger this action, like so:

drone deploy <ORG>/<REPO> <build number> <environment>

A specific example, using the .drone.yml above:

drone deploy my-org/my-awesome-app 53 engscale

If a new PR requires some action, like running a k8s Job once, we can use the drone deploy action from our workstation to trigger and monitor actions/outcomes.

Nothing else runs - we use anchors/tags in YAML to be very specific with the action and target system.

One thing we’d love to see is the ability to have Drone incorporate an import mechanism so when conditions are met, a specific “child” file could be pulled in to help keep the .drone.yml file from going beyond hundreds of lines. :slight_smile:


#4

For this you will definitely want to take a look at configuration plugins (requires 1.0). I recommend taking a look at this thread in our issue tracker, starting with the comment I linked and then viewing subsequent comments which include sample plugins that community members have begin posting.