Generate a permission target template with jf rt permission-target-template

Generate an Artifactory permission target JSON template interactively with jf rt permission-target-template.

Create a JSON template for permission target creation or replacement through an interactive process.

Synopsis

jf rt permission-target-template <template-path>

Aliases: rt ptt

Arguments

ArgumentRequiredDescription
<template-path>YesLocal file system path for the template file

Options

This command accepts no flags. It uses the server configured as default by jf config.
To target a non-default server, run jf config use <server-id> before executing this command.

📘

Note

Connection flags such as --server-id, --url, and --access-token are accepted by
jf rt ptc and jf rt ptu
when applying a template — not by jf rt ptt.

Examples

Create a Permission Target Template

To generate a permission target template interactively:

  • Run:
jf rt permission-target-template <template-path>

Where:

  • <template-path>: Path where the new JSON template file should be written (see Arguments).

Full example:

jf rt permission-target-template ./my-permission-target.json

The CLI guides you through an interactive wizard. On success, you will see:

HH:MM:SS [Info] Permission target configuration template successfully created at ./my-permission-target.json.

The output file is standard JSON and is suitable for use with permission-target-create or permission-target-update.

When to Use

Use jf rt ptt to create a JSON template interactively before creating or updating permission targets. The template approach is recommended because:

  • Complex structure: Permission targets involve repositories, users, groups, and action permissions. The template guides you through all the fields.
  • Reusability: Save the template and reuse it across environments. Use ${variableName} placeholders in the template, then inject real values with --vars when running jf rt ptc or jf rt ptu.
  • Version control: Commit templates to source control for auditable access control changes.

Typical workflow:

To create a template and apply it, then update with variables:

  1. Create the template interactively (writes the file to the path you provide):
jf rt ptt ./team-access.json
  1. (Optional) Edit the JSON to add ${variable} tokens for parameterization (for example change "repositories":"my-repo" to "repositories":"${repoName}").

  2. Create the permission target from the template:

jf rt ptc ./team-access.json
  1. Later, update it and inject variables with --vars (semicolon-separated key=value pairs):
jf rt ptu ./team-access.json --vars "groupName=new-team;repoName=my-libs-repo"
📘

Note

If you're coming from the Artifactory UI, you manage permission targets under Administration > Identity and Access > Permissions. The template corresponds to the JSON payload you would see if you clicked Export on a permission target. The CLI's interactive prompts walk you through the same fields.


Before You Begin

Have the following information ready before starting the wizard:

  • Permission target name — a unique identifier for this permission target
  • Repository names — the repos to apply permissions to, or one of the special values ANY, ANY REMOTE, or ANY LOCAL
  • Usernames and/or group names — principals to grant permissions to (you can press Enter with no value to skip users or groups)

Wizard Walkthrough

The wizard runs a multi-step questionnaire. Here is the full prompt sequence:

StepPromptInput typeNotes
1Insert the permission target name >Free textRequired. Name of the permission target.
You can type ":x" at any time to save and exit.(hint)See Saving and exiting.
2Select the permission target section to configure (press Tab for options):Tab-selectOptions: repo, build, releaseBundle, :x (save and exit). Press Tab to reveal.
3Insert the section's repositories value. / The value should be a comma separated list >Comma-separated(repo section only) Accepts repo names, ANY, ANY REMOTE, or ANY LOCAL.
4Insert a value for include-patterns: / The value should be a comma separated list (press enter for default) [**]:Comma-separated(repo section only) Default is ** (all files). Press Enter to accept.
5Insert value for exclude-patterns: / The value should be a comma separated list (press enter for default) []:Comma-separated(repo section only) Default is empty (no exclusions). Press Enter to accept.
6Configure actions for users? (press Tab for options): [yes]:Tab-selectOptions: yes, no. Default is yes.
7Insert user name (press enter to finish) >Free text (repeatable)Enter one username per line. Press Enter with no value to finish the user list.
7aSelect permission value for <username> (press tab for options or enter to finish) >Tab-select (repeatable)(asked immediately after each username, before the next username prompt) Press Tab to pick one permission at a time from the remaining values (read, write, annotate, delete, manage, managedXrayMeta, distribute); press Enter with no value to finish this user's permissions and return to step 7.
8Configure actions for groups? [yes]:Tab-selectOptions: yes, no. Default is yes. Note: unlike step 6, this prompt is not labeled (press Tab for options) in the CLI output, though Tab still reveals the choices.
9Insert group name (press enter to finish) >Free text (repeatable)Enter one group name per line. Press Enter with no value to finish.
9aSelect permission value for <group name> (press tab for options or enter to finish) >Tab-select (repeatable)(asked immediately after each group name, before the next group name prompt) Same behavior as step 7a.
10Returns to step 2Add another section (build, releaseBundle) or type :x to save and exit.
👍

