Skip to content

Conversation

@ivan-torres-jbr
Copy link

@ivan-torres-jbr ivan-torres-jbr commented Jan 7, 2026

Checklist

=========

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have checked for similar issues and haven't found anything relevant.
  • This is not a security issue (which should be reported here: https://circleci.com/security/)
  • I have read Contribution Guidelines.

Internal Checklist

  • I am requesting a review from my own team as well as the owning team (N/A - external contributor)
  • I have a plan in place for the monitoring of the changes that I am making (N/A - CLI-only changes)

Changes

=======

  • Add circleci project id <project-slug> command to print project UUID.
  • Allow circleci pipeline list to accept <project-id|project-slug> (slug→project-id resolution).
  • Add circleci pipeline definitions list <project-slug> convenience command.
  • Add circleci pipeline runs latest <project-slug> --branch <branch> [--json].
  • Add circleci pipeline workflows <pipeline-id> [--json].
  • Add circleci workflow jobs <workflow-id> [--json].
  • Add circleci job logs <project-slug> <job-number> [--step ...] [--json] to fetch step outputs (v1.1 job details + presigned output URLs).
  • Add circleci job image-tag <project-slug> <job-number> [--step ...] [--regex ...] to extract image tag(s) from step output.
  • Add unit tests for new commands and shared slug parsing.
  • Skip integration scenario when K9S_CIRCLECI_CLI_TOKEN is unavailable (e.g. forked PR CI).

Rationale

=========

CircleCI CLI already supports v2 status discovery (pipelines/workflows/jobs) but does not expose job step logs or step outputs needed to debug build steps and to derive artifacts like image tags.

This PR adds first-class commands so users can stay within the CLI instead of stitching together multiple curl/jq calls.

Considerations

==============

  • Job logs/step output are not available in API v2 job details, so circleci job logs/circleci job image-tag rely on the v1.1 job details endpoint and its presigned output_url fields.
  • Presigned output URLs contain a token; the CLI never prints these URLs, and errors redact query parameters.
  • --step supports 1-based index, exact name, and substring matches to make it easy to target a specific step in a job.

How to Test

============

Prereqs: Go installed; a CircleCI personal API token.

  1. Build and run tests:

    • make build
    • make test (or go test ./...)
  2. Set your token (either works):

    Note: The @k9s integration scenario requires K9S_CIRCLECI_CLI_TOKEN. If it is not set, the scenario is skipped.

    • circleci setup
    • OR export CIRCLECI_CLI_TOKEN=...
  3. Choose a project/branch (example uses this repo):

    • PROJECT=gh/CircleCI-Public/circleci-cli
    • BRANCH=main
  4. Project ID:

    • circleci project id $PROJECT
  5. Pipeline definitions (slug-based):

    • circleci pipeline definitions list $PROJECT
    • (also works) circleci pipeline list $PROJECT
  6. Latest pipeline run:

    • pipeline_id=$(circleci pipeline runs latest $PROJECT --branch $BRANCH | cut -f1)
    • (json) circleci pipeline runs latest $PROJECT --branch $BRANCH --json | jq -r '.id'
  7. Workflows for the pipeline:

    • workflow_id=$(circleci pipeline workflows $pipeline_id --json | jq -r '.[0].id')
  8. Jobs for the workflow:

    • circleci workflow jobs $workflow_id
    • job_number=$(circleci workflow jobs $workflow_id --json | jq -r '.[] | select(.name=="build") | .job_number' | head -n1)
  9. Job logs:

    • circleci job logs $PROJECT $job_number (full)
    • circleci job logs $PROJECT $job_number --step "Checkout code"
    • If you’re not sure of step names: circleci job logs $PROJECT $job_number --json | jq -r '.steps[].name'
  10. Image tags:

  • circleci job image-tag $PROJECT $job_number (defaults to “Build Docker image”/“Push Docker images”)
  • If your step names differ: circleci job image-tag $PROJECT $job_number --step "<step name>"
  • If your output format differs: circleci job image-tag $PROJECT $job_number --step "<step name>" --regex '<your-regex-with-capture-group>'

Screenshots

============

N/A (CLI output only)


Note

Introduces first-class CLI utilities for v2 pipelines/workflows and v1.1 job step logs.

  • New job commands: job logs (fetch step outputs; optional --step, --json) and job image-tag (extract tags via regex; defaults to common Docker steps)
  • New pipeline utilities: pipeline runs latest --branch, pipeline workflows <pipeline-id> [--json], pipeline definitions list <project-slug>, and enhanced pipeline list to accept <project-id|project-slug>
  • New workflow jobs <workflow-id> [--json] and project id <project-slug> commands
  • Added REST clients/endpoints for listing pipelines and workflows, workflow jobs, and a v1.1 job API client; shared slug.ParseProject helper
  • Root command wires up new subcommands; extensive unit tests added; integration test skips when K9S_CIRCLECI_CLI_TOKEN is absent
  • CI: vulnerability scan job now ignores pull/* branches

Written by Cursor Bugbot for commit 08a2023. This will update automatically on new commits. Configure here.

@ivan-torres-jbr ivan-torres-jbr requested a review from a team as a code owner January 7, 2026 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant