Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Enabling

JS Hooks

JavaScript Hooks for a repository

The first time that a repository administrator opens the

JS Hooks

JavaScript Hooks page for the repository

they'll be prompted to enable JS Hooks for the repository. This will enable the repository hook automatically. If for some reason the Repository Hooks are disabled through the Hooks

, they will be shown "Enable" buttons that can be clicked to enable one or more of the three available types of JavaScript Hooks. Items enabled will only be enabled for that specific repository.

Image Added

If for some reason a type of JavaScript Hooks are disabled via this configuration screen, the administrator will be

repromted.Image RemovedImage Removed

shown the "Enable" buttons again for the specific JavaScript Hooks not currently enabled.

 

Writing a

Javascript

JavaScript hook

Writing a

Javascript hook is

JavaScript hook can be quite simple.

Simply click on "

 Click Add Hook

"

on the repository

JS Hook

JavaScript hook page and you'll be presented with a

screen for your editing. Each Hook will require a name and the script itself.As part of the editing experience, you can select a changes (or a pull request in the

configuration screen.

At any point, click on the "Javascript function and objects available" link to see what is available to you.

Image Added

 

From this screen:

  1. Give the hook a name
  2. Add the script for the hook into the "Script code" area.
  3. Select a change (or pull request, in case of a merge check) to run against.
    1. This will run your actual
Javascript
    1. JavaScript code against the particular item as if it was "live". At the end of the run you can see if there was an error with your code and which of the external
api
    1. API calls were called (and what the arguments passed to them were).
Once saved - the hook becomes
  1. Click Save.

The hook is now active.

At

 At any point, though, you can disable the hook from the repository view page.

Image Removed

 

Troubleshooting