Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 115 additions & 15 deletions .github/workflows/reusable-poll-jira.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,36 @@
# - Optional secrets: FULLSEND_JIRA_TOKEN / FULLSEND_JIRA_EMAIL for API-token
# authentication, or FULLSEND_JIRA_CLIENT_ID / FULLSEND_JIRA_CLIENT_SECRET
# for OAuth 2.0 client credentials. The Jira client validates the pair.
# - Optional inputs: runner_image (runner for the poll job) and timeout_minutes
# (job timeout; defaults to 15 minutes and can be raised by the caller).
# - Optional secrets FULLSEND_JIRA_WRITE_GROUPS, FULLSEND_JIRA_WRITE_ACCOUNTS,
# FULLSEND_JIRA_TRIAGE_GROUPS and FULLSEND_JIRA_TRIAGE_ACCOUNTS: the jira
# authorization lists that .fullsend/config.yaml reads with groups_from and
# accounts_from, so the lists stay out of a public repository (#9132).
# - Optional inputs: runner_image (runner for both jobs) and timeout_minutes
# (timeout of each job; defaults to 15 minutes and can be raised by the
# caller).
# - Output: matrix is the JSON include matrix for reusable-dispatch.yml; an
# empty include array means there were no Jira issues to dispatch.
# empty include array means there were no Jira issues to dispatch. The matrix
# job sets it, not the poll job (see the comment on that job).
# Runs `fullsend poll --input-driver jira-poll` against the caller's
# .fullsend/config.yaml and returns the dispatch matrix to the caller. The
# caller passes it to reusable-dispatch.yml at the same ref (ADR 62).
# The poll normally completes within 15 minutes; the caller controls the job
# timeout through timeout_minutes to account for its runner and Jira latency.
#
# Security: Jira credentials reach only the poll step. They are never
# forwarded to agents or the runner-secret bundle.
# Security: Jira credentials reach only the poll and check steps. They are
# never forwarded to agents or the runner-secret bundle.
name: Jira poll

on:
workflow_call:
inputs:
runner_image:
description: GitHub Actions runner image for the poll job.
description: GitHub Actions runner image for the Jira poll jobs.
type: string
required: false
default: "ubuntu-24.04"
timeout_minutes:
description: Maximum runtime in minutes for the Jira poll job.
description: Maximum runtime in minutes for each Jira poll job.
type: number
required: false
default: 15
Expand All @@ -42,10 +48,18 @@ on:
required: false
FULLSEND_JIRA_CLIENT_SECRET:
required: false
FULLSEND_JIRA_WRITE_GROUPS:
required: false
FULLSEND_JIRA_WRITE_ACCOUNTS:
required: false
FULLSEND_JIRA_TRIAGE_GROUPS:
required: false
FULLSEND_JIRA_TRIAGE_ACCOUNTS:
required: false
outputs:
matrix:
description: Dispatch matrix accepted by reusable-dispatch.yml.
value: ${{ jobs.poll.outputs.matrix }}
value: ${{ jobs.matrix.outputs.matrix || '{"include":[]}' }}
Comment thread
waynesun09 marked this conversation as resolved.
Resolved

jobs:
poll:
Expand All @@ -55,7 +69,8 @@ jobs:
permissions:
contents: read
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
dispatch_count: ${{ steps.check.outputs.count }}
artifact_suffix: ${{ steps.check.outputs.artifact_suffix }}
steps:
- name: Checkout caller repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand Down Expand Up @@ -104,6 +119,12 @@ jobs:
FULLSEND_JIRA_EMAIL: ${{ secrets.FULLSEND_JIRA_EMAIL }}
FULLSEND_JIRA_CLIENT_ID: ${{ secrets.FULLSEND_JIRA_CLIENT_ID }}
FULLSEND_JIRA_CLIENT_SECRET: ${{ secrets.FULLSEND_JIRA_CLIENT_SECRET }}
# The poller reads these only when config.yaml names them with
# groups_from or accounts_from, and never prints them.
FULLSEND_JIRA_WRITE_GROUPS: ${{ secrets.FULLSEND_JIRA_WRITE_GROUPS }}
FULLSEND_JIRA_WRITE_ACCOUNTS: ${{ secrets.FULLSEND_JIRA_WRITE_ACCOUNTS }}
FULLSEND_JIRA_TRIAGE_GROUPS: ${{ secrets.FULLSEND_JIRA_TRIAGE_GROUPS }}
FULLSEND_JIRA_TRIAGE_ACCOUNTS: ${{ secrets.FULLSEND_JIRA_TRIAGE_ACCOUNTS }}
TARGET_REPO: ${{ github.repository }}
run: |
set -euo pipefail
Expand All @@ -113,16 +134,95 @@ jobs:
--output dispatches.json \
--fullsend-dir .fullsend

