Skip to content

Commit 8d5750c

Browse files
authored
New --operation flag for release bundle promote command (#2877)
1 parent 97b96b6 commit 8d5750c

File tree

5 files changed

+45
-19
lines changed

5 files changed

+45
-19
lines changed

go.mod

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,6 @@ require (
191191

192192
replace github.com/jfrog/jfrog-cli-artifactory => github.com/jfrog/jfrog-cli-artifactory v0.1.13-0.20250219071539-9bcf054e67db
193193

194-
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250212021126-e5223ab616af
194+
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250221065317-8f044fe71fea
195195

196-
replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20250219065446-e17342f27e44
197-
198-
// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20241220065541-91828d43d8b9
199-
200-
// replace github.com/jfrog/gofrog => github.com/jfrog/gofrog dev
196+
replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20250221062042-87cb5136765e

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,14 @@ github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYL
187187
github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w=
188188
github.com/jfrog/jfrog-cli-artifactory v0.1.13-0.20250219071539-9bcf054e67db h1:I9ywkE/lXJ/1S/0h2jjEWiqIKzWiJszE0VrjoGsorLk=
189189
github.com/jfrog/jfrog-cli-artifactory v0.1.13-0.20250219071539-9bcf054e67db/go.mod h1:EzlrSRtRoEipL+8axXHfgoUgXEoHZMVA6cElS2xK1w8=
190-
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250212021126-e5223ab616af h1:XnyhhyARP1YCzYGdhk8ovpyZV+hSchiTGVTuejrZXsI=
191-
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250212021126-e5223ab616af/go.mod h1:Hx2houXADsNv0eRh4w5XCS2uSsPNPn1OmiSDdwGFB7g=
190+
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250221065317-8f044fe71fea h1:ahP9eFJOw5K3AehHytj1H9nPGpswYfb3paTTwcBtwHg=
191+
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250221065317-8f044fe71fea/go.mod h1:VAVY5umw94aXf+yGzKCoEqijeUjIUNv+ikJUeQkd9tw=
192192
github.com/jfrog/jfrog-cli-platform-services v1.7.0 h1:u0AOyG4JX3VT7xhEeA9gDpBgW8tYILONpQURtzR3FkI=
193193
github.com/jfrog/jfrog-cli-platform-services v1.7.0/go.mod h1:u3lMRG7XC8MeUy/OPkHkZnsgCMIi0br4sjk2/W1Pm8I=
194194
github.com/jfrog/jfrog-cli-security v1.15.0 h1:TYNIID231X/AivYtptDCF25JyH8qTQht6ISHRfwejL8=
195195
github.com/jfrog/jfrog-cli-security v1.15.0/go.mod h1:WyXj2D0zBfF6gbdufgt/DWGTA0Qr2dyRMwIqr21t0bc=
196-
github.com/jfrog/jfrog-client-go v1.28.1-0.20250219065446-e17342f27e44 h1:Q2S65q8vk4Yb0B95XGCkcJJCUmJoKsDO5w/A1l6guJ8=
197-
github.com/jfrog/jfrog-client-go v1.28.1-0.20250219065446-e17342f27e44/go.mod h1:hDoUcW6LZme83YNFbdSRImV+di1x0GP+Nlw7fctkwtE=
196+
github.com/jfrog/jfrog-client-go v1.28.1-0.20250221062042-87cb5136765e h1:SGKkXdFJtc5Rb32jh5E55SCLrHXtOTvc9YKy6QwWbzY=
197+
github.com/jfrog/jfrog-client-go v1.28.1-0.20250221062042-87cb5136765e/go.mod h1:hDoUcW6LZme83YNFbdSRImV+di1x0GP+Nlw7fctkwtE=
198198
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
199199
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
200200
github.com/jszwec/csvutil v1.10.0 h1:upMDUxhQKqZ5ZDCs/wy+8Kib8rZR8I8lOR34yJkdqhI=

lifecycle/cli.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ func promote(c *cli.Context) error {
254254
promoteCmd := lifecycle.NewReleaseBundlePromoteCommand().SetServerDetails(lcDetails).SetReleaseBundleName(c.Args().Get(0)).
255255
SetReleaseBundleVersion(c.Args().Get(1)).SetEnvironment(c.Args().Get(2)).SetSigningKeyName(c.String(cliutils.SigningKey)).
256256
SetSync(c.Bool(cliutils.Sync)).SetReleaseBundleProject(cliutils.GetProject(c)).
257-
SetIncludeReposPatterns(splitRepos(c, cliutils.IncludeRepos)).SetExcludeReposPatterns(splitRepos(c, cliutils.ExcludeRepos))
257+
SetIncludeReposPatterns(splitRepos(c, cliutils.IncludeRepos)).SetExcludeReposPatterns(splitRepos(c, cliutils.ExcludeRepos)).
258+
SetPromotionType(c.String(cliutils.PromotionType))
258259
return commands.Exec(promoteCmd)
259260
}
260261

lifecycle_test.go

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
const (
3232
artifactoryLifecycleMinVersion = "7.68.3"
3333
signingKeyOptionalArtifactoryMinVersion = "7.104.1"
34+
promotionTypeFlagArtifactoryMinVersion = "7.106.1"
3435
gpgKeyPairName = "lc-tests-key-pair"
3536
lcTestdataPath = "lifecycle"
3637
releaseBundlesSpec = "release-bundles-spec.json"
@@ -144,8 +145,7 @@ func TestLifecycleFullFlow(t *testing.T) {
144145
defer deleteReleaseBundle(t, lcManager, tests.LcRbName3, number3)
145146

146147
// Promote the last release bundle to prod repo 1.
147-
promoteRb(t, lcManager, number3)
148-
148+
promoteRb(t, lcManager, tests.LcRbName3, number3, tests.RtProdRepo1, "")
149149
// Assert the artifacts of both the initial release bundles made it to prod repo 1.
150150
assertExpectedArtifacts(t, tests.SearchAllProdRepo1, tests.GetExpectedLifecycleArtifacts())
151151
// Assert no artifacts were promoted to prod repo 2.
@@ -181,6 +181,22 @@ func TestImportReleaseBundle(t *testing.T) {
181181
assert.Error(t, err)
182182
}
183183

184+
func TestPromoteReleaseBundleWithPromotionTypeFlag(t *testing.T) {
185+
cleanCallback := initLifecycleTest(t, promotionTypeFlagArtifactoryMinVersion)
186+
defer cleanCallback()
187+
lcManager := getLcServiceManager(t)
188+
189+
deleteBuilds := uploadBuilds(t)
190+
defer deleteBuilds()
191+
192+
createRbFromSpec(t, tests.LifecycleBuilds12, tests.LcRbName1, number1, true, false)
193+
defer deleteReleaseBundle(t, lcManager, tests.LcRbName1, number1)
194+
assertStatusCompleted(t, lcManager, tests.LcRbName1, number1, "")
195+
196+
promoteRb(t, lcManager, tests.LcRbName1, number1, tests.RtProdRepo1, "move")
197+
assertStatusCompleted(t, lcManager, tests.LcRbName1, number1, "")
198+
}
199+
184200
func deleteExportedReleaseBundle(t *testing.T, rbName string) {
185201
assert.NoError(t, os.RemoveAll(rbName))
186202
}
@@ -285,16 +301,24 @@ func getOption(option, value string) string {
285301
return fmt.Sprintf("--%s=%s", option, value)
286302
}
287303

288-
func promoteRb(t *testing.T, lcManager *lifecycle.LifecycleServicesManager, rbVersion string) {
289-
output := lcCli.RunCliCmdWithOutput(t, "rbp", tests.LcRbName3, rbVersion, prodEnvironment,
304+
func promoteRb(t *testing.T, lcManager *lifecycle.LifecycleServicesManager, rbName, rbVersion, promoteRepo, promotionType string) {
305+
cmdArgs := []string{"rbp", rbName, rbVersion, prodEnvironment,
290306
getOption(cliutils.SigningKey, gpgKeyPairName),
291-
getOption(cliutils.IncludeRepos, tests.RtProdRepo1),
292-
"--project=default")
307+
getOption(cliutils.IncludeRepos, promoteRepo),
308+
"--project=default"}
309+
310+
// Include promotion type if specified
311+
if promotionType != "" {
312+
cmdArgs = append(cmdArgs, getOption(cliutils.PromotionType, promotionType))
313+
}
314+
315+
output := lcCli.RunCliCmdWithOutput(t, cmdArgs...)
316+
293317
var promotionResp services.RbPromotionResp
294318
if !assert.NoError(t, json.Unmarshal([]byte(output), &promotionResp)) {
295319
return
296320
}
297-
assertStatusCompleted(t, lcManager, tests.LcRbName3, rbVersion, promotionResp.CreatedMillis.String())
321+
assertStatusCompleted(t, lcManager, rbName, rbVersion, promotionResp.CreatedMillis.String())
298322
}
299323

300324
func getSpecFile(fileName string) (string, error) {

utils/cliutils/commandsflags.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ const (
582582
lcIncludeRepos = lifecyclePrefix + IncludeRepos
583583
lcExcludeRepos = lifecyclePrefix + ExcludeRepos
584584
setupRepo = repo
585+
PromotionType = "promotion-type"
585586
)
586587

587588
var flagsMap = map[string]cli.Flag{
@@ -1726,6 +1727,10 @@ var flagsMap = map[string]cli.Flag{
17261727
Name: repo,
17271728
Usage: "[Optional] Specifies the Artifactory repository name for the selected package manager, replacing the interactive repository selection.` `",
17281729
},
1730+
PromotionType: cli.StringFlag{
1731+
Name: PromotionType,
1732+
Usage: "[Default: copy] Specifies promotion type. [Valid values: move / copy]` `",
1733+
},
17291734
}
17301735

17311736
var commandFlags = map[string][]string{
@@ -2006,7 +2011,7 @@ var commandFlags = map[string][]string{
20062011
specFlag, specVars, BuildName, BuildNumber,
20072012
},
20082013
ReleaseBundlePromote: {
2009-
platformUrl, user, password, accessToken, serverId, lcSigningKey, lcSync, lcProject, lcIncludeRepos, lcExcludeRepos,
2014+
platformUrl, user, password, accessToken, serverId, lcSigningKey, lcSync, lcProject, lcIncludeRepos, lcExcludeRepos, PromotionType,
20102015
},
20112016
ReleaseBundleDistribute: {
20122017
platformUrl, user, password, accessToken, serverId, lcProject, DistRules, site, city, countryCodes,

0 commit comments

Comments
 (0)