agent icon indicating copy to clipboard operation
agent copied to clipboard

Inline hooks

Open keithpitt opened this issue 9 years ago • 12 comments

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:

  • environment
  • pre-checkout
  • checkout
  • post-checkoutt
  • pre-command
  • ~~command~~
  • post-command
  • pre-artifact
  • post-artifact

What do you think?

keithpitt avatar Apr 30 '16 01:04 keithpitt

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!

toolmantim avatar Apr 30 '16 05:04 toolmantim

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

lox avatar Nov 04 '17 01:11 lox

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

keithpitt avatar Nov 06 '17 00:11 keithpitt

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.

lox avatar Nov 06 '17 00:11 lox

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

toolmantim avatar Nov 06 '17 02:11 toolmantim

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?

lox avatar Jan 30 '18 03:01 lox

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

keithpitt avatar Jan 30 '18 04:01 keithpitt

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?

lox avatar Jan 30 '18 04:01 lox

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

Sorry, yeah that!

keithpitt avatar Jan 30 '18 04:01 keithpitt

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

sj26 avatar Jul 06 '21 05:07 sj26

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

GMNGeoffrey avatar Aug 26 '21 22:08 GMNGeoffrey

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)

GMNGeoffrey avatar Aug 26 '21 22:08 GMNGeoffrey