Tip

You can configure multiple sections in one session. After completing a section, the wizard returns to the section selector. Type :x when you are done adding sections.


Important Notes

  • Requires a real terminal (TTY). This command uses an interactive prompt library that requires a live terminal session. Running it without a TTY — for example, from a script, CI pipeline, or with piped stdin — causes the command to exit immediately with an error. If you need to create a template in a non-interactive environment, write the JSON file manually using the format documented in jf rt permission-target-create or jf rt permission-target-update.
  • Saving and exiting the wizard: At any section selection prompt, type :x and press Enter to save the template and exit. This is the only way to complete and save the wizard session.
  • Dropdown prompts require Tab: Prompts marked (press Tab for options) require you to press Tab to reveal the list of valid choices. Pressing Enter without a valid selection prints Invalid answer. Please select value from the suggestions list. You can either press Tab and then Enter, or type the option name exactly (for example, repo) and press Enter.
  • The command is interactive. It prompts for the permission target name, section type, repository assignments, user/group principals, and action permissions.
  • The wizard writes literal values to the template JSON exactly as you typed them. To enable variable substitution, manually edit the JSON after generation and replace any value with a ${variableName} token. Then pass real values at apply time using --vars with jf rt ptc or jf rt ptu. For example:
    { "name": "team-target", "repo": { "repositories": "${repoName}" } }
    jf rt ptc ./team-access.json --vars "repoName=my-libs-repo"
    The --vars flag is not accepted by jf rt ptt itself.
  • Template files are standard JSON and can be edited manually after generation.
  • repositories is a string, not a JSON array. Use a comma-separated list to specify one or more repository keys (for example "libs-release" or "libs-release,libs-release-local"). Passing a JSON array produces json: cannot unmarshal array into Go struct field PermissionSectionAnswer.repositories of type string.
  • The build section's repositories value is ignored. Whatever you set there, the CLI always submits it as artifactory-build-info, the fixed virtual repository Artifactory uses for build info. The build section itself is optional — omit any top-level section (repo, build, releaseBundle) you don't need.

Frequently Asked Questions

This section provides answers to frequently asked questions.

plusFAQs
Q: How do I generate a permission target template?

A: Run jf rt permission-target-template <template-path> in a terminal and follow the interactive wizard. See Wizard Walkthrough for the full prompt sequence.

Q: What happens if I run permission-target-template without a TTY?

A: The command exits immediately with an error, because it requires a live terminal session. See Important Notes for how to create a template manually instead.

Q: What is the difference between the repo, build, and releaseBundle sections?

A: Each section configures permissions for a different resource type. The build section's repositories value is always fixed to artifactory-build-info, and every section is optional.

Q: What information do I need before starting the wizard?

A: A permission target name, the repository names or special values (ANY, ANY REMOTE, ANY LOCAL), and any usernames or group names to grant permissions to. See Before You Begin.

Q: Can I use variables in a generated template?

A: Yes. The wizard writes literal values only, but you can manually edit the JSON afterward to replace a value with a ${variableName} token, then supply the value with --vars when running jf rt ptc or jf rt ptu.

Related Topics



What’s Next

Once your template is ready, create the permission target or update an existing one.

Did this page help you?