Skip to content

JGC-492 - Add --format flag for release-bundle-create, promote, and distribute#488

Open
ehl-jf wants to merge 3 commits into
jfrog:mainfrom
ehl-jf:JGC-492-format-flag
Open

JGC-492 - Add --format flag for release-bundle-create, promote, and distribute#488
ehl-jf wants to merge 3 commits into
jfrog:mainfrom
ehl-jf:JGC-492-format-flag

Conversation

@ehl-jf

@ehl-jf ehl-jf commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds --format flag support to the three lifecycle Release Bundle V2 commands:

  • jf release-bundle-promote (rbp)--format json (default, backward-compat) and --format table. Table renders a single-row summary with REPOSITORY KEY, BUNDLE NAME, VERSION, ENVIRONMENT, and CREATED columns.
  • jf release-bundle-create (rbc)--format json only (Pattern B / echo). No flag = silent (backward-compat). Emits { release_bundle_name, release_bundle_version, status: "created" } on success.
  • jf release-bundle-distribute (rbd)--format json only (Pattern B / echo). No flag = silent (backward-compat). Emits { release_bundle_name, release_bundle_version, status: "distributed" } on success.

Changes

  • lifecycle/cli.go — Added SupportedFormats to the three command definitions; wired c.GetOutputFormat() + .SetOutputFormat() in the create(), promote(), and distribute() action handlers; added coreformat import.
  • lifecycle/commands/promote.go — Added outputFormat field, SetOutputFormat() setter, printOutput() dispatcher (json default / table), and printPromoteTable() helper using coreutils.PrintTable.
  • lifecycle/commands/distribute.go — Added outputFormat field, SetOutputFormat() setter, and printDistributeOutput() echo-json helper.
  • lifecycle/commands/createcommon.go — Added outputFormat field, SetOutputFormat() setter, and printCreateOutput() echo-json helper; refactored Run() to collect the create error at a single exit point before calling printCreateOutput().
  • lifecycle/commands/format_output_test.go (new) — 15 unit tests covering the json path, no-format backward-compat path, table path (for promote), content correctness, and setter behaviour for all three commands.

Backward compatibility

All three commands retain their existing behaviour when --format is not specified:

  • rbp continues to emit the full promotion JSON response.
  • rbc and rbd continue to produce no output.

  • All tests passed. If this feature is not already covered by the tests, I added new tests.
  • All static analysis checks passed.
  • Appropriate label is added to auto generate release notes.
  • I used gofmt for formatting the code before submitting the pull request.
  • PR description is clear and concise, and it includes the proposed solution/fix.

@reshmifrog reshmifrog added improvement Automatically generated release notes safe to test Approve running integration tests on a pull request labels Jun 12, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Jun 12, 2026
return rbc
}

func (rbc *ReleaseBundleCreateCommand) SetOutputFormat(f coreformat.OutputFormat) *ReleaseBundleCreateCommand {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of using a single letter f we can rename it as format

}

if sourceTypes != nil && isSingleSourceType(sourceTypes) {
var runErr error

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is runErr can we use a better name for this?

if rbc.outputFormat != coreformat.Json {
return nil
}
return printEchoJson(rbc.releaseBundleName, rbc.releaseBundleVersion, "created")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a const for "created"

}

func (rbd *ReleaseBundleDistributeCommand) SetOutputFormat(f coreformat.OutputFormat) *ReleaseBundleDistributeCommand {
rbd.outputFormat = f

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here as well use a better name instead of using f

if rbd.outputFormat != coreformat.Json {
return nil
}
return printEchoJson(rbd.releaseBundleName, rbd.releaseBundleVersion, "distributed")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a const for "distributed".


// --- promote ---

func TestPromotePrintOutput_Json(t *testing.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please add e2e in jfrog-cli.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Automatically generated release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants