Script Variables — User Guide & GitHub Integration Examples
Script Variables provide encrypted, tenant-scoped storage for sensitive configuration data, API keys, and Personal Access Tokens (PATs). Instead of hardcoding credentials in your scripts, store them securely in Script Variables and retrieve them dynamically at runtime.
Steps to Use Script Variables
Step 1: Create and Store a Variable
- Open ScriptFabric → Script Variables in Jira Cloud.
- Click Create Variable.
- Enter a Key (e.g.
GITHUB_TOKEN). - Enter the Value (e.g. your GitHub Personal Access Token
ghp_your_secret_pat). - Toggle Secret to encrypt the value at rest and mask it in the admin UI.
- Click Save.
Step 2: Retrieve the Variable Inside the Execution Console
Use the built-in getVariable() function available in all script execution contexts:
const token = await getVariable("GITHUB_TOKEN");
if (!token) {
return 'Error: GITHUB_TOKEN is missing in Script Variables';
}
Step 3: Use the Variable in API Calls & Integrations
Pass the decrypted token to your client or API headers:
// Authenticate GitHub client using stored token
const token = await getVariable("GITHUB_TOKEN");
git.token = `${token}`;
const me = await git.getMe();
return me;
GitHub API Integration Examples
1. Fetch Complete Issue Details
Instead of returning a single field (such as issue.body), return the complete issue object to inspect all metadata:
const token = await getVariable("GITHUB_TOKEN");
git.token = `${token}`;
// Fetch complete issue object from workspace and repository
const issue = await git.getIssue(
"Canarys-Internal-apps",
"Jira_Github_MCP",
2
);
return issue;
2. Create a Pull Request with Realistic Parameters
Pass realistic workspace, repository, and branch parameters when creating a pull request:
const token = await getVariable("GITHUB_TOKEN");
git.token = `${token}`;
// Create Pull Request with working branch and target main branch
const newPR = await git.createPR(
"Canarys-Internal-apps",
"Jira_Github_MCP",
{
title: "Fix authentication token validation in Forge app",
head: "feature-branch",
base: "main",
body: "Resolves token validation issue and updates error handling."
}
);
return newPR;
3. Fetch Comprehensive Pull Request Details
Retrieve complete pull request metadata (author, state, mergeability, branches, timestamps, and URL) instead of returning only merge status:
const token = await getVariable("GITHUB_TOKEN");
git.token = `${token}`;
// Fetch PR #3 from repository
const pr = await git.getPR(
"Canarys-Internal-apps",
"Jira_Github_MCP",
3
);
return {
number: pr.number,
title: pr.title,
body: pr.body,
state: pr.state,
mergeable: pr.mergeable,
merged: pr.merged,
author: pr.user?.login,
sourceBranch: pr.head?.ref,
targetBranch: pr.base?.ref,
createdAt: pr.created_at,
updatedAt: pr.updated_at,
url: pr.html_url
};
Security & Scoping
- Encryption at Rest: Variable values are encrypted using AES-256 before being saved in Forge storage.
- UI Masking: Secret variables display as
••••••••in the administrative UI. - Tenant Scope: Variables are scoped strictly to your Jira Cloud site installation.
- Admin Control: Only Jira administrators can create, update, or delete Script Variables.