33module Pyxis
44 module Commands
55 class Release < Thor
6+ include SemanticLogger ::Loggable
67 include PermissionHelper
78
89 desc 'create_canary' , 'Promote an experimental build to canary'
910 exclusive do
1011 at_least_one do
11- method_option :build ,
12+ method_option :build_id ,
1213 aliases : '-b' ,
1314 desc : 'The build ID' ,
1415 required : false ,
@@ -23,23 +24,28 @@ class Release < Thor
2324 def create_canary
2425 assert_executed_by_delivery_team_member!
2526
26- build_id = options [ :build ] || ManagedVersioning ::ComponentInfo . new (
27+ info = ManagedVersioning ::ComponentInfo . new (
28+ build_id : options [ :build_id ] ,
2729 container_tag : options [ :container_tag ]
28- ) . find_build_id_for_container_tag
30+ )
2931
30- raise Pyxis ::MessageError , 'This build does not exist' if build_id . nil?
32+ raise Pyxis ::MessageError , 'This build does not exist' if info . find_build_id_for_container_tag . nil?
33+ raise Pyxis ::MessageError , 'This build does not exist' if info . find_container_tag_for_build_id . nil?
3134
3235 pipeline = GitlabClient . client . create_pipeline (
3336 Project ::Pyxis . api_gitlab_path ,
3437 Project ::Pyxis . default_branch ,
3538 variables : {
36- PIPELINE_NAME : "Release build #{ build_id } as canary" ,
39+ PIPELINE_NAME : "Release #{ info . find_container_tag_for_build_id } as canary" ,
3740 RELEASE_COORDINATOR : 'canary' ,
38- BUILD_ID_TO_PROMOTE : build_id . to_s ,
41+ BUILD_ID_TO_PROMOTE : info . find_build_id_for_container_tag . to_s ,
3942 }
4043 )
4144
42- raise Pyxis ::MessageError , 'Failed to create pipeline' if pipeline . response . status != 201
45+ if pipeline . response . status != 201
46+ logger . warn ( 'Failed to create pipeline for canary release' , response : response . body )
47+ raise Pyxis ::MessageError , 'Failed to create pipeline'
48+ end
4349
4450 "Created coordinator pipeline at #{ pipeline . body . web_url } "
4551 end
0 commit comments