# The matrix job has no secrets, so GitHub no longer blocks a Jira
Comment thread
waynesun09 marked this conversation as resolved.
Resolved
# credential in its output. Check for one here instead.
- name: Check dispatches
id: check
env:
FULLSEND_JIRA_TOKEN: ${{ secrets.FULLSEND_JIRA_TOKEN }}
FULLSEND_JIRA_EMAIL: ${{ secrets.FULLSEND_JIRA_EMAIL }}
FULLSEND_JIRA_CLIENT_ID: ${{ secrets.FULLSEND_JIRA_CLIENT_ID }}
FULLSEND_JIRA_CLIENT_SECRET: ${{ secrets.FULLSEND_JIRA_CLIENT_SECRET }}
run: |
set -euo pipefail
jq -e 'type == "array"' dispatches.json > /dev/null
# JSON escapes characters such as quotes, so search the decoded
# strings, not the file.
jq -r '.. | strings' dispatches.json > dispatch-strings.txt
for name in FULLSEND_JIRA_TOKEN FULLSEND_JIRA_EMAIL FULLSEND_JIRA_CLIENT_ID FULLSEND_JIRA_CLIENT_SECRET; do
# Trim the value as the CLI does. An empty grep pattern matches
# every line, and a padded one matches nothing.
value="$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e '/^$/d' <<< "${!name}")"
if [[ -n "${value}" ]] && grep -qF -f <(printf '%s\n' "${value}") dispatch-strings.txt; then
echo "::error::dispatches.json contains ${name}; not passing it on."
exit 1
fi
done
# A run can call this workflow more than once, and artifact names are
# unique per run, so each call names its artifact with its own suffix.
echo "artifact_suffix=$(openssl rand -hex 8)" >> "${GITHUB_OUTPUT}"
echo "count=$(jq length dispatches.json)" >> "${GITHUB_OUTPUT}"

# The poller has already advanced its Jira checkpoints, so a failed
# upload would lose this cycle's dispatches. Try it twice.
- name: Save dispatches
id: save
if: ${{ steps.check.outputs.count != '0' }}
continue-on-error: true
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: fullsend-jira-dispatches-${{ steps.check.outputs.artifact_suffix }}
path: dispatches.json
if-no-files-found: error
retention-days: 1
overwrite: true

