# Scenario Book for Jira — Azure Pipelines. # # Copy scenario-book-sync.mjs anywhere in the repo. Put the values from README.md in a variable group called # "scenario-book" (Pipelines → Library), marking SB_SYNC_KEY and JIRA_API_TOKEN as secret. # # A secret variable is **not** put in the environment automatically, which is why every step below maps the # ones it needs by hand. Without that mapping the script stops with "JIRA_API_TOKEN is not set" — the right # failure, and a confusing one to work out from a build log. trigger: branches: include: [main] schedules: # Jira is the side people edit in, so the pull runs on a schedule. - cron: '*/15 * * * *' displayName: Pull the feature files from Jira branches: include: [main] always: true pool: vmImage: ubuntu-latest variables: - group: scenario-book - name: SB_DIR value: features steps: - task: NodeTool@0 inputs: versionSpec: '20.x' displayName: Node 20 - checkout: self persistCredentials: true fetchDepth: 1 - script: node scenario-book-sync.mjs pull displayName: Pull the feature files from Jira condition: eq(variables['Build.Reason'], 'Schedule') env: JIRA_API_TOKEN: $(JIRA_API_TOKEN) JIRA_BASE_URL: $(JIRA_BASE_URL) JIRA_EMAIL: $(JIRA_EMAIL) JIRA_PROJECT: $(JIRA_PROJECT) - script: | set -eu if [ -n "$(git status --porcelain)" ]; then git config user.name "Scenario Book sync" git config user.email "scenario-book@pipelines.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 displayName: Branch and push, for review condition: and(succeeded(), eq(variables['Build.Reason'], 'Schedule')) - script: node scenario-book-sync.mjs push displayName: Send the repo's feature files to Jira condition: and(succeeded(), ne(variables['Build.Reason'], 'Schedule')) env: JIRA_API_TOKEN: $(JIRA_API_TOKEN) JIRA_BASE_URL: $(JIRA_BASE_URL) JIRA_EMAIL: $(JIRA_EMAIL) JIRA_PROJECT: $(JIRA_PROJECT) SB_SYNC_KEY: $(SB_SYNC_KEY) SB_PUSH_URL: $(SB_PUSH_URL) # Add after the step that runs your tests, where the report file is: # # - script: node scenario-book-sync.mjs results reports/cucumber.json # displayName: Upload the test results to Scenario Book # condition: always() # a failing test run is the one you most want in Jira # env: # JIRA_API_TOKEN: $(JIRA_API_TOKEN) # JIRA_BASE_URL: $(JIRA_BASE_URL) # JIRA_EMAIL: $(JIRA_EMAIL) # JIRA_PROJECT: $(JIRA_PROJECT) # SB_SYNC_KEY: $(SB_SYNC_KEY) # SB_RESULTS_URL: $(SB_RESULTS_URL) # SB_LABEL: azure