Use APM with JFrog CLI
Configure Microsoft Agent Package Manager for Artifactory and run jf agent apm with optional build-info.
Run Agent Package Manager (APM) with JFrog Artifactory integration for registry configuration, per-run credential injection, and optional build-info collection.
This topic covers the following tasks:
- Configure APM for Artifactory
- Install Agent Packages
- Publish Agent Packages
- Run Native APM Subcommands
When to Use
Use jf agent apm when you manage Agent Packages with the native apm CLI and want JFrog CLI to authenticate against Artifactory and, for install and publish, to record build-info.
- Run
jf setup apmonce per environment to write the Artifactory registry into~/.apm/config.json. - Run
jf agent apm installorjf agent apm publishwith--build-nameand--build-numberto collect build-info locally, then publish the record withjf rt build-publish. - Run other native APM subcommands through
jf agent apmas a passthrough with authenticated registry access and no build-info.
If you only need native APM configuration without JFrog CLI, you can set registry URL and token yourself. For more information, see Agent Packages Repositories.
Note
Package Alias doesn't intercept
apm. Runjf agent apmor nativeapmafterjf setup apm. For more information, see Use JFrog CLI Package Alias.
Prerequisites
- APM on
PATH:jf agent apmandjf setup apmdon't install APM. JFrog CLI requires APM 0.23.0 or later. Install from the Agent Package Manager documentation. - JFrog CLI installed and authenticated: Install or upgrade from the JFrog CLI quick start, then configure a server with
jf config addorjf c add. Use--server-idwhen you need a server other than the default. - Artifactory Agent Packages repository: Create a local Agent Packages repository. Artifactory doesn't provide remote or virtual Agent Packages repositories for APM install and publish. For more information, see Agent Packages Repositories.
- Write access to APM user config for setup:
jf setup apmupdates~/.apm/config.jsonthrough the nativeapmclient. JFROG_HOME(optional): Set this variable if you use a non-default directory for JFrog CLI configuration files.
Configure APM for Artifactory
jf setup apm configures the local APM client to use an Artifactory local Agent Packages repository as a named registry (and as the default registry).
There's no jf apm-config command. Use jf setup apm.
To configure APM for Artifactory:
- Configure a JFrog CLI server with
jf c addorjf config add. - Run
jf setup apm --server-id=<server-id> --repo=<local-repository-key>for non-interactive setup, or omit--repoto select a local Agent Packages repository interactively. - Confirm
~/.apm/config.jsoncontains a registry named after the repository key, with URLhttps://<host>/artifactory/api/agentpackages/<repo>/and a token.
After setup, native apm install and apm publish can use the same registry without going through JFrog CLI.
Synopsis
jf setup apm [--server-id=<server-id>] [--repo=<repository-key>] [--project=<project-key>]Where:
<server-id>: JFrog CLI server ID fromjf config add.<repository-key>: Artifactory local Agent Packages repository key.<project-key>: JFrog project key used when listing repositories interactively.
Options
The following options apply to jf setup apm.
| Flag | Default | Description |
|---|---|---|
--server-id | Default server | JFrog CLI server ID from jf config add |
--repo | Interactive selection | Artifactory local Agent Packages repository key. When omitted, the CLI prompts you to select a local Agent Packages repository. |
--project | None | JFrog project key used when listing repositories interactively |
Setup runs native APM config commands that enable registries and set registry.<repository-key>.url, registry.<repository-key>.token, and registry.<repository-key>.default to true. Re-running setup for a different repository makes that repository the default.
Warning
jf setup apmwrites credentials into~/.apm/config.json. If the access token expires, native APM andjf agent apmcan fail with401until you refresh the JFrog CLI server withjf c addorjf c editand re-runjf setup apm.
Configure APM with Flags
To run non-interactive setup:
- Run:
jf setup apm --server-id=my-server --repo=agent-packages-localExpected result includes: Successfully configured apm to use JFrog repository 'agent-packages-local'.
Install Agent Packages
jf agent apm install runs native apm install with Artifactory credentials injected for the current process only. Those credentials aren't written to disk. Remaining arguments and native flags (--frozen, --dev, --root, --dry-run, --target, positional owner/name#version) go to apm.
When --build-name and --build-number are both set, or when you supply JFROG_CLI_BUILD_NAME and JFROG_CLI_BUILD_NUMBER, and the install isn't --dry-run, the CLI collects dependency build-info from apm.lock.yaml after a successful run (registry-sourced dependencies only). If the project has no dependencies, APM doesn't write a lockfile and build-info is skipped.
--root redirects apm_modules/ and apm.lock.yaml. Build-info collection reads the lockfile from that directory. apm.yml still resolves from the current working directory.
Synopsis
jf agent apm install [jfrog-options ...] [apm-install-args ...]JFrog options are --build-name, --build-number, --module, --project, and --server-id. They can appear before or after native APM flags. JFrog CLI removes them before invoking apm.
Build Options
The following flags apply to build-info and server selection for install and publish.
| Flag | Default | Description |
|---|---|---|
--build-name | JFROG_CLI_BUILD_NAME | Build name for local build-info. Must be provided together with --build-number. |
--build-number | JFROG_CLI_BUILD_NUMBER | Build number for local build-info. Must be provided together with --build-name. |
--module | None | Optional module name override in the build-info. Requires build name and number. |
--project | JFROG_CLI_BUILD_PROJECT | JFrog project key associated with the build-info. |
--server-id | Default server | Server ID from jf config add, used for credential injection. Never forwarded to native apm. |
Note
Providing only
--build-nameor only--build-numberfails with:the build-name and build-number options cannot be provided separately.
To install dependencies from apm.yml and record build-info:
- From the directory that contains
apm.yml, run:
jf agent apm install --build-name=<build-name> --build-number=<build-number>Full example:
jf agent apm install --build-name=docs-apm --build-number=1After a successful run, JFrog CLI prints apm install finished successfully. When build-info is collected, it also prints Collecting APM build info... and APM build info saved for <build-name>/<build-number>: <n> dependencies.
To install a package on the command line:
jf agent apm install my-org/my-package#1.0.0 --target claudeA bare #1.0.0 pin is exact. Use a range such as #^1.0.0 if later installs should pick up newer matching versions.
To preview an install without changing files or recording build-info:
jf agent apm install --dry-runPublish Agent Packages
jf agent apm publish runs native apm publish. --package <owner>/<name> is required. JFrog CLI doesn't infer the package from a positional argument.
If more than one registry is configured in ~/.apm/config.json, pass native --registry <repository-key> so APM doesn't refuse to guess the target.
On success, if --build-name and --build-number are both set and the command isn't --dry-run, the CLI records the published .zip artifact in local build-info. --zip sets the archive path whose checksum is recorded.
To publish a package and collect build-info:
- Run
jf setup apm(or declare a matchingregistries:block inapm.yml). - Run:
jf agent apm publish --package=<owner>/<name> --registry=<repository-key> --build-name=<build-name> --build-number=<build-number>- Publish the local build-info to Artifactory:
jf rt build-publish <build-name> <build-number>Full example:
jf agent apm publish --package=frog/my-package --registry=agent-packages-local --build-name=docs-apm --build-number=1
jf rt build-publish docs-apm 1Without --package, the command fails with: jf agent apm publish requires --package <owner>/<name>, e.g. --package acme/my-skill
--dry-run packs locally but uploads nothing and skips build-info.
Run Native APM Subcommands
Subcommands other than install and publish are forwarded to apm with credential injection and no build-info collection. Examples include lock, outdated, audit, view, and marketplace.
jf agent apm with no subcommand prints native apm help.
To run APM lock through JFrog CLI:
jf agent apm lockTo run a passthrough command against a named JFrog CLI server:
jf agent apm outdated --server-id=my-server--server-id is consumed by JFrog CLI and is not passed to apm. For native APM help, run jf agent apm <subcommand> --help or apm --help.
Important Notes
jf agent apmdoesn't upload build-info. Usejf rt build-publish.installandpublishcollect build-info only when both build name and build number are set.- Build-info modules use type
apm. jf agent apmdoesn't accept--repo. Configure the registry withjf setup apmorapm.ymlregistries:.- Token values aren't written during
installorpublish. Setup is the path that persists a token in~/.apm/config.json.
Troubleshooting
The following table lists common errors and how to resolve them.
| Error | Cause | Fix |
|---|---|---|
exec: "apm": executable file not found in $PATH or failed to determine apm version. Ensure apm is installed | APM isn't installed or isn't on PATH | Install APM 0.23.0 or later and ensure the apm binary is on PATH. jf agent apm install --help also requires native apm. |
JFrog CLI apm commands require apm version 0.23.0 or higher | APM is older than 0.23.0 | Upgrade APM |
jf agent apm publish requires --package | Missing --package | Pass --package owner/name |
the build-name and build-number options cannot be provided separately | Only one of the two flags or environment variables is set | Pass both, or set both JFROG_CLI_BUILD_NAME and JFROG_CLI_BUILD_NUMBER |
no APM registry found | No registry in ~/.apm/config.json or apm.yml for the Artifactory host | Run jf setup apm or add a registries: block in apm.yml |
401 / expired token | Token in ~/.apm/config.json or injected credentials expired | Re-authenticate with jf c add or jf c edit, then re-run jf setup apm |
Frequently Asked Questions
This section provides answers to frequently asked questions.
FAQs
Q: Does jf agent apm Change ~/.apm/config.json?
jf agent apm Change ~/.apm/config.json?A: jf agent apm install and jf agent apm publish inject credentials for the process only. jf setup apm is what writes ~/.apm/config.json. For more information, see Configure APM for Artifactory.
Q: When Does jf agent apm Collect Build-Info?
jf agent apm Collect Build-Info?A: After a successful install or publish, and only when both build name and build number are set. --dry-run skips build-info. Other subcommands don't collect build-info. For more information, see Install Agent Packages.
Q: How Do I Publish Build-Info to Artifactory?
A: Run jf rt build-publish <build-name> <build-number> after jf agent apm. For more information, see Build Tools.
Q: Can I Use Package Alias With apm?
apm?A: No. Package Alias doesn't create an apm shim. Run jf agent apm or native apm after jf setup apm.
Q: What Do I Need Before I Run jf agent apm?
jf agent apm?A: Install APM 0.23.0 or later on PATH, configure a JFrog CLI server with jf c add, and create a local Agent Packages repository. For more information, see Prerequisites.
Related Topics
Updated about 2 hours ago