- name: Save dispatches (second try)
if: ${{ steps.save.outcome == 'failure' }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: fullsend-jira-dispatches-${{ steps.check.outputs.artifact_suffix }}
path: dispatches.json
if-no-files-found: error
retention-days: 1
overwrite: true

# Builds the matrix in a job without secrets. GitHub drops a job output that
# contains the value of a secret the job has, and the matrix holds the ID of
# the account that acted, which can equal a list secret such as
# FULLSEND_JIRA_WRITE_ACCOUNTS.
matrix:
name: Build dispatch matrix
needs: poll
# "!= '0'", not "> 0": an empty (dropped) count still runs this job.
if: ${{ needs.poll.outputs.dispatch_count != '0' }}
runs-on: ${{ inputs.runner_image }}
timeout-minutes: ${{ inputs.timeout_minutes }}
permissions: {}
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
# If both tries fail, "Re-run failed jobs" reads the artifact again
# while it is kept (1 day). "Re-run all jobs" would poll again and find
# nothing.
- name: Read dispatches
id: read
continue-on-error: true
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: fullsend-jira-dispatches-${{ needs.poll.outputs.artifact_suffix }}

- name: Read dispatches (second try)
if: ${{ steps.read.outcome == 'failure' }}
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: fullsend-jira-dispatches-${{ needs.poll.outputs.artifact_suffix }}

- name: Build dispatch matrix
id: matrix
run: |
set -euo pipefail
jq -e 'type == "array"' dispatches.json > /dev/null
if jq -e 'length == 0' dispatches.json > /dev/null; then
echo "No dispatches."
echo 'matrix={"include":[]}' >> "${GITHUB_OUTPUT}"
exit 0
fi
jq -e 'type == "array" and length > 0' dispatches.json > /dev/null
MATRIX=$(jq -c '{include: .}' dispatches.json)
DELIM="MATRIX_$(openssl rand -hex 8)"
{
Expand Down
17 changes: 16 additions & 1 deletion docs/cli/repos.md
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,16 @@ flag or environment variable supplies them.
When install manages the caller, it checks that its upstream ref contains
`reusable-poll-jira.yml`. An older pin fails with no credential or workflow
changes; upgrade the pin to a ref that includes the workflow.
When the `jira` authorization entry reads a list with `groups_from` or
`accounts_from`, the poll job also receives the
`FULLSEND_JIRA_WRITE_GROUPS`, `FULLSEND_JIRA_WRITE_ACCOUNTS`,
`FULLSEND_JIRA_TRIAGE_GROUPS`, or `FULLSEND_JIRA_TRIAGE_ACCOUNTS` secret it
names. Install warns about any other name, which the caller cannot pass.
It also warns when a poll workflow you maintain calls
`reusable-poll-jira.yml` without passing a secret the entry names.
You set these secrets
yourself; install and uninstall never write or delete them. See
[Keeping the lists out of the repository](../guides/user/jira-integration.md#keeping-the-lists-out-of-the-repository).
Install changes the file only when it carries the
`# fullsend-component: jira-poll` marker line. A workflow at that path
without the marker, such as one copied from the Jira guide, is reported and
Expand All @@ -692,7 +702,12 @@ flag or environment variable supplies them.
environment variable available to all environments. The same rules apply
to `--jira-client-secret` and an existing `FULLSEND_JIRA_CLIENT_SECRET`.
Supplying any Jira credential flag when no selected repo enables polling
fails the run.
fails the run. When the `jira` authorization entry uses `groups_from` or
`accounts_from` and `fullsend_ref` pins a release that predates them, the
repo fails before any write, on GitHub and GitLab, with polling enabled or
not. On GitHub with polling enabled, it also fails when a poll workflow you
maintain calls a `reusable-poll-jira.yml` that predates them, unless the
install is vendored. `repos status` reports the same errors.
- **Dry run.** `--dry-run` lists Jira secrets by name only and reports the
poll-resource changes it would make.
- **Command-line only.** `--jira-token`, `--jira-email`, `--jira-client-id`,
Expand Down
1 change: 1 addition & 0 deletions docs/guides/getting-started/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ fullsend github set "$OWNER/$REPO" FULLSEND_GCP_REGION global
| `FULLSEND_JIRA_TOKEN` | Repo secret | Jira API token for polling and Jira-originated agent status updates when effective `tracker.jira.poll.enabled` is `true`, written by `repos install --jira-token` (required on the first install unless client credentials are supplied; an omitted flag keeps the existing secret; `repos uninstall` deletes it) | (Jira API token) |
| `FULLSEND_JIRA_EMAIL` | Repo secret | Optional Jira account email for the same poller and agent status calls, written by `repos install --jira-email`; an omitted flag keeps the existing secret; `repos uninstall` deletes it | `poller@example.com` |
| `FULLSEND_JIRA_CLIENT_ID` / `FULLSEND_JIRA_CLIENT_SECRET` | Repo secret | A service account's OAuth 2.0 credential, used instead of `FULLSEND_JIRA_TOKEN` (never both). GitHub poll and Jira-originated dispatch workflows forward them to the Jira client; `repos install` writes them on GitHub and GitLab. `repos uninstall` deletes them | (OAuth client credentials) |
| `FULLSEND_JIRA_WRITE_GROUPS` / `FULLSEND_JIRA_WRITE_ACCOUNTS` / `FULLSEND_JIRA_TRIAGE_GROUPS` / `FULLSEND_JIRA_TRIAGE_ACCOUNTS` | Repo secret (optional) | Comma-separated Jira group IDs or account IDs that the `jira` authorization entry reads with `groups_from` or `accounts_from`, so the lists stay out of the repository. The managed poll workflow passes the ones the entry names to the poll job only. Set with `gh secret set`; `repos install` and `repos uninstall` never write or delete them. See [Keeping the lists out of the repository](../user/jira-integration.md#keeping-the-lists-out-of-the-repository) | `<group-id-1>,<group-id-2>` |
| `FULLSEND_TRACE_SIGNING_KEY` | Repo secret | Trace-context signing key ([ADR 0154](../../ADRs/0154-correlate-work-item-and-behaviour-scenario-traces.md)): standard base64 of a 32-byte Ed25519 seed, generated by `repos install`, which records its public key in `repos.yaml` as `config.trace_context`. [Trace signing keys](../../cli/repos.md#trace-signing-keys) lists when install writes it. Nothing reads it yet. `fullsend run` keeps it from harnesses. `repos uninstall` deletes it | (generated) |
| `FULLSEND_GITHUB_RUNNER_SECRETS` | Repo or org secret (optional) | JSON object of name → value for host-side scripts, read through each harness's `env.runner`. Set with `gh secret set`, not `fullsend github set`; see [Pass secrets to host-side scripts](../user/bring-your-own-agent.md#pass-secrets-to-host-side-scripts-github) | `{"JIRA_API_TOKEN":"..."}` |

Expand Down
5 changes: 5 additions & 0 deletions docs/guides/infrastructure/infrastructure-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,11 @@ Secrets and variables are deployed on the target repository.
not by `github setup`)
- `FULLSEND_JIRA_TOKEN`, `FULLSEND_JIRA_EMAIL` — Jira API token and optional account email for repos whose effective `tracker.jira.poll.enabled` is `true`, used by the poller and Jira-originated agent status updates (written by `repos install --jira-token` / `--jira-email`; an omitted flag keeps the existing secret; deleted by `repos uninstall`; not set by `github setup`)
- `FULLSEND_JIRA_CLIENT_ID`, `FULLSEND_JIRA_CLIENT_SECRET` — a service account's OAuth 2.0 credential, an alternative to `FULLSEND_JIRA_TOKEN` (never both). GitHub poll and Jira-originated dispatch workflows forward them to the Jira client, and `repos install` writes them on GitHub and GitLab; `repos uninstall` deletes them
- `FULLSEND_JIRA_WRITE_GROUPS`, `FULLSEND_JIRA_WRITE_ACCOUNTS`,
`FULLSEND_JIRA_TRIAGE_GROUPS`, `FULLSEND_JIRA_TRIAGE_ACCOUNTS` — optional,
set by you: the Jira group or account IDs that the `jira` authorization
entry reads with `groups_from` or `accounts_from`
([setup](../user/jira-integration.md#keeping-the-lists-out-of-the-repository))
- `FULLSEND_TRACE_SIGNING_KEY` — trace-context signing key
([ADR 0154](../../ADRs/0154-correlate-work-item-and-behaviour-scenario-traces.md)):
standard base64 of a 32-byte Ed25519 seed, generated by `repos install`,
Expand Down
8 changes: 8 additions & 0 deletions docs/guides/user/custom-poller-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ tracker:

See [Jira Integration § Custom JQL](jira-integration.md#custom-jql).

> **If the poll job receives a `jira` authorization list secret** (see
> [Keeping the lists out of the repository](jira-integration.md#keeping-the-lists-out-of-the-repository)),
> do not set the `matrix` output in that job, as this example does. GitHub
> drops a job output that contains the value of a secret the job has, and
> the matrix contains the ID of the account that acted. Set the output from
> a second job that receives no list secret. See
> [GitHub: Vault or another secret store](jira-integration.md#github-vault-or-another-secret-store).

## Matrix Format

The `matrix` input (a GitHub Actions [matrix strategy](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow#using-a-matrix-strategy) that runs parallel jobs) must follow the format produced by `fullsend dispatch --output-driver gha-matrix`:
Expand Down
Loading
Loading