@@ -40,21 +40,42 @@ def deregister_image(parameters)
40
40
before do
41
41
Rake ::Task [ 'aws:ami:create' ] . reenable
42
42
allow_any_instance_of ( Kernel ) . to receive ( :system ) . and_return ( true )
43
+ allow ( ENV ) . to receive ( :[] ) . and_call_original
44
+ stub_env_var ( 'CI_JOB_TOKEN' , 'CI-NO-JOB-TOKEN' )
43
45
end
44
46
45
- describe 'on a regular tag ' do
47
+ context 'when using `AMI_USE_OLD_BUILD_PROCESS` environment variable ' do
46
48
before do
49
+ stub_env_var ( 'AMI_USE_OLD_BUILD_PROCESS' , 'true' )
47
50
allow ( Build ::Check ) . to receive ( :on_tag? ) . and_return ( true )
48
51
allow ( Build ::Check ) . to receive ( :is_auto_deploy? ) . and_return ( false )
49
52
allow ( Build ::Check ) . to receive ( :is_rc_tag? ) . and_return ( false )
50
53
allow ( Build ::Info ) . to receive ( :ami_deb_package_download_url ) . and_return ( 'http://example.com' )
51
54
end
52
55
56
+ it 'should call the old script' do
57
+ allow ( Build ::Info ) . to receive ( :edition ) . and_return ( 'ce' )
58
+ allow ( Omnibus ::BuildVersion ) . to receive ( :semver ) . and_return ( '9.3.0' )
59
+
60
+ expect_any_instance_of ( Kernel ) . to receive ( :system ) . with ( *[ "support/packer_old/packer_ami.sh" , "9.3.0" , "ce" , "http://example.com" , "" ] )
61
+
62
+ Rake ::Task [ 'aws:ami:create' ] . invoke
63
+ end
64
+ end
65
+
66
+ describe 'on a regular tag' do
67
+ before do
68
+ allow ( Build ::Check ) . to receive ( :on_tag? ) . and_return ( true )
69
+ allow ( Build ::Check ) . to receive ( :is_auto_deploy? ) . and_return ( false )
70
+ allow ( Build ::Check ) . to receive ( :is_rc_tag? ) . and_return ( false )
71
+ allow ( Build ::Info ::CI ) . to receive ( :package_download_url ) . and_return ( 'http://example.com' )
72
+ end
73
+
53
74
it 'should identify ce category correctly, if specified' do
54
75
allow ( Build ::Info ) . to receive ( :edition ) . and_return ( 'ce' )
55
76
allow ( Omnibus ::BuildVersion ) . to receive ( :semver ) . and_return ( '9.3.0' )
56
77
57
- expect_any_instance_of ( Kernel ) . to receive ( :system ) . with ( *[ "support/packer/packer_ami.sh" , "9.3.0" , "ce" , "http://example.com" , "" ] )
78
+ expect_any_instance_of ( Kernel ) . to receive ( :system ) . with ( *[ "support/packer/packer_ami.sh" , "9.3.0" , "ce" , "http://example.com" , "CI-NO-JOB-TOKEN" , " "] )
58
79
59
80
Rake ::Task [ 'aws:ami:create' ] . invoke
60
81
end
@@ -63,7 +84,7 @@ def deregister_image(parameters)
63
84
allow ( Build ::Info ) . to receive ( :edition ) . and_return ( nil )
64
85
allow ( Omnibus ::BuildVersion ) . to receive ( :semver ) . and_return ( '9.3.0' )
65
86
66
- expect_any_instance_of ( Kernel ) . to receive ( :system ) . with ( *[ "support/packer/packer_ami.sh" , "9.3.0" , "ce" , "http://example.com" , "" ] )
87
+ expect_any_instance_of ( Kernel ) . to receive ( :system ) . with ( *[ "support/packer/packer_ami.sh" , "9.3.0" , "ce" , "http://example.com" , "CI-NO-JOB-TOKEN" , " "] )
67
88
68
89
Rake ::Task [ 'aws:ami:create' ] . invoke
69
90
end
@@ -72,7 +93,7 @@ def deregister_image(parameters)
72
93
allow ( Build ::Info ) . to receive ( :edition ) . and_return ( 'ee' )
73
94
allow ( Omnibus ::BuildVersion ) . to receive ( :semver ) . and_return ( '9.3.0' )
74
95
75
- expect_any_instance_of ( Kernel ) . to receive ( :system ) . with ( *[ "support/packer/packer_ami.sh" , "9.3.0" , "ee" , "http://example.com" , "" ] )
96
+ expect_any_instance_of ( Kernel ) . to receive ( :system ) . with ( *[ "support/packer/packer_ami.sh" , "9.3.0" , "ee" , "http://example.com" , "CI-NO-JOB-TOKEN" , " "] )
76
97
77
98
Rake ::Task [ 'aws:ami:create' ] . invoke
78
99
end
@@ -83,7 +104,7 @@ def deregister_image(parameters)
83
104
allow ( Build ::Info ) . to receive ( :edition ) . and_return ( nil )
84
105
allow ( Omnibus ::BuildVersion ) . to receive ( :semver ) . and_return ( '9.3.0' )
85
106
86
- expect_any_instance_of ( Kernel ) . to receive ( :system ) . with ( *[ "support/packer/packer_ami.sh" , "9.3.0" , "ce-arm64" , "http://example.com" , "" ] )
107
+ expect_any_instance_of ( Kernel ) . to receive ( :system ) . with ( *[ "support/packer/packer_ami.sh" , "9.3.0" , "ce-arm64" , "http://example.com" , "CI-NO-JOB-TOKEN" , " "] )
87
108
88
109
Rake ::Task [ 'aws:ami:create' ] . invoke
89
110
end
@@ -94,7 +115,7 @@ def deregister_image(parameters)
94
115
allow ( Build ::Info ) . to receive ( :edition ) . and_return ( 'ee' )
95
116
allow ( Omnibus ::BuildVersion ) . to receive ( :semver ) . and_return ( '9.3.0' )
96
117
97
- expect_any_instance_of ( Kernel ) . to receive ( :system ) . with ( *[ "support/packer/packer_ami.sh" , "9.3.0" , "ee-arm64" , "http://example.com" , "" ] )
118
+ expect_any_instance_of ( Kernel ) . to receive ( :system ) . with ( *[ "support/packer/packer_ami.sh" , "9.3.0" , "ee-arm64" , "http://example.com" , "CI-NO-JOB-TOKEN" , " "] )
98
119
99
120
Rake ::Task [ 'aws:ami:create' ] . invoke
100
121
end
@@ -105,7 +126,7 @@ def deregister_image(parameters)
105
126
allow ( Gitlab ::Util ) . to receive ( :get_env ) . with ( "AWS_RELEASE_TYPE" ) . and_return ( 'ultimate' )
106
127
allow ( Omnibus ::BuildVersion ) . to receive ( :semver ) . and_return ( '9.3.0' )
107
128
108
- expect_any_instance_of ( Kernel ) . to receive ( :system ) . with ( *[ "support/packer/packer_ami.sh" , "9.3.0" , "ee-ultimate" , "http://example.com" , "AWS_ULTIMATE_LICENSE_FILE" ] )
129
+ expect_any_instance_of ( Kernel ) . to receive ( :system ) . with ( *[ "support/packer/packer_ami.sh" , "9.3.0" , "ee-ultimate" , "http://example.com" , "CI-NO-JOB-TOKEN" , " AWS_ULTIMATE_LICENSE_FILE"] )
109
130
110
131
Rake ::Task [ 'aws:ami:create' ] . invoke
111
132
end
@@ -116,7 +137,7 @@ def deregister_image(parameters)
116
137
allow ( Gitlab ::Util ) . to receive ( :get_env ) . with ( "AWS_RELEASE_TYPE" ) . and_return ( 'premium' )
117
138
allow ( Omnibus ::BuildVersion ) . to receive ( :semver ) . and_return ( '9.3.0' )
118
139
119
- expect_any_instance_of ( Kernel ) . to receive ( :system ) . with ( *[ "support/packer/packer_ami.sh" , "9.3.0" , "ee-premium" , "http://example.com" , "AWS_PREMIUM_LICENSE_FILE" ] )
140
+ expect_any_instance_of ( Kernel ) . to receive ( :system ) . with ( *[ "support/packer/packer_ami.sh" , "9.3.0" , "ee-premium" , "http://example.com" , "CI-NO-JOB-TOKEN" , " AWS_PREMIUM_LICENSE_FILE"] )
120
141
121
142
Rake ::Task [ 'aws:ami:create' ] . invoke
122
143
end
@@ -127,7 +148,7 @@ def deregister_image(parameters)
127
148
allow ( Build ::Check ) . to receive ( :on_tag? ) . and_return ( true )
128
149
allow ( Build ::Check ) . to receive ( :is_auto_deploy? ) . and_return ( false )
129
150
allow ( Build ::Check ) . to receive ( :is_rc_tag? ) . and_return ( true )
130
- allow ( Build ::Info ) . to receive ( :ami_deb_package_download_url ) . and_return ( 'http://example.com' )
151
+ allow ( Build ::Info :: CI ) . to receive ( :package_download_url ) . and_return ( 'http://example.com' )
131
152
end
132
153
133
154
it 'does not do anything' do
@@ -142,7 +163,7 @@ def deregister_image(parameters)
142
163
allow ( Build ::Check ) . to receive ( :on_tag? ) . and_return ( true )
143
164
allow ( Build ::Check ) . to receive ( :is_auto_deploy? ) . and_return ( true )
144
165
allow ( Build ::Check ) . to receive ( :is_rc_tag? ) . and_return ( false )
145
- allow ( Build ::Info ) . to receive ( :ami_deb_package_download_url ) . and_return ( 'http://example.com' )
166
+ allow ( Build ::Info :: CI ) . to receive ( :package_download_url ) . and_return ( 'http://example.com' )
146
167
end
147
168
148
169
it 'does not do anything' do
0 commit comments