Command Hooks

Defines command or script hooks to be executed before or after a JReleaser step.

Legend:

  • required

  • optional

  • may use environment variable

  • accepts Name Templates

  • YAML

  • TOML

  • JSON

  • Maven

  • Gradle

# 
hooks:
  # Enable or disable all hooks.
  # Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
  # Defaults to `ALWAYS`.
  # 
  active: ALWAYS

  # 
  command:
    # Enable or disable all before, success, and failure hooks.
    # Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
    # Defaults to `ALWAYS`.
    # 
    active: ALWAYS

    # The type of hook
    # Valid entries are `before`, `success`, `failure`.
    # 
    before:
        # Let the release continue if the hook fails.
        # Defaults to `false`.
        # 
      - continueOnError: true

        # Enable or disable this hook.
        # Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
        # Defaults to `ALWAYS`.
        # 
        active: ALWAYS

        # The command to be invoked.
        #  
        cmd: '{{basedir}}/notifier.sh {{event.name}} {{event.type}} {{projectVersion}}'

        # Filters this hook based on the given step.
        # 
        filter:
          includes: ['release']
          excludes: ['publish']
# 
[hooks]
  # Enable or disable all hooks.
  # Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
  # Defaults to `ALWAYS`.
  # 
  active = "ALWAYS"

  # 
  [hooks.command]
    # Enable or disable all before, success, and failure hooks.
    # Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
    # Defaults to `ALWAYS`.
    # 
    active = "ALWAYS"

    # The type of hook
    # Valid entries are `before`, `success`, `failure`.
    # 
    
      # Let the release continue if the hook fails.
      # Defaults to `false`.
      # 
      continueOnError = true

      # Enable or disable this hook.
      # Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
      # Defaults to `ALWAYS`.
      # 
      active = "ALWAYS"

      # The command to be invoked.
      #  
      cmd = "{{basedir}}/notifier.sh {{event.name}} {{event.type}} {{projectVersion}}"

      # Filters this hook based on the given step.
      # 
      filter.includes = ["release"]
      filter.excludes = ["publish"]
{
  // 
  "hooks": {
    // Enable or disable all hooks.
    // Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
    // Defaults to `ALWAYS`.
    // 
    "active": "ALWAYS",

    // 
    "command": {
      // Enable or disable all before, success, and failure hooks.
      // Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
      // Defaults to `ALWAYS`.
      // 
      "active": "ALWAYS",

      // The type of hook
      // Valid entries are `before`, `success`, `failure`.
      // 
      "before": [
        {
          // Let the release continue if the hook fails.
          // Defaults to `false`.
          // 
          "continueOnError": true,

          // Enable or disable this hook.
          // Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
          // Defaults to `ALWAYS`.
          // 
          "active": "ALWAYS",

          // The command to be invoked.
          //  
          "cmd": "{{basedir}}/notifier.sh {{event.name}} {{event.type}} {{projectVersion}}",

          // Filters this hook based on the given step.
          // 
          "filter": {
            "includes": ["release"],
            "excludes": ["publish"]
          }
        }
      ]
    }
  }
}
<jreleaser>
  <!--
    
  -->
  <hooks>
    <!--
      Enable or disable all hooks.
      Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
      Defaults to `ALWAYS`.
      
    -->
    <active>ALWAYS</active>

    <!--
      
    -->
    <command>
      <!--
        Enable or disable all before, success, and failure hooks.
        Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
        Defaults to `ALWAYS`.
        
      -->
      <active>ALWAYS</active>

      <!--
        The type of hook
        Valid entries are `before`, `success`, `failure`.
        
      -->
      <before>
        <commandHook>
          <!--
            Let the release continue if the hook fails.
            Defaults to `false`.
            
          -->
          <continueOnError>true</continueOnError>
          <!--
            Enable or disable this hook.
            Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
            Defaults to `ALWAYS`.
            
          -->
          <active>ALWAYS</active>

          <!--
            The command to be invoked.
             
          -->
          <cmd>{{basedir}}/notifier.sh {{event.name}} {{event.type}} {{projectVersion}}</cmd>

          <!--
            Filters this hook based on the given step.
            
          -->
          <filter>
            <includes>release</include>
            <excludes>publish</excludes>
          </filter>
        </commandHook>
      </before>
    </command>
  </hooks>
</jreleaser>
jreleaser {
  // 
  hooks {
    // Enable or disable all hooks.
    // Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
    // Defaults to `ALWAYS`.
    // 
    active = 'ALWAYS'

    // 
    command {
      // Enable or disable all before, success, and failure hooks.
      // Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
      // Defaults to `ALWAYS`.
      // 
      active: ALWAYS

      // The type of hook
      // Valid entries are `before`, `success`, `failure`.
      // 
      before {
        // Let the release continue if the hook fails.
        // Defaults to `false`.
        // 
        continueOnError = true

        // Enable or disable this hook.
        // Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
        // Defaults to `ALWAYS`.
        // 
        active = 'ALWAYS'

        // The command to be invoked.
        //  
        cmd = "{{basedir}}/notifier.sh {{event.name}} {{event.type}} {{projectVersion}}"

        // Filters this hook based on the given step.
        // 
        filter {
          includes = ["release"]
          excludes = ["publish"]
        }
      }
    }
  }
}
When not explicitly set, the value of active may be resolved from an environment variable JRELEASER_HOOKS_COMMAND_ACTIVE or from a system property jreleaser.hooks.command.active. The system property takes precedence over the environment variable.

Step Names

The following step names may be used when filtering hooks:

  • download

  • assemble

  • changelog

  • checksum

  • sign

  • upload

  • release

  • prepare

  • package

  • publish

  • announce

Template Names

The following template names are also available:

{{event.type}}

One of [before, success, failure].

{{event.name}}

One of the previously mentioned steps.