# Scenario Book for Jira — Bitbucket Pipelines. # # Merge into your bitbucket-pipelines.yml and copy scenario-book-sync.mjs anywhere in the repo. # Set the variables from README.md under Repository settings → Repository variables, with "Secured" ticked # for SB_SYNC_KEY and JIRA_API_TOKEN. image: node:20 definitions: steps: - step: &pull-from-jira name: Pull the feature files from Jira clone: depth: 1 script: - export SB_DIR=features - node scenario-book-sync.mjs pull # A branch for review rather than a commit straight to main: a scenario arriving from Jira changes # what the tests assert, so it goes through review like any other change. - | if [ -n "$(git status --porcelain)" ]; then git config user.name "Scenario Book sync" git config user.email "pipelines@${BITBUCKET_WORKSPACE}.local" git checkout -B scenario-book/from-jira git add -A git commit -m "Scenario Book: feature files from Jira" git push --force origin scenario-book/from-jira echo "Pushed scenario-book/from-jira. Open a pull request from it." else echo "Nothing changed." fi - step: &push-to-jira name: Send the repo's feature files to Jira clone: depth: 1 script: - export SB_DIR=features - node scenario-book-sync.mjs push pipelines: # Every commit on main sends the repo to Jira. branches: main: - step: *push-to-jira # Jira is the side people edit in, so the pull runs on a schedule: Repository settings → Pipelines → # Schedules, pointing at this custom pipeline. Keeping the two apart is also what stops a loop — a merge of # Jira's own changes would otherwise trigger a push of the files Jira had just sent. custom: scenario-book-pull: - step: *pull-from-jira # Add to the step that runs your tests, where the report file is. In after-script, so a failing test run # still reports — that is the run you most want in Jira: # # after-script: # - export SB_LABEL=bitbucket # - node scenario-book-sync.mjs results reports/cucumber.json