Post Function

Post function #

You can use the post function to perform additional actions after a transition is executed. You can the advantage of full Jira Cloud REST API: https://developer.atlassian.com/cloud/jira/platform/rest/v3/

Post functions are webassembly functions (WASM). You can write your own post function and deploy it to Extensions for Jira Workflow app. Extensions for Jira Workflow app will execute your post function when the issue transition is executed.

We have example code repo that you can use to get started:

Inside example project you can find

  • AssemblyScript code that interact with Jira issue (fetch issue data, create comment)
  • functions that perform arbitrary calculations and data manipulation
  • Bitbucket pipeline example that builds and deploy your post function to the Extensions for Jira Workflow app.

Wiring up your post function to the Extensions for Jira Workflow app includes 3 steps.

  1. Create a new post function in the Extensions for Jira Workflow app
  2. Deploy your post function to the Extensions for Jira Workflow app
  3. Pick your post function in the Jira workflow transition

1. Create a new post function #

create-post-function.png From top menu select “Apps” and click “Manage Apps” button. From side menu select “Extensions for Jira Workflow” and click “create new” link.

new-post-function-form.png Save id and secret, you will need them to deploy your post function.

2. Deploy your post function #

Example with curl. Replace $FUNCTION_ID and $DEPLOYMENT_SECRET with your values or provide them as environment variables.

curl https://app.workflow-jira.com/deploy/$FUNCTION_ID \
-H "Content-Type: application/wasm" \
-H "Authorization: Bearer $DEPLOYMENT_SECRET" \
--data-binary @build/release.wasm

Example with Bitbucket pipeline:

    # ...
    # Step example
    - step:
        trigger: manual
        image: curlimages/curl-base:8.5.0
        name: Deploy
        script:
          - >-
            curl https://app.workflow-jira.com/deploy/$FUNCTION_ID \
               -H "Content-Type: application/javascript" \
               -H "Authorization: Bearer $SECRET_TOKEN" \
               --data-binary @build/release.wasm            
    # ...

bitbucket-repo-vars.png

3. Pick your post function in the Jira workflow transition #

  • Edit your Jira workflow.
  • Pick transition. Open Post Functions tab.
  • Click “Add post functions” tab. jira-transition-post-function.png
  • Choose “Custom Post Function” custom-post-function-to-transition.png
  • Pick your post function from the list and “Add” it. select-defined-postfunction.png
  • And the result should look like this: custom-postfunction-on-the-list.png

Do not forget to publish your workflow changes with “Publish Draft” button.