Skip to content

feat(JFrogCliV2): allow persisting and reusing JFrog CLI config across steps - #651

Open
SierraNL wants to merge 1 commit into
jfrog:devfrom
SierraNL:split/2-persist-config
Open

feat(JFrogCliV2): allow persisting and reusing JFrog CLI config across steps#651
SierraNL wants to merge 1 commit into
jfrog:devfrom
SierraNL:split/2-persist-config

Conversation

@SierraNL

Copy link
Copy Markdown

Reasons

Split out of #637 (implementation of feature request #636) per reviewer feedback - the original PR bundled a few independent changes into one. This PR contains only the config persistence/reuse scenario. It is independent of the other two split-out PRs (#650 register-in-PATH, and a Package Alias PR) and can be reviewed/merged on its own, in any order.

Summary

Adds opt-in inputs so downstream pipeline steps (e.g. dotnet restore) can reuse the CLI config this task creates, instead of every step needing its own JFrog Platform service connection:

  • configurationName (optional) - reuse an existing named config instead of creating a new one; jfrogPlatformConnection becomes optional when this is set (the task fails clearly if neither is provided).
  • keepConfig (default false) - skips the cleanup step so the config survives after this task finishes.
  • The resolved config name is exposed via the JFROG_CLI_CONFIG_NAME pipeline variable, intended for a paired "teardown" task at the end of the pipeline (configurationName=$(JFROG_CLI_CONFIG_NAME), keepConfig=false) to delete the persisted config.

All new behavior is off by default, so existing pipelines using JFrogCliV2 are unaffected.

Test plan

  • node --check tasks/JFrogCliV2/jfrogCliRun.js
  • Validated tasks/JFrogCliV2/task.json parses as valid JSON
  • Added integration tests under tests/resources/jfrogCliV2PersistConfig/ (+ a new describe block in tests/tests.ts), following the existing tests/resources/<taskDir>/<scenario>.js + mockTask/runSyncTest pattern:
    • Fails clearly when neither jfrogPlatformConnection nor configurationName is provided.
    • Keeps a configuration via keepConfig, then reuses it by name via configurationName in a second task invocation (with no service connection), verifying the persist/reuse round-trip.

Note on CI

The Tests workflow is a pull_request_target workflow gated behind a safe to test label, and for fork PRs GitHub always runs the base branch's copy of that workflow file (a built-in security control against fork PRs granting themselves elevated permissions) - so a maintainer needs to add the label for the integration tests above to actually execute in CI. This can't be changed from the PR branch itself.

🤖 Generated with Claude Code

…s steps

Adds opt-in inputs so downstream pipeline steps can reuse the CLI
config this task creates, instead of every step needing its own
JFrog Platform service connection:

- configurationName: reuse an existing named config instead of
  creating a new one. jfrogPlatformConnection becomes optional when
  this is set (the task fails clearly if neither is provided).
- keepConfig: skips the cleanup step so the config survives after
  this task finishes.

The resolved config name is exposed via the JFROG_CLI_CONFIG_NAME
pipeline variable, intended for a paired "teardown" task at the end
of the pipeline (configurationName=$(JFROG_CLI_CONFIG_NAME),
keepConfig=false) to delete the persisted config.

This is the core scenario from feature request jfrog#636: run this task
once at the start of a pipeline to configure JFrog CLI, keep using
'jf' in existing steps, then tear the config down at the end -
without touching every step in between.

Split out of jfrog#637 per reviewer feedback, as an independent PR (not
stacked on any of the other split-out PRs) so it can be reviewed and
merged on its own.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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