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.

jira_sync_fields.py - Sync fields from a source Jira issue to a target issue

Description

Copies fields from a source Jira issue to a target issue, but only for fields that are empty or null on the target. This is useful when a revision case is created and many metadata fields (e.g., DOI, openICPSR URL, manuscript ID) need to be carried over from the original issue without overwriting any values already entered on the revision.

Usage

python3 tools/jira_sync_fields.py <issue-key> [<target-key>] [--yes] [--comment]

Arguments

Options

Issue Key Formats

Bare numbers (e.g., 9603) are automatically expanded to AEAREP-9603. Keys with any non-numeric prefix (e.g., TRAIN-2000) are used as-is (uppercased).

Examples

# Explicit source and target
python3 tools/jira_sync_fields.py AEAREP-9000 AEAREP-9603

# Using bare numbers
python3 tools/jira_sync_fields.py 9000 9603

# Auto-detect source from revision link on the target issue
python3 tools/jira_sync_fields.py AEAREP-9603

# Auto-apply without confirmation prompt
python3 tools/jira_sync_fields.py 9603 --yes

# Post a comment listing all synced fields
python3 tools/jira_sync_fields.py 9000 9603 --comment

Requirements

Environment Variables Required

To obtain a Jira API token:

  1. Visit https://id.atlassian.com/manage-profile/security/api-tokens

  2. Click “Create API token”

  3. Copy the token and set it as JIRA_API_KEY environment variable

Behavior

Output

Use in Bitbucket Pipelines

This tool is invoked by the s-sync-issue-fields custom pipeline, which runs automatically when a revision ticket is associated with an original issue via the "is a revision of" Jira link. The pipeline passes the --yes and --comment flags so that changes are applied non-interactively and a comment is posted to the target issue.

See Bitbucket Pipelines Configuration for details on the s-sync-issue-fields pipeline.

See Also