Environment Variables#
Securely store configuration values, API keys, and secrets for use in your scripts.
Overview#
Environment Variables in Automan allow you to:
- Store sensitive data like API keys and tokens securely
- Configure scripts without hardcoding values
- Change configuration without modifying script code
- Share common values across multiple scripts
Variables are stored securely in Atlassian’s infrastructure and are accessible
to all scripts through process.env.
Accessing Environment Variables#
- Navigate to
Apps>Automan - Click on the Environment tab
Creating a Variable#
- Click Add Variable button
- Enter the variable details:
- Name - Variable name (used to access it in scripts)
- Value - The value to store
- Secret - Check to mask the value in the UI
- Click Save
Naming Rules#
Variable names must follow these rules:
- Start with a letter (a-z, A-Z) or underscore (_)
- Contain only letters, numbers, and underscores
- Maximum 64 characters
- Case-sensitive (
API_KEYandapi_keyare different)
Valid Names#
API_KEYwebhook_url_internal_settingMyVariable123
Invalid Names#
123variable(can’t start with number)my-variable(no hyphens)my variable(no spaces)
Secret Variables#
When you mark a variable as secret:
- The value is hidden in the UI (shown as
•••••) - The value is still fully accessible in scripts
- Use for API keys, tokens, passwords, and other sensitive data
Using Variables in Scripts#
Access environment variables through process.env:
// Access a variable
const apiKey = process.env.API_KEY;
// Check if variable exists
if (!process.env.WEBHOOK_URL) {
console.log("WEBHOOK_URL not configured");
return;
}
// Use in API calls
const webhookUrl = process.env.WEBHOOK_URL;
console.log("Sending to webhook:", webhookUrl);Example: External API Integration#
const apiKey = process.env.EXTERNAL_SERVICE_API_KEY;
const baseUrl = process.env.EXTERNAL_SERVICE_URL;
if (!apiKey || !baseUrl) {
throw new Error("Missing required environment variables");
}
// Use the configuration
console.log(`Connecting to ${baseUrl}...`);Example: Configurable Behavior#
// Use environment variables for configuration
const maxRetries = parseInt(process.env.MAX_RETRIES || "3", 10);
const defaultAssignee = process.env.DEFAULT_ASSIGNEE_ID;
const debugMode = process.env.DEBUG_MODE === "true";
if (debugMode) {
console.log("Debug mode enabled");
console.log("Max retries:", maxRetries);
}Editing a Variable#
- Click on the variable row in the list
- Modify the value (for secret variables, enter the new value)
- Click Save
Note: For secret variables, the current value is not shown. You must enter the complete new value.
Deleting a Variable#
- Click the delete icon (trash) on the variable row
- Confirm the deletion
Warning: Deletion is immediate and permanent. Scripts using this variable will fail or have undefined behavior until you add the variable back.
Common Use Cases#
API Keys and Tokens#
// Store external service credentials
const slackToken = process.env.SLACK_BOT_TOKEN;
const githubToken = process.env.GITHUB_ACCESS_TOKEN;
const serviceApiKey = process.env.MY_SERVICE_API_KEY;User Account IDs#
// Store Atlassian account IDs for auto-assignment
const teamLeadId = process.env.TEAM_LEAD_ACCOUNT_ID;
const qaLeadId = process.env.QA_LEAD_ACCOUNT_ID;
const defaultReviewerId = process.env.DEFAULT_REVIEWER_ID;
// Use in auto-assignment
await requestJira(
route`/rest/api/3/issue/${issueKey}`,
{
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
fields: {
assignee: { accountId: teamLeadId }
}
})
}
);Webhook URLs#
// Store webhook endpoints
const slackWebhook = process.env.SLACK_WEBHOOK_URL;
const teamsWebhook = process.env.TEAMS_WEBHOOK_URL;
const customWebhook = process.env.NOTIFICATION_WEBHOOK;Feature Flags#
// Toggle features without code changes
const enableAutoAssign = process.env.ENABLE_AUTO_ASSIGN === "true";
const enableNotifications = process.env.ENABLE_NOTIFICATIONS !== "false";
if (enableAutoAssign) {
// Auto-assignment logic
}
if (enableNotifications) {
// Notification logic
}Custom Field IDs#
// Store custom field IDs (they vary by Jira instance)
const sprintFieldId = process.env.SPRINT_FIELD_ID; // e.g., "customfield_10010"
const storyPointsFieldId = process.env.STORY_POINTS_FIELD_ID;
const epicLinkFieldId = process.env.EPIC_LINK_FIELD_ID;
// Use in API calls
const issue = await response.json();
const sprint = issue.fields[sprintFieldId];
const points = issue.fields[storyPointsFieldId];Best Practices#
Naming Conventions#
Use clear, descriptive names with consistent prefixes:
# External services
SLACK_WEBHOOK_URL
SLACK_BOT_TOKEN
GITHUB_ACCESS_TOKEN
# User IDs
TEAM_LEAD_ACCOUNT_ID
QA_LEAD_ACCOUNT_ID
# Custom field IDs
CUSTOM_FIELD_SPRINT
CUSTOM_FIELD_STORY_POINTS
# Feature flags
FEATURE_AUTO_ASSIGN
FEATURE_NOTIFICATIONS
DEBUG_MODESecurity#
- Always use secret for API keys, tokens, and passwords
- Never log secrets - avoid
console.log(process.env.API_KEY) - Validate presence - check variables exist before using
- Rotate credentials - update secrets periodically
Error Handling#
// Always validate required variables
function requireEnv(name) {
const value = process.env[name];
if (!value) {
throw new Error(`Missing required environment variable: ${name}`);
}
return value;
}
// Usage
const apiKey = requireEnv("API_KEY");
const webhookUrl = requireEnv("WEBHOOK_URL");Default Values#
// Provide sensible defaults for optional configuration
const maxItems = parseInt(process.env.MAX_ITEMS || "100", 10);
const timeoutMs = parseInt(process.env.TIMEOUT_MS || "30000", 10);
const defaultLabel = process.env.DEFAULT_LABEL || "auto-created";Troubleshooting#
Variable Not Available#
- Check the variable name matches exactly (case-sensitive)
- Verify the variable exists in the Environment tab
- Ensure there are no typos in
process.env.VARIABLE_NAME
Value is Undefined#
// Debug missing variables
console.log("Available env vars:", Object.keys(process.env));
console.log("API_KEY exists:", !!process.env.API_KEY);Script Works in Test but Not Production#
- Test environment may have different variables
- Ensure all required variables are set
- Check for environment-specific configuration
Limitations#
Size Limits#
- Variable name: Maximum 64 characters
- Variable value: Maximum 8KB per value
Count Limits#
- Total variables: No hard limit, but keep manageable for performance
Not Available#
- Variables cannot contain newlines in the value
- Binary data is not supported (use base64 encoding if needed)
Related Topics#
- Script Definitions - Managing your scripts
- API Reference - Available globals and APIs