Access environment variables from forge event callback

I have a Forge app that uses the trigger module to get callbacks when issues change. I’m trying to access a set environment variable from the function that’s run from one of these event triggers, and it’s consistently undefined.

My manifest.yml looks like this:

    - key: issue-update-trigger
      function: app-issue-events-func
        - avi:jira:updated:issue
    - key: main
    - key: app-issue-events-func
      handler: index.issueUpdate

I set the variable with:

forge variables set FORGE_USER_VAR_NAME value 

And my function looks like:

import * as process from 'process';

export async function issueUpdate(data) {
  const nameVar = process.env.FORGE_USER_VAR_NAME;
  // undefined

Is it not possible to access environment variables from trigger functions?

The process object is available globally within Node.js and the Forge environment. Can you please try removing the process import - perhaps it is interfering with the one Forge provides?

1 Like