Last updatedJul 22, 2020

Rate this page:

Extending your app with a scheduled trigger

You can configure a scheduled trigger for your existing app to repeatedly invoke a function on a scheduled interval.

This guide assumes you have an app with a function that you would like to trigger on a schedule. If you haven’t already created a function, see Getting started for step-by-step instructions on setting up Forge and creating your first app.

Add a web trigger

To develop your function, create a temporary web trigger to invoke your function manually while testing. Add a web trigger to your manifest.yml as follows:

1
2
3
4
modules:
  webtrigger:
    - key: temporary-development-webtrigger
      function: '<your-function-key>'

Deploy and install your app

You'll need to redeploy your app to add the web trigger module. If this is the first time you're deploying your app, you'll also need to install the app on an Atlassian site.

  1. Navigate to the app's top-level directory and deploy your app by running:

    1
    forge deploy
  2. Install your app by running:

    1
    forge install
    1. Select your Atlassian product using the arrow keys and press the enter key.

      Note: Running forge install command installs your app in all available Atlassian products on the site. You don’t need to run the command for each product.

    2. Enter the URL for your development site. For example, example.atlassian.net.

    3. Open the authorization URL in your default browser from the CLI by pressing any key.
    4. Review the app's requested access.
    5. Select your Atlassian cloud site from the Authorize for list, then select Accept.

Develop your app using the web trigger

Iterate through your function’s development by invoking the function using the web trigger.

Note that the event parameter does not have a value for scheduled triggers, so you should avoid referencing it in your function.

  1. Get the web trigger URL by running:

    1
    forge webtrigger
  2. Start your app using the tunnel to get fast feedback without needing to redeploy. Run the following command:

    1
    forge tunnel
  3. Make a request to the URL provided above in a web browser or using the curl utility.

Note, forge tunnel is only available in the development environment. See the environment restrictions on the Environments for details.

Add a scheduled trigger and remove the web trigger

Once you have completed development of the function, you can add a scheduled trigger to your manifest.yml:

1
2
3
4
5
modules:
  scheduledTrigger:
    - key: my-scheduled-trigger
      function: '<your-function-key>'
      interval: hour

While debugging, you can keep using the web trigger and scheduled trigger. When you’re done, you can remove the web trigger module from the manifest file.

To make your changes permanent, redeploy your app using the forge deploy command.

Rate this page: