Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Types

The commands in this repository and the interactive scripts in the replication template (tools/) authenticate to Jira and Bitbucket with Atlassian API tokens, and to Box with a Box JWT app.

Where to set the variables

All credentials can be read from environment variables.

Cluster
Codespaces
Bitbucket Pipelines

Keep ~/.envvars (and the Box config file) in the home directory there.

VariableValue
JIRA_USERNAMEAtlassian account email
JIRA_API_KEYJira API token
P_BITBUCKET_PATBitbucket API token (scoped)
P_BITBUCKET_EMAILAtlassian account email for the Bitbucket REST API; defaults to JIRA_USERNAME
P_BITBUCKET_USERNAMEBitbucket username, for git over HTTPS (aeagit, aeagit-create)
BOX_CONFIG_PATHDirectory with the Box config file (see Box)
BOX_ENTERPRISE_ID, BOX_PRIVATE_KEY_IDIDs from the Box config file name
BOX_FOLDER_PRIVATEBox folder holding the aearep-NNNN case folders
BOX_PRIVATE_JSONBase64-encoded Box config file, instead of the file

Jira and Bitbucket API tokens

Bitbucket can be confusing

The Bitbucket REST API accepts the account email with the token; git over HTTPS accepts only the Bitbucket username (shown under Personal settings in Bitbucket).

Creating a token

Scoped and unscoped tokens are created at id.atlassian.com → Security → API tokens. Create only scoped tokens (Create API token with scopes). Unscoped tokens (Create API token) are deprecated: they act with all of the account’s permissions. Replace an existing unscoped token with a scoped one.

Tokens expire after at most one year; a command that uses Jira stops with an error naming JIRA_USERNAME/JIRA_API_KEY when the token is no longer accepted.

Jira (JIRA_API_KEY)

  1. Click Create API token with scopes.

  2. Name it and pick an expiry date.

  3. Select the app Jira.

  4. Select the scopes listed under Scopes (Jira tabs), then Create.

  5. Copy the token into JIRA_API_KEY, and the account email into JIRA_USERNAME.

The Jira commands connect through the Atlassian API gateway (https://api.atlassian.com/ex/jira/c342e627-3ea3-47e3-b3dd-58b188a34a9e, set in aea_editor_scripts/jira_auth.py), which accepts scoped tokens. Browse links printed by the commands point to https://aeadataeditors.atlassian.net.

Bitbucket (P_BITBUCKET_PAT)

  1. Click Create API token with scopes.

  2. Name it and pick an expiry date.

  3. Select the app Bitbucket.

  4. Select the scopes listed under Scopes (Bitbucket tab), then Create.

  5. Copy the token into P_BITBUCKET_PAT.

Scopes

Classic Jira scopes
Granular Jira scopes
Bitbucket scopes

Scopes per command. Every command reads the current user (read:jira-user) to verify the token on connecting.

Commandread:jira-userread:jira-workwrite:jira-workOther
aea-box-clean-folders✓✓✓
aea-box-create-folder✓✓✓
aea-box-recover-files✓✓
aeagit (--all only)✓✓
aeagit-create✓✓✓
jira-approval-manager✓✓✓
jira-openicpsr-changes✓✓--apply
jira-purge-query✓✓
jira-reason-sync✓✓--execute
jira-status-manager✓✓when changing
jira_workflow_cleanup.pymanage:jira-configuration, or granular read:workflow:jira and delete:workflow:jira (separate scoped token)

The write:jira-work operations are editing fields, transitions, comments, and (in aea-box-create-folder) creating a subtask.

Box

Box access uses a Box JWT app. Its credentials are a JSON file named <ENTERPRISE_ID>_<KEY_ID>_config.json, available at 🔒 this private Box link. Most Box commands use BOX_FOLDER_PRIVATE, which is the folder on Box holding the aearep-NNNN case folders. The link to the JSON file is provided privately (here called <SECRETURL>)

Config file
Environment variable

Store the file in ~/.config/box/, readable only by you:

mkdir -p ~/.config/box
wget <SECRETURL> -P ~/Downloads
mv ~/Downloads/*_config.json ~/.config/box/
chmod 600 ~/.config/box/*_config.json

Then add to ~/.envvars, taking the two IDs from the file name:

BOX_CONFIG_PATH=${HOME}/.config/box
BOX_ENTERPRISE_ID=<ENTERPRISE_ID>
BOX_PRIVATE_KEY_ID=<KEY_ID>
BOX_FOLDER_PRIVATE=144685329952