Skip to content

Commit

Permalink
Support for a new JFROG_CLI_RELEASES_REPO environment variable (#1918)
Browse files Browse the repository at this point in the history
  • Loading branch information
omerzi committed May 2, 2023
1 parent 56c37e1 commit 5a8d97a
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 30 deletions.
28 changes: 26 additions & 2 deletions artifactory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4925,7 +4925,7 @@ func TestGetExtractorsRemoteDetails(t *testing.T) {

// Set 'JFROG_CLI_EXTRACTORS_REMOTE' and make sure extractor3.jar downloaded from a remote repo 'test-remote-repo' in ServerId.
testRemoteRepo := "test-remote-repo"
setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, utils.ExtractorsRemoteEnv, tests.ServerId+"/"+testRemoteRepo)
setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, coreutils.ExtractorsRemoteEnv, tests.ServerId+"/"+testRemoteRepo)
defer setEnvCallBack()
downloadPath = "org/jfrog/buildinfo/build-info-extractor/extractor3.jar"
expectedRemotePath = path.Join(testRemoteRepo, downloadPath)
Expand All @@ -4938,7 +4938,31 @@ func validateExtractorRemoteDetails(t *testing.T, downloadPath, expectedRemotePa
serverDetails, remotePath, err := utils.GetExtractorsRemoteDetails(downloadPath)
assert.NoError(t, err)
assert.Equal(t, expectedRemotePath, remotePath)
assert.False(t, os.Getenv(utils.ExtractorsRemoteEnv) != "" && serverDetails == nil, "Expected a server to be returned")
assert.False(t, os.Getenv(coreutils.ExtractorsRemoteEnv) != "" && serverDetails == nil, "Expected a server to be returned")
}

func TestGetReleasesRemoteDetails(t *testing.T) {
initArtifactoryTest(t, "")
_, err := createServerConfigAndReturnPassphrase(t)
assert.NoError(t, err)
defer deleteServerConfig(t)

// Set 'JFROG_CLI_RELEASES_REPO' and make sure extractor3.jar downloaded from a remote repo 'test-remote-repo' in ServerId.
testRemoteRepo := "test-remote-repo"
setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, coreutils.ReleasesRemoteEnv, tests.ServerId+"/"+testRemoteRepo)
defer setEnvCallBack()
downloadPath := "org/jfrog/buildinfo/build-info-extractor/extractor3.jar"
expectedRemotePath := path.Join(testRemoteRepo, "artifactory", "oss-release-local", downloadPath)
validateReleasesRemoteDetails(t, downloadPath, expectedRemotePath)

cleanArtifactoryTest()
}

func validateReleasesRemoteDetails(t *testing.T, downloadPath, expectedRemotePath string) {
serverDetails, remotePath, err := utils.GetExtractorsRemoteDetails(downloadPath)
assert.NoError(t, err)
assert.Equal(t, expectedRemotePath, remotePath)
assert.False(t, os.Getenv(coreutils.ReleasesRemoteEnv) != "" && serverDetails == nil, "Expected a server to be returned")
}

