Run Go commands with Artifactory integration, including configuration, builds, and publishing.

This topic covers the following tasks:

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-config in the project directory before the first build.
  • Configure a server with jf config add or jf c add.
  • Authentication to Artifactory is required.

Configuration: jf go-config

Generate 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

FlagDefaultDescription
--globalfalseSet to true for global configuration (all projects). Specific projects can override.
--repo-deployRepository for artifacts deployment
--repo-resolveRepository for dependencies resolution
--server-id-deployArtifactory server ID for deployment. Configure with jf config add.
--server-id-resolveArtifactory server ID for resolution. Configure with jf config add.

Configuration Examples

View Help

jf go-config --help

Non-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-local

Why 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-resolve for fetching modules and --repo-deploy for publishing.
  • GOPROXY override: The CLI temporarily sets GOPROXY during 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.yaml

Build: jf go

Run 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

ArgumentRequiredDescription
<go-arguments>YesArguments and options for the Go command (for example, build, get, mod)

Build Options

FlagDefaultDescription
--build-nameBuild name for build-info. Requires --build-number.
--build-numberBuild number for build-info. Requires --build-name.
--moduleOptional module name for build-info. Requires --build-name and --build-number.
--no-fallbacktrueWhen true (the default), packages missing in Artifactory will not be downloaded from VCS. Set to false to allow fallback to direct VCS download.
--projectJFrog Artifactory project key

Build Examples

Run Go Build

jf go --help

Run 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=1

Run Go Get with No VCS Fallback

jf go get <package> --no-fallback

Where:

  • <package> is the Go module path (e.g., github.com/example/lib)

For example:

jf go get github.com/example/lib --no-fallback

Publish: jf go-publish

Publish 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

ArgumentRequiredDescription
<project-version>YesPackage version to publish (for example, v1.0.0)

Publish Options

FlagDefaultDescription
--build-nameBuild name for build-info. Requires --build-number.
--build-numberBuild number for build-info. Requires --build-name.
--detailed-summaryfalseSet to true to include a list of affected files in the summary
--exclusionsSemicolon-separated exclusions. Supports * and ? wildcards.
--moduleOptional module name for build-info. Requires --build-name and --build-number.
--projectJFrog Artifactory project key
--urlJFrog platform URL
--userJFrog username
--passwordJFrog password
--access-tokenJFrog access token

Publish Examples

View Help

jf go-publish --help

Publish a Package Version

jf go-publish v1.0.0

Publish with Build-Info and Detailed Summary

jf go-publish v1.0.0 --build-name=my-app --build-number=1 --detailed-summary

Publish with Exclusions

jf go-publish v1.0.0 --exclusions="test/*;*.md"

Important Notes

  • VCS fallback: By default, --no-fallback is true, 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 GOPROXY to point at your Artifactory Go repository. This overrides any existing GOPROXY setting for the duration of the command.
  • Build-info: Use --build-name and --build-number to collect dependency information, then publish with jf rt build-publish.
  • Version format: The version must follow Go module versioning (for example, v1.0.0, v2.1.3). The v prefix is required.
  • Exclusions: Use --exclusions to 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: GOPROXY environment variable is temporarily overridden during jf go execution. Check with go env GOPROXY after 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

SymptomCauseFix
no config file was foundjf go-config was not runRun jf go-config in the project directory
404 on jf go buildResolution repository does not exist or module not cachedVerify --repo-resolve matches an existing Go virtual repository; set --no-fallback=false to allow VCS fallback
401 / 403 errorsInvalid credentials or insufficient permissionsRe-run jf config add with a valid access token
Module version rejected by ArtifactoryVersion does not follow vX.Y.Z formatEnsure the version starts with v (for example, v1.0.0)
GOPROXY conflictsExisting GOPROXY overridden during CLI executionThe CLI sets GOPROXY temporarily; this is expected behavior
jf go-publish uploads unwanted filesTest or doc files includedUse --exclusions="test/*;*.md" to exclude them

Enable debug logging: export JFROG_CLI_LOG_LEVEL=DEBUG


Related Topics