buildkite / agent

The Buildkite Agent is an open-source toolkit written in Go for securely running build jobs on any device or network
https://buildkite.com/
MIT License
810 stars 300 forks source link

Inline hooks #296

Open keithpitt opened 8 years ago

keithpitt commented 8 years ago

Here is a proposal to have inline hooks with a build job. So currently there a few places you can have hooks:

  1. Global hooks
  2. Per-pipeline hooks
  3. Plugin hooks

How about we have inline hooks as well, like:

steps:
  - command: "my-script.sh"
    hooks:
      environment: "echo 'run at the every beginning'"
      post-checkout: "echo 'after the code is checked out'"
      post-artifact: "echo 'run after artifacts are uploaded"

The list of hooks we could support here:

What do you think?

toolmantim commented 8 years ago

I saw that in support, and thought "my golly, that's not a bad idea at all!". I can't think of any reasons why not!

lox commented 7 years ago

This is a really neat idea. Has time changed your feels on it @keithpitt?

keithpitt commented 7 years ago

Still probably a good thing to add! Just makes working with hooks a bit easier and more explicit (instead of magical files in a folder somewhere).

Although in a new world of running stuff in Docker, I'm not sure how hooks should work in that world. Should they run inside the container? Should they run outside the container? /shurg

lox commented 7 years ago

Although in a new world of running stuff in Docker, I'm not sure how hooks should work in that world. Should they run inside the container? Should they run outside the container? /shurg

I'd say they should behave exactly like the non-inline hooks, so they wouldn't run inside a container defined in a plugin or a command. They WOULD run in a docker container if your bootstrap was running in a container.

toolmantim commented 7 years ago

Yep, I don't think anything would change if you use the docker plugin!

lox commented 6 years ago

I'm looking at the client side of this. Do these hooks override existing pipeline hooks? Or do they run in addition to? Possibly after as a new class of hook?

keithpitt commented 6 years ago

Currently global and local hooks run side by side, I'd imagine inline hooks perform the same way.

lox commented 6 years ago

How do you mean side by side? They run in order, right? global, plugin, repository, with the exception of command and checkout, which pick the most specific to run. Would we just be adding global, plugin, repository, inline?

keithpitt commented 6 years ago

Would we just be adding global, plugin, repository, inline?

Sorry, yeah that!

sj26 commented 3 years ago

Would still love to see this, it'd be amazing for prototyping and iterating on pipelines.

GMNGeoffrey commented 3 years ago

I think this is basically implemented by https://github.com/improbable-eng/metahook-buildkite-plugin

GMNGeoffrey commented 3 years ago

Except it doesn't work for checkout, which is the one I was trying to override :crying_cat_face: (https://github.com/improbable-eng/metahook-buildkite-plugin/commit/68f8f9a3e4fc381bf3c78a1485ba54937b6106f2)