func TestVcsProps(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion docs/artifactory/gradle/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/jfrog/jfrog-cli/docs/common"

var Usage = []string{"rt gradle <tasks and options> [command options]"}

var EnvVar = []string{common.JfrogCliExtractorsRemote, common.JfrogCliDependenciesDir}
var EnvVar = []string{common.JfrogCliReleasesRepo, common.JfrogCliDependenciesDir}

func GetDescription() string {
return "Run Gradle build."
Expand Down
2 changes: 1 addition & 1 deletion docs/artifactory/mvn/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/jfrog/jfrog-cli/docs/common"

var Usage = []string{"rt mvn <goals and options> [command options]"}

var EnvVar = []string{common.JfrogCliExtractorsRemote, common.JfrogCliDependenciesDir}
var EnvVar = []string{common.JfrogCliReleasesRepo, common.JfrogCliDependenciesDir}

func GetDescription() string {
return "Run Maven build."
Expand Down
2 changes: 1 addition & 1 deletion docs/buildtools/gradle/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/jfrog/jfrog-cli/docs/common"

var Usage = []string{"gradle <tasks and options> [command options]"}

var EnvVar = []string{common.JfrogCliExtractorsRemote, common.JfrogCliDependenciesDir}
var EnvVar = []string{common.JfrogCliReleasesRepo, common.JfrogCliDependenciesDir}

func GetDescription() string {
return "Run Gradle build."
Expand Down
2 changes: 1 addition & 1 deletion docs/buildtools/mvn/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/jfrog/jfrog-cli/docs/common"

var Usage = []string{"mvn <goals and options> [command options]"}

var EnvVar = []string{common.JfrogCliExtractorsRemote, common.JfrogCliDependenciesDir}
var EnvVar = []string{common.JfrogCliReleasesRepo, common.JfrogCliDependenciesDir}

func GetDescription() string {
return "Run Maven build."
Expand Down
13 changes: 7 additions & 6 deletions docs/common/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ const (
The search will run on the first five remote repositories within the virtual repository.
This feature is experimental and available on Artifactory version 7.17.0 or higher.`

JfrogCliExtractorsRemote = ` JFROG_CLI_EXTRACTORS_REMOTE
Configured Artifactory server ID and repository name from which to download the jar needed by the mvn/gradle command.
This environment variable's value format should be <server ID>/<repo name>.
The repository should proxy https://releases.jfrog.io/artifactory/oss-release-local.
Support by the following commands: maven and gradle`
JfrogCliReleasesRepo = ` JFROG_CLI_RELEASES_REPO
Configured Artifactory repository name from which to download the jar needed by the mvn/gradle command.
This environment variable's value format should be <server ID configured by the 'jf c add' command>/<repo name>.
The repository should proxy https://releases.jfrog.io.
This environment variable is used by the 'jf mvn' and 'jf gradle' commands, and also by the 'jf audit' command, when used for maven or gradle projects.`

JfrogCliDependenciesDir = ` JFROG_CLI_DEPENDENCIES_DIR
[Default: $JFROG_CLI_HOME_DIR/dependencies]
Expand Down Expand Up @@ -107,7 +108,7 @@ func GetGlobalEnvVars() string {
JfrogCliPluginsServer,
JfrogCliPluginsRepo,
JfrogCliTransitiveDownloadExperimental,
JfrogCliExtractorsRemote,
JfrogCliReleasesRepo,
JfrogCliDependenciesDir,
JfrogCliMinChecksumDeploySizeKb,
JfrogCliBuildUrl,
Expand Down
4 changes: 2 additions & 2 deletions documentation/CLI-for-JFrog-Artifactory.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

This page describes how to use JFrog CLI with JFrog Artifactory.

Read more about JFrog CLI [here](https://jfrog.com/help/r/jfrog-cli).
Read more about JFrog CLI [here](https://jfrog.com/help/r/jfrog-cli/environment-variables).

## Environment Variables

Expand All @@ -14,7 +14,7 @@ The Artifactory upload command makes use of the following environment variable:
| --- | --- |
| **Variable Name** | **Description** |
| **JFROG\_CLI\_MIN\_CHECKSUM\_DEPLOY\_SIZE\_KB** | \[Default: 10\]<br><br>Minimum file size in KB for which JFrog CLI performs checksum deploy optimization. |
| **JFROG\_CLI\_EXTRACTORS_REMOTE** | Configured Artifactory server ID (configured by the "jfrog c add command") and repository name from which to download the jar needed by the "jf mvn" and "jf gradle" commands. This environment variables value format should be &lt;server ID&gt;/&lt;repo name&gt;. The repository should proxy [https://releases.jfrog.io/artifactory/oss-release-local](https://releases.jfrog.io/artifactory/oss-release-local). |
| **JFROG\_CLI\_RELEASES_REPO** | Configured Artifactory repository name from which to download the jar needed by the mvn/gradle command.<br> This environment variable's value format should be `<server ID configured by the 'jf c add' command>/<repo name>`.<br> The repository should proxy https://releases.jfrog.io.<br> This environment variable is used by the 'jf mvn' and 'jf gradle' commands, and also by the 'jf audit' command, when used for maven or gradle projects. |
| **JFROG\_CLI\_DEPENDENCIES_DIR** | \[Default: $JFROG\_CLI\_HOME_DIR/dependencies\]<br><br>Defines the directory to which JFrog CLI's internal dependencies are downloaded. |
| **JFROG\_CLI\_REPORT_USAGE** | \[Default: true\]<br><br>Set to false to block JFrog CLI from sending usage statistics to Artifactory. |
| **JFROG\_CLI\_BUILD_NAME** | Build name to be used by commands which expect a build name, unless sent as a command argument or option. |
Expand Down
21 changes: 11 additions & 10 deletions documentation/JFrog-CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,16 +270,17 @@ The **jf options** command displays all the supported environment variables.

JFrog CLI makes use of the following environment variables:

| | |
| --- | --- |
| **Variable Name** | **Description** |
| **JFROG\_CLI\_LOG_LEVEL** | \[Default: INFO\]<br><br>This variable determines the log level of the JFrog CLI. <br>Possible values are: INFO, ERROR, and DEBUG. <br>If set to ERROR, JFrog CLI logs error messages only. It is useful when you wish to read or parse the JFrog CLI output and do not want any other information logged. |
| **JFROG\_CLI\_LOG_TIMESTAMP** | \[Default: TIME\]<br><br>Controls the log messages timestamp format. Possible values are: TIME, DATE\_AND\_TIME, and OFF. |
| **JFROG\_CLI\_HOME_DIR** | \[Default: ~/.jfrog\]<br><br>Defines the JFrog CLI home directory. |
| **JFROG\_CLI\_TEMP_DIR** | \[Default: The operating system's temp directory\]<br><br>Defines the temp directory used by JFrog CLI. |
| **JFROG\_CLI\_PLUGINS_SERVER** | \[Default: Official JFrog CLI Plugins registry\]<br><br>Configured Artifactory server ID from which to download JFrog CLI Plugins. |
| **JFROG\_CLI\_PLUGINS_REPO** | \[Default: 'jfrog-cli-plugins'\]<br><br>Can be optionally used with the JFROG\_CLI\_PLUGINS_SERVER environment variable. Determines the name of the local repository to use. |
| **CI** | \[Default: false\]<br><br>If true, disables interactive prompts and progress bar. |
| | |
|--------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **Variable Name** | **Description** |
| **JFROG\_CLI\_LOG_LEVEL** | \[Default: INFO\]<br><br>This variable determines the log level of the JFrog CLI. <br>Possible values are: INFO, ERROR, and DEBUG. <br>If set to ERROR, JFrog CLI logs error messages only. It is useful when you wish to read or parse the JFrog CLI output and do not want any other information logged. |
| **JFROG\_CLI\_LOG_TIMESTAMP** | \[Default: TIME\]<br><br>Controls the log messages timestamp format. Possible values are: TIME, DATE\_AND\_TIME, and OFF. |
| **JFROG\_CLI\_HOME_DIR** | \[Default: ~/.jfrog\]<br><br>Defines the JFrog CLI home directory. |
| **JFROG\_CLI\_TEMP_DIR** | \[Default: The operating system's temp directory\]<br><br>Defines the temp directory used by JFrog CLI. |
| **JFROG\_CLI\_PLUGINS_SERVER** | \[Default: Official JFrog CLI Plugins registry\]<br><br>Configured Artifactory server ID from which to download JFrog CLI Plugins. |
| **JFROG\_CLI\_PLUGINS_REPO** | \[Default: 'jfrog-cli-plugins'\]<br><br>Can be optionally used with the JFROG\_CLI\_PLUGINS_SERVER environment variable. Determines the name of the local repository to use. |
| **JFROG\_CLI\_RELEASES_REPO** | Configured Artifactory repository name from which to download the jar needed by the mvn/gradle command.<br> This environment variable's value format should be `<server ID configured by the 'jf c add' command>/<repo name>`.<br> The repository should proxy https://releases.jfrog.io.<br> This environment variable is used by the 'jf mvn' and 'jf gradle' commands, and also by the 'jf audit' command, when used for maven or gradle projects. |
| **CI** | \[Default: false\]<br><br>If true, disables interactive prompts and progress bar. |

## JFrog Platform Configuration

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ require (

// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20230316095417-a9f6b73206d7

replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20230423150914-af631338e74b
replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20230430083747-590ae14f9dca

replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230427132104-0046ec524f06
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230501144900-694655cd7157

replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.2.6-0.20230418122323-2bf299dd6d27
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ github.com/jfrog/build-info-go v1.9.2 h1:gSX9PH3whFcAMtM9dlPxRE7u9YuYcx8IkfVXQKR
github.com/jfrog/build-info-go v1.9.2/go.mod h1:hHXyLsG0SW1jQa4g6q8x2LGAvvX/MMqWVFTcIUAF2PI=
github.com/jfrog/gofrog v1.2.6-0.20230418122323-2bf299dd6d27 h1:jX3UD9qVfj9cuyOe7pN7LlB9JKH5A/3vctjnBpWCKsU=
github.com/jfrog/gofrog v1.2.6-0.20230418122323-2bf299dd6d27/go.mod h1:IFMc+V/yf7rA5WZ74CSbXe+Lgf0iApEQLxRZVzKRUR0=
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230427132104-0046ec524f06 h1:mPSYSlYUn04Bf3LIoiDLSEBV2arZcCWVZPjR4yDcask=
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230427132104-0046ec524f06/go.mod h1:zdbsIPETzd5S/Q9wg0OF2vZKF4IiL+TizdNGV2sdqK0=
github.com/jfrog/jfrog-client-go v1.28.1-0.20230423150914-af631338e74b h1:Bgzk+ujbw09b/ALcKcddkKwQNXmTd1LXiNV5LvBBnd0=
github.com/jfrog/jfrog-client-go v1.28.1-0.20230423150914-af631338e74b/go.mod h1:X5LKqXKQByyxVvP/MpqYQZdR5eIvdoC6uyn6EtKw8H0=
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230501144900-694655cd7157 h1:sLU1V+0DgFaacrWttIGPEQMYawpGR55M11uMO9N56no=
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20230501144900-694655cd7157/go.mod h1:pkkh6sYQkWgQTHwzLvfvrz+mBpBW3XCplumRGjAI5Vg=
github.com/jfrog/jfrog-client-go v1.28.1-0.20230430083747-590ae14f9dca h1:khI87cFWk8NKf8pJ2rs81V80KLN8Ex3EqEGbMP3VJG8=
github.com/jfrog/jfrog-client-go v1.28.1-0.20230430083747-590ae14f9dca/go.mod h1:X5LKqXKQByyxVvP/MpqYQZdR5eIvdoC6uyn6EtKw8H0=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/jszwec/csvutil v1.8.0 h1:G7vS2LGdpZZDH1HmHeNbxOaJ/ZnJlpwGFvOkTkJzzNk=
Expand Down

0 comments on commit 5a8d97a

Please sign in to comment.