jf go
Run Go commands with Artifactory integration, including configuration, builds, and publishing.
This topic covers the following tasks:
- Configure Go for Artifactory (
jf go-config) - Run Go commands (
jf go) - Publish Go modules (
jf go-publish)
When to Use
Use jf go if your Go project uses Go modules (go.mod) and you want dependencies resolved from Artifactory. The CLI wraps go build, go get, and other Go commands while setting GOPROXY to point at your Artifactory Go repository.
Prerequisites
- Go must be installed (Go 1.16+ recommended for module support).
- Run
jf go-configin the project directory before the first build. - Configure a server with
jf config addorjf c add. - Authentication to Artifactory is required.
Configuration: jf go-config
jf go-configGenerate Go build configuration for dependency resolution and deployment. Run this once per project before your first build.
To configure Go for Artifactory:
Synopsis
jf go-config [options]
Aliases: goc
Configuration Options
| Flag | Default | Description |
|---|---|---|
--global | false | Set to true for global configuration (all projects). Specific projects can override. |
--repo-deploy | — | Repository for artifacts deployment |
--repo-resolve | — | Repository for dependencies resolution |
--server-id-deploy | — | Artifactory server ID for deployment. Configure with jf config add. |
--server-id-resolve | — | Artifactory server ID for resolution. Configure with jf config add. |
Configuration Examples
View Help
jf go-config --helpNon-Interactive Configuration with Flags
jf go-config --server-id-resolve=<server-id> --repo-resolve=<repo-name> --server-id-deploy=<server-id> --repo-deploy=<repo-name>Where:
- <server-id>: The server ID configured using
jf config add - <repo-name>: The name of the repository in Artifactory
For example:
jf go-config --server-id-resolve=my-server --repo-resolve=go-virtual --server-id-deploy=my-server --repo-deploy=go-localWhy Run Config First?
You must run jf go-config before jf go or jf go-publish. The config tells the CLI which Artifactory Go repositories to use, setting GOPROXY automatically during builds. Without it, jf go does not know where to fetch or publish modules.
Shortcut: In CI/CD, pass all flags non-interactively so the config step is fully automated and reproducible.
Configuration Notes
- Run once per project: Configuration persists in
.jfrog/projects/go.yaml. - Resolution and deployment: Use
--repo-resolvefor fetching modules and--repo-deployfor publishing. - GOPROXY override: The CLI temporarily sets
GOPROXYduring execution, overriding any system setting.
Expected Output
$ jf go-config --server-id-resolve=my-server --repo-resolve=go-virtual --server-id-deploy=my-server --repo-deploy=go-local
Go build configuration saved successfully.
How to Verify
After running, confirm the configuration exists:
cat .jfrog/projects/go.yamlBuild: jf go
jf goRun Go commands with Artifactory integration and optional build-info collection.
To run Go commands with Artifactory integration:
Synopsis
jf go <go-arguments> [options]
Aliases: none
Arguments
| Argument | Required | Description |
|---|---|---|
<go-arguments> | Yes | Arguments and options for the Go command (for example, build, get, mod) |
Build Options
| Flag | Default | Description |
|---|---|---|
--build-name | — | Build name for build-info. Requires --build-number. |
--build-number | — | Build number for build-info. Requires --build-name. |
--module | — | Optional module name for build-info. Requires --build-name and --build-number. |
--no-fallback | true | When true (the default), packages missing in Artifactory will not be downloaded from VCS. Set to false to allow fallback to direct VCS download. |
--project | — | JFrog Artifactory project key |
Build Examples
Run Go Build
jf go --helpRun Go with Build-Info Collection
jf go build --build-name=<build-name> --build-number=<build-number>Where:
<build-name>is a name for the build (e.g.,my-go-app)<build-number>is a number or identifier for the build run (e.g.,1)
For example:
jf go build --build-name=my-go-app --build-number=1Run Go Get with No VCS Fallback
jf go get <package> --no-fallbackWhere:
<package>is the Go module path (e.g.,github.com/example/lib)
For example:
jf go get github.com/example/lib --no-fallbackPublish: jf go-publish
jf go-publishPublish a Go package and its dependencies to Artifactory.
To publish a Go package to Artifactory:
Synopsis
jf go-publish <project-version> [options]
Aliases: gp
Arguments
| Argument | Required | Description |
|---|---|---|
<project-version> | Yes | Package version to publish (for example, v1.0.0) |
Publish Options
| Flag | Default | Description |
|---|---|---|
--build-name | — | Build name for build-info. Requires --build-number. |
--build-number | — | Build number for build-info. Requires --build-name. |
--detailed-summary | false | Set to true to include a list of affected files in the summary |
--exclusions | — | Semicolon-separated exclusions. Supports * and ? wildcards. |
--module | — | Optional module name for build-info. Requires --build-name and --build-number. |
--project | — | JFrog Artifactory project key |
--url | — | JFrog platform URL |
--user | — | JFrog username |
--password | — | JFrog password |
--access-token | — | JFrog access token |
Publish Examples
View Help
jf go-publish --helpPublish a Package Version
jf go-publish v1.0.0Publish with Build-Info and Detailed Summary
jf go-publish v1.0.0 --build-name=my-app --build-number=1 --detailed-summaryPublish with Exclusions
jf go-publish v1.0.0 --exclusions="test/*;*.md"Important Notes
- VCS fallback: By default,
--no-fallbackistrue, meaning the CLI will not fall back to the public VCS (for example, GitHub) if a module is missing in Artifactory. To allow VCS fallback, pass--no-fallback=false. - GOPROXY: The CLI sets
GOPROXYto point at your Artifactory Go repository. This overrides any existingGOPROXYsetting for the duration of the command. - Build-info: Use
--build-nameand--build-numberto collect dependency information, then publish withjf rt build-publish. - Version format: The version must follow Go module versioning (for example,
v1.0.0,v2.1.3). Thevprefix is required. - Exclusions: Use
--exclusionsto exclude test files, documentation, or other files you don't want in the published module.
Platform Notes
- Windows: Go module archive creation may behave differently with path separators. Use forward slashes in exclusion patterns.
- macOS / Linux:
GOPROXYenvironment variable is temporarily overridden duringjf goexecution. Check withgo env GOPROXYafter the command completes to verify it was restored.
CI/CD Example (GitHub Actions)
# .github/workflows/build.yml
steps:
- uses: actions/checkout@v4
- name: Setup JFrog CLI
uses: jfrog/setup-jfrog-cli@v4
env:
JF_URL: ${{ vars.JF_URL }}
JF_ACCESS_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }}
- name: Configure Go
run: jf go-config --server-id-resolve=setup-jfrog-cli-server --repo-resolve=go-virtual --server-id-deploy=setup-jfrog-cli-server --repo-deploy=go-local
- name: Build
run: jf go build --build-name=my-go-app --build-number=${{ github.run_number }} --no-fallback
- name: Publish module
run: jf go-publish v1.0.0 --build-name=my-go-app --build-number=${{ github.run_number }}
- name: Publish build info
run: jf rt build-publish my-go-app ${{ github.run_number }}Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
no config file was found | jf go-config was not run | Run jf go-config in the project directory |
404 on jf go build | Resolution repository does not exist or module not cached | Verify --repo-resolve matches an existing Go virtual repository; set --no-fallback=false to allow VCS fallback |
| 401 / 403 errors | Invalid credentials or insufficient permissions | Re-run jf config add with a valid access token |
| Module version rejected by Artifactory | Version does not follow vX.Y.Z format | Ensure the version starts with v (for example, v1.0.0) |
GOPROXY conflicts | Existing GOPROXY overridden during CLI execution | The CLI sets GOPROXY temporarily; this is expected behavior |
jf go-publish uploads unwanted files | Test or doc files included | Use --exclusions="test/*;*.md" to exclude them |
Enable debug logging: export JFROG_CLI_LOG_LEVEL=DEBUG
Related Topics
- Build Tools Overview — Capabilities matrix and tool reference
- Native Mode — Supported packages with Native Mode
Updated 8 days ago
