Skip to content

Commit

Permalink
Accept JFROG_CLI_BUILD_PROJECT env on download/search/props/copy comm…
Browse files Browse the repository at this point in the history
…ands (#1914)
  • Loading branch information
sverdlov93 committed Apr 27, 2023
1 parent 1abbd96 commit d367529
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
21 changes: 15 additions & 6 deletions artifactory/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ func downloadCmd(c *cli.Context) error {
"You can avoid this confirmation message by adding --quiet to the command.", false) {
return nil
}
// This error is being checked latter on because we need to generate summary report before return.
// This error is being checked later on because we need to generate summary report before return.
err = progressbar.ExecWithProgress(downloadCommand)
result := downloadCommand.Result()
defer cliutils.CleanupResult(result, &err)
Expand Down Expand Up @@ -2500,7 +2500,7 @@ func createDefaultCopyMoveSpec(c *cli.Context) (*spec.SpecFiles, error) {
Props(c.String("props")).
ExcludeProps(c.String("exclude-props")).
Build(c.String("build")).
Project(c.String("project")).
Project(getProject(c)).
ExcludeArtifacts(c.Bool("exclude-artifacts")).
IncludeDeps(c.Bool("include-deps")).
Bundle(c.String("bundle")).
Expand All @@ -2527,7 +2527,7 @@ func createDefaultDeleteSpec(c *cli.Context) (*spec.SpecFiles, error) {
Props(c.String("props")).
ExcludeProps(c.String("exclude-props")).
Build(c.String("build")).
Project(c.String("project")).
Project(getProject(c)).
ExcludeArtifacts(c.Bool("exclude-artifacts")).
IncludeDeps(c.Bool("include-deps")).
Bundle(c.String("bundle")).
Expand All @@ -2551,7 +2551,7 @@ func createDefaultSearchSpec(c *cli.Context) (*spec.SpecFiles, error) {
Props(c.String("props")).
ExcludeProps(c.String("exclude-props")).
Build(c.String("build")).
Project(c.String("project")).
Project(getProject(c)).
ExcludeArtifacts(c.Bool("exclude-artifacts")).
IncludeDeps(c.Bool("include-deps")).
Bundle(c.String("bundle")).
Expand All @@ -2577,7 +2577,7 @@ func createDefaultPropertiesSpec(c *cli.Context) (*spec.SpecFiles, error) {
Props(c.String("props")).
ExcludeProps(c.String("exclude-props")).
Build(c.String("build")).
Project(c.String("project")).
Project(getProject(c)).
ExcludeArtifacts(c.Bool("exclude-artifacts")).
IncludeDeps(c.Bool("include-deps")).
Bundle(c.String("bundle")).
Expand Down Expand Up @@ -2673,7 +2673,7 @@ func createDefaultDownloadSpec(c *cli.Context) (*spec.SpecFiles, error) {
Props(c.String("props")).
ExcludeProps(c.String("exclude-props")).
Build(c.String("build")).
Project(c.String("project")).
Project(getProject(c)).
ExcludeArtifacts(c.Bool("exclude-artifacts")).
IncludeDeps(c.Bool("include-deps")).
Bundle(c.String("bundle")).
Expand Down Expand Up @@ -2809,3 +2809,12 @@ func getOffsetAndLimitValues(c *cli.Context) (offset, limit int, err error) {

return
}

// Get project key from flag or environment variable
func getProject(c *cli.Context) string {
project := c.String("project")
if project == "" {
project = os.Getenv(coreutils.Project)
}
return project
}
4 changes: 2 additions & 2 deletions utils/cliutils/commandsflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ var flagsMap = map[string]cli.Flag{
},
build: cli.StringFlag{
Name: build,
Usage: "[Optional] If specified, only artifacts of the specified build are matched. The property format is build-name/build-number. If you do not specify the build number, the artifacts are filtered by the latest build number.` `",
Usage: "[Optional] If specified, only artifacts of the specified build are matched. The property format is build-name/build-number. If you do not specify the build number, the artifacts are filtered by the latest build number. If the build is assigned to a specific project please provide the project key using the --project flag.` `",
},
excludeArtifacts: cli.StringFlag{
Name: excludeArtifacts,
Expand Down Expand Up @@ -868,7 +868,7 @@ var flagsMap = map[string]cli.Flag{
},
project: cli.StringFlag{
Name: project,
Usage: "[Optional] Artifactory project key.` `",
Usage: "[Optional] JFrog Artifactory project key.` `",
},
bpDryRun: cli.BoolFlag{
Name: dryRun,
Expand Down

0 comments on commit d367529

Please sign in to comment.