Skip to content

Commit 7a3ab2a

Browse files
Andrew Pattersonbalasankarc
andcommitted
Merge branch 'fix-os-detection-in-deployer-rake-task' into 'master'
Fix OS detection in deployer pipeline triggering logic See merge request https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7312 Merged-by: Andrew Patterson <[email protected]> Approved-by: Andrew Patterson <[email protected]> Approved-by: Jason Plum <[email protected]> Co-authored-by: Balasankar 'Balu' C <[email protected]>
2 parents 62d8bf5 + db49c1a commit 7a3ab2a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

lib/gitlab/tasks/gitlab_com.rake

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ namespace :gitlab_com do
3737
# other than `master` in the deployer project
3838
trigger_ref = Gitlab::Util.get_env('DEPLOYER_TRIGGER_REF') || :master
3939

40-
current_os = OhaiHelper.fetch_os_with_codename[0..1].join("-")
40+
# Find out the OS for which packages are built for. We can not use Ohai for
41+
# this, as that will return the builder image being used to run this rake
42+
# task. So, we detect the OS from the path of the packages.
43+
package_os = Build::Info::Package.file_list.map { |path| path.split("/")[1] }.uniq.first
44+
4145
os_for_deployment = Build::Info::Deploy::OS_MAPPING[Build::Info::Deploy.environment_key]
42-
if current_os != os_for_deployment
43-
puts "Deployment to #{deploy_env} not to be triggered from this build (#{current_os})."
46+
if package_os != os_for_deployment
47+
puts "Deployment to #{deploy_env} not to be triggered from this build (#{package_os})."
4448
next
4549
end
4650

spec/lib/gitlab/tasks/gitlab_com_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
context 'with the auto-deploy tag' do
4949
before do
50-
allow(OhaiHelper).to receive(:fetch_os_with_codename).and_return(%w[ubuntu bionic])
50+
allow(Dir).to receive(:glob).with("pkg/**/*.{deb,rpm}").and_return(%w[pkg/ubuntu-bionic/gitlab-ee_16.7.0-ee.0_amd64.deb])
5151
allow(Build::Check).to receive(:is_auto_deploy?).and_return(true)
5252
end
5353

@@ -58,7 +58,7 @@
5858

5959
context 'when running on Ubuntu 18.04' do
6060
before do
61-
allow(OhaiHelper).to receive(:fetch_os_with_codename).and_return(%w[ubuntu bionic])
61+
allow(Dir).to receive(:glob).with("pkg/**/*.{deb,rpm}").and_return(%w[pkg/ubuntu-bionic/gitlab-ee_16.7.0-ee.0_amd64.deb])
6262
end
6363

6464
context 'with a release candidate (RC) tag' do
@@ -89,7 +89,7 @@
8989

9090
context 'when running on Ubuntu 20.04' do
9191
before do
92-
allow(OhaiHelper).to receive(:fetch_os_with_codename).and_return(%w[ubuntu focal])
92+
allow(Dir).to receive(:glob).with("pkg/**/*.{deb,rpm}").and_return(%w[pkg/ubuntu-focal/gitlab-ee_16.7.0-ee.0_amd64.deb])
9393
end
9494

9595
context 'with a release candidate (RC) tag' do

0 commit comments

Comments
 (0)