Use apk with JFrog CLI
Configure and run jf apk with JFrog Artifactory for Alpine package install, upload, credential injection, and build-info collection.
Run Alpine Package Keeper (apk) commands with Artifactory integration for credential injection, optional build-info collection, and package upload.
This topic covers the following tasks:
- Configure apk for Artifactory (
jf setup apk) - Install and upgrade packages (
jf apk addandjf apk upgrade) - Upload packages (
jf apk upload) - Passthrough native apk subcommands
When to Use
Use jf apk on Alpine Linux when you resolve or publish .apk packages through Artifactory and want JFrog CLI to inject credentials and optionally record build-info.
- Run
jf setup apkonce per environment to point/etc/apk/repositoriesat an Artifactory Alpine repository and to install the repository RSA public key under/etc/apk/keys/. - Run
jf apk addorjf apk upgradeto install or upgrade packages with optional build-info. - Run
jf apk uploadto publish a local.apkfile to Artifactory. - Run other native
apksubcommands throughjf apkwhen you want credential injection without build-info.
If you do not need build-info or JFrog-managed credentials, you can configure apk manually. For repository layout and Set Me Up snippets, see Alpine Linux Repositories.
Note
Package Alias (Ghost Frog) can intercept
apkwhen you install theapkalias. Supported tools includemvn,gradle,npm,yarn,pnpm,go,pip,pipenv,poetry,dotnet,nuget,docker,gem,bundle, andapk. See Use JFrog CLI Package Alias for setup.
Prerequisites
- Alpine Linux environment for wrapped
apkcommands:jf apk add,jf apk upgrade, and other native wrappers require theapkbinary onPATH. Verify withapk --version. For authenticated repository access throughHTTP_AUTH, use apk-tools 2.12 or later. - JFrog CLI installed and authenticated: Install or upgrade from the JFrog CLI quick start, then configure a server with
jf config addorjf c add. The CLI uses this configuration (default server, or the server named by--server-id) for credential injection and uploads. - Artifactory Alpine repositories: Create local, remote, and virtual Alpine repositories as needed. Prefer a virtual repository for resolution. Attach an RSA key pair to the repository you use for signed indexes. See Alpine Linux Repositories.
- Root or write access for setup:
jf setup apkwrites/etc/apk/repositoriesand files under/etc/apk/keys/. Package install and upgrade also require the privileges that nativeapkrequires. - Optional: Set
JFROG_HOMEif you use a non-default directory for JFrog CLI configuration files.
Configure: jf setup apk
jf setup apkjf setup apk configures the local Alpine client to use an Artifactory Alpine repository. It downloads the repository RSA public key and updates /etc/apk/repositories.
There is no jf apk config command. Use jf setup apk.
To configure apk for Artifactory:
- Configure a JFrog CLI server with
jf c add(orjf config add). - Run
jf setup apk --server-id=<server-id> --repo=<repo-key>(or omit--repoto select interactively). - Confirm that the RSA public key is written under
/etc/apk/keys/and that/etc/apk/repositoriespoints at Artifactory.
Synopsis
jf setup apk [--server-id=<server-id>] [--repo=<repo-key>]
Options
The following options configure the Alpine client.
| Flag | Default | Description |
|---|---|---|
--server-id | Default server | JFrog CLI server ID from jf config add |
--repo | Interactive selection | Artifactory Alpine repository key. When omitted, the CLI prompts for repository type (virtual recommended, then local or remote) and repository selection |
When Alpine version detection succeeds (from /etc/alpine-release), the repository URL uses the layout https://<artifactory-host>/artifactory/<repo-key>/<alpine-version>/main/. Setup embeds the configured username and password or access token in that URL so native apk can authenticate.
Warning
jf setup apkembeds credentials in the/etc/apk/repositoriesURL. If you use a short-lived access token, nativeapkcommands can fail with permission errors after the token expires because nothing refreshes that file. Re-runjf setup apkto refresh credentials, or configure the server with a username and password (or a longer-lived token). Preferjf apkfor day-to-day install and upgrade so the CLI can injectHTTP_AUTHfrom your server configuration without relying only on the embedded URL.
Example
jf setup apk --server-id=my-server --repo=my-alpine-repoOn success, the CLI logs that the APK repository is configured and that the RSA signing key was written under /etc/apk/keys/.
Build: jf apk
jf apkjf apk runs the native apk binary with stdin, stdout, and stderr passed through. JFrog CLI removes its own options from the argument list, injects HTTP_AUTH into the apk subprocess environment when a server is configured, and can collect build-info after a successful add or upgrade.
HTTP_AUTH uses the format basic:<hostname>:<username>:<password-or-token>, where <hostname> is the Artifactory host only (no scheme or path). At debug log level, the CLI masks the secret as HTTP_AUTH=basic:<host>:<user>:***.
When --build-name and --build-number are both set (or supplied via JFROG_CLI_BUILD_NAME and JFROG_CLI_BUILD_NUMBER), the CLI records newly installed or upgraded packages in a build-info module of type apk. Dependency IDs use the name:version format. When --module is omitted, the default module ID is <repo>:<arch>:<alpine-version> when those values are available.
Passing --repo does not permanently change /etc/apk/repositories. For a single command, the CLI can isolate repository selection when --repo or --server-id requires it. For lasting client configuration, run jf setup apk.
To run native apk commands with credentials and optional build-info:
- Run
jf apk addorjf apk upgradewith the package arguments you need. - (Optional) Add
--build-nameand--build-numberto collect build-info. - Publish collected build-info with
jf rt build-publish <build-name> <build-number>.
Synopsis
jf apk add <packages...> [command options]
jf apk upgrade [packages...] [command options]
jf apk <native-subcommand> [args...] [command options]
Aliases: none for the apk command group. The upload subcommand also accepts u as a short alias for upload.
Arguments
The following arguments are accepted by jf apk.
| Argument | Required | Description |
|---|---|---|
<packages...> | For add | One or more package names forwarded to native apk |
| Remaining args | No | After JFrog-specific options are removed, only native apk flags and arguments remain and are forwarded to apk |
Build Options
The following options control build-info collection and Artifactory access.
| Flag | Default | Description |
|---|---|---|
--server-id | Default server | JFrog CLI server ID used for credential injection and checksum enrichment. An unknown explicit --server-id fails immediately |
--repo | (none) | Artifactory Alpine repository key. Optional for build-info. Used for repository validation, isolated resolution when needed, and Artifactory Query Language (AQL) checksum enrichment |
--alpine-version | (none) | Alpine release, for example v3.20. Used when selecting Artifactory paths and default module IDs |
--user | From server config | Override Artifactory username |
--password | From server config | Override Artifactory password or token |
--build-name | (none) | Logical build name. Requires --build-number when set. Env fallback: JFROG_CLI_BUILD_NAME |
--build-number | (none) | Build number or CI ID. Requires --build-name when set. Env fallback: JFROG_CLI_BUILD_NUMBER |
--module | <repo>:<arch>:<alpine-version> when available | Overrides the build-info module ID |
--project | (none) | Associates the build-info with a JFrog Project. Env fallback: JFROG_CLI_BUILD_PROJECT |
--branch | main | Alpine repository branch for jf apk upload only, for example main or community. See Upload Options |
All other flags pass through to apk unchanged.
Build Examples
Install packages
jf apk add curl bashInstall with build-info
jf apk add curl bash --build-name=<build-name> --build-number=<build-number>Where:
<build-name>is the logical name for the build<build-number>is the build ID (for example a CI run number)
For example:
jf apk add curl bash --build-name=ci-image --build-number=42Install with an explicit server and repository
jf apk add curl --server-id=<server-id> --repo=<repo-key> --build-name=<build-name> --build-number=<build-number>For example:
jf apk add curl --server-id=my-server --repo=my-alpine-repo --build-name=ci-image --build-number=42Upgrade packages
jf apk upgrade --server-id=my-server --repo=my-alpine-repoBuild-info from environment variables
export JFROG_CLI_BUILD_NAME=ci-image
export JFROG_CLI_BUILD_NUMBER=7
jf apk add curlPublish build-info to Artifactory
jf rt build-publish <build-name> <build-number>For example:
jf rt build-publish ci-image 42The following subcommands collect build-info when --build-name and --build-number are both set.
| apk subcommand | Dependencies in build-info | Artifacts in build-info |
|---|---|---|
add, upgrade | Yes (newly installed or upgraded packages) | No |
upload | Optional related dependency metadata | Yes (uploaded .apk) |
| Other native subcommands | No (warning if build-info flags are set) | No |
Checksums are collected from cached .apk archives when possible. When --repo is set, the CLI can enrich missing checksums from Artifactory with AQL. Using apk --no-cache limits local checksum collection; drop --no-cache when you need complete local checksums in build-info.
Publish: jf apk upload
jf apk uploadjf apk upload publishes a local .apk file to an Artifactory Alpine repository. Upload is a REST operation and does not require a local apk binary.
To upload an Alpine package:
- Run
jf apk uploadwith the package file, repository, and Alpine version. - (Optional) Add build-info options to record the uploaded artifact.
Synopsis
jf apk upload <file.apk> --repo <repo-key> --alpine-version <vX.Y> [command options]
Aliases: jf apk u
Arguments
The following argument identifies the package to upload.
| Argument | Required | Description |
|---|---|---|
<file.apk> | Yes | Path to the local Alpine package file |
Upload Options
The following options control the upload destination and build-info collection.
| Flag | Default | Description |
|---|---|---|
--repo | Resolved from /etc/apk/repositories when possible | Artifactory Alpine repository key. Required unless setup already configured a matching Artifactory URL in /etc/apk/repositories |
--alpine-version | Host /etc/alpine-release when detectable | Alpine release used in the upload path, for example v3.20. Required when auto-detection is unavailable |
--branch | main | Alpine repository branch, for example main or community |
--arch | From package .PKGINFO, then system arch | CPU architecture override (x86_64, aarch64, armhf, and similar) |
--server-id | Default server | JFrog CLI server ID |
--user and --password | From server config | Optional credential overrides |
--build-name and --build-number | (none) | Record the uploaded artifact in local build-info when both are set |
--module | <repo>:<arch>:<alpine-version> when available | Overrides the build-info module ID |
--project | (none) | Associates the build-info with a JFrog Project. Env fallback: JFROG_CLI_BUILD_PROJECT |
Upload path and properties
The CLI uploads to:
<repo-key>/<alpine-version>/<branch>/<arch>/<filename>
For example: my-alpine-repo/v3.20/main/x86_64/myapp-1.0.0-r0.x86_64.apk.
On upload, the CLI sets artifact properties including os.name=alpine, os.version=<alpine-version>, os.arch=<arch>, apk.name=<name>, and apk.version=<version>.
Upload Examples
jf apk upload ./myapp-1.0.0-r0.x86_64.apk --repo=my-alpine-repo --alpine-version=v3.20jf apk upload ./myapp-1.0.0-r0.x86_64.apk \
--repo=my-alpine-repo \
--alpine-version=v3.20 \
--branch=main \
--build-name=ci-image \
--build-number=42Passthrough Native apk Subcommands
Every other native apk subcommand runs as a passthrough: JFrog flags are accepted, credentials are injected when a server is configured, and remaining arguments are forwarded to apk. Build-info is not collected. If you pass build-info flags on a passthrough command, the CLI prints a warning after execution.
Passthrough examples include update, fetch, search, del, info, fix, audit, version, and stats.
To pass through a native apk subcommand:
- Run the subcommand through
jf apk. - Add JFrog CLI options when you need credential injection or a specific repository.
jf apk update
jf apk search curl
jf apk info muslImportant Notes
- After collecting build-info locally, publish it to Artifactory with
jf rt build-publish <build-name> <build-number>(aliasjf rt bp). - If no JFrog server is configured, the CLI skips
HTTP_AUTHinjection and warns you to runjf c add. - An explicit unknown
--server-idis a hard error. Omit--server-idto use the default server. - Signature verification failures can include a hint to run
jf setup apkso the RSA public key is installed. jf apk add,jf apk upgrade, and other wrappers that invoke nativeapktarget Alpine Linux.jf apk uploadcan run wherever JFrog CLI can reach Artifactory.
Environment Variables
The following environment variables configure build-info collection and credential injection.
| Variable | Default | Description |
|---|---|---|
JFROG_CLI_BUILD_NAME | (none) | When set with JFROG_CLI_BUILD_NUMBER, enables build-info collection without passing --build-name and --build-number |
JFROG_CLI_BUILD_NUMBER | (none) | Companion to JFROG_CLI_BUILD_NAME |
JFROG_CLI_BUILD_PROJECT | (none) | Same effect as --project when not passed on the command line |
HTTP_AUTH | (none) | If already set and you do not pass explicit --user and --password, the CLI keeps the existing value. Explicit flags override it |
JFROG_CLI_LOG_LEVEL | INFO | Set to DEBUG to see masked HTTP_AUTH debug output and other diagnostics |
Dockerfile Example
FROM alpine:3.20
# Install JFrog CLI (pin the release URL your organization uses)
RUN wget -qO /usr/local/bin/jf https://releases.jfrog.io/artifactory/jfrog-cli/v2-jf/jfrog-cli-linux-amd64/jf && \
chmod +x /usr/local/bin/jf
# Configure the Artifactory server non-interactively in CI, then:
RUN jf setup apk --server-id="$JF_SERVER_ID" --repo="$JF_ALPINE_REPO"
RUN jf apk add curl bash jq \
--server-id="$JF_SERVER_ID" \
--repo="$JF_ALPINE_REPO" \
--build-name="$JFROG_CLI_BUILD_NAME" \
--build-number="$JFROG_CLI_BUILD_NUMBER"Provide server credentials through your CI secret mechanism before jf setup apk and jf apk add.
Troubleshooting
The following table lists common issues and resolutions.
| Symptom | Cause | Fix |
|---|---|---|
'apk' binary not found. Is this an Alpine Linux environment? | Native apk is missing from PATH | Run wrapped install or upgrade commands inside Alpine Linux, or use jf apk upload on any platform |
| Signature verification failed | RSA public key missing or outdated under /etc/apk/keys/ | Run jf setup apk --server-id=<id> --repo=<repo> |
No server configured — skipping HTTP_AUTH injection | No default JFrog CLI server | Run jf c add, or pass a valid --server-id |
server ID "..." not found in configuration | Unknown --server-id | Add the server with jf c add, or omit --server-id |
Permission denied after token expiry on native apk | Embedded token in /etc/apk/repositories expired | Re-run jf setup apk, or use jf apk with a refreshed server config |
Incomplete build-info checksums with --no-cache | Downloaded archives were not kept locally | Drop --no-cache, or pass --repo so AQL enrichment can fill checksums from Artifactory |
| No build-info after the command | Build-info flags or env vars not both set, or subcommand does not support collection | Pass both --build-name and --build-number (or both env vars) on add, upgrade, or upload |
| Warning that build-info is unavailable for a subcommand | Passthrough command with build-info flags | Use add, upgrade, or upload for build-info |
| apk-tools older than 2.12 warning | HTTP_AUTH may be unsupported | Upgrade apk-tools to 2.12 or later |
Enable debug logging: export JFROG_CLI_LOG_LEVEL=DEBUG
Frequently Asked Questions
This section provides answers to frequently asked questions about using apk with JFrog CLI.
FAQs
Q: How do I point apk at Artifactory?
A: Run jf setup apk --server-id=<server-id> --repo=<repo-key>. See Configure: jf setup apk.
Q: Is there a jf apk config command?
A: No. Use jf setup apk to configure the Alpine client for Artifactory.
Q: Does jf apk add write credentials into /etc/apk/repositories?
A: No. jf apk add injects HTTP_AUTH into the subprocess environment. jf setup apk is the command that updates /etc/apk/repositories and can embed credentials there.
Q: Which commands collect build-info?
A: jf apk add, jf apk upgrade, and jf apk upload when --build-name and --build-number are set (or the matching environment variables). Then publish with jf rt build-publish.
Q: What build-info module type does Alpine use?
A: The module type is apk.
Related Topics
Updated about 10 hours ago
