Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Support pre/post execution hooks #820

Closed
aalmiray opened this issue Apr 22, 2022 · 1 comment
Closed

[core] Support pre/post execution hooks #820

aalmiray opened this issue Apr 22, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@aalmiray
Copy link
Member

Allow pre/post hooks for each execution step. There may be 2 types of hooks:

  1. external script or executable with args. Arguments should include:
  • event type. BEFORE or AFTER.
  • event name. matches the given step such as changelog, release, etc.
  • known values such as project name, project version, resolved tagname, basedir, and outputdir.
  1. A Java implementation of a given hook interface. Implementors will be located using the ServiceLoader interface. Callback methods should accept and event object (type, name), a read-only view of the evaluated model, basedir, and outputdir.

Loading Java hooks requires configuring the location where required JARs are placed. This location should be set in the model config file or DSL.

@aalmiray aalmiray added the enhancement New feature or request label Apr 22, 2022
@aalmiray
Copy link
Member Author

A tentative option:

hooks:
  command:
    before:
      - filter:
          include: [checksum, sign]
          exclude: [release]
        cmd: 'echo {{ event.name }} {{ event.type }} {{ projectVersion }}'
    after:
      - cmd: 'echo {{ event.name }} DONE'

I know include/exclude as stated right there makes no sense, it’s to show possible config

This setup would allow running OS commands before and after specific steps. In the case of after it will be invoked after every single step. In the case of before it will be invoked based on filters applied to the event’s name

There will be a second type of hook that will let you load a Java class, taking the event and the context as inputs. This requires setting up an isolated classpath.

Questions:

  1. Should command/script hooks be separate from Java hooks? for example, command hooks are actually "execution hooks" while Java hooks are "execution listeners". The distinction is that hooks receive explicit arguments as defined by consumers in the DSL while listeners receive the resolved model. Listeners can only be Java based.
  2. Should execution failures still trigger hooks/listeners? If so, event types should be BEFORE, AFTER, FAILURE.

@aalmiray aalmiray added this to the v1.2.0 milestone Jul 29, 2022
@aalmiray aalmiray self-assigned this Jul 29, 2022
aalmiray added a commit to jreleaser/jreleaser.github.io that referenced this issue Jul 29, 2022
aalmiray added a commit to jreleaser/jreleaser.github.io that referenced this issue Aug 3, 2022
aalmiray added a commit to jreleaser/jreleaser.github.io that referenced this issue Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant