Skip to content

Commit a09322c

Browse files
Andrew Pattersonbalasankarc
andcommitted
Merge branch 'run-nightly-in-com' into 'master'
Enable running nightly pipelines in Canonical repo See merge request https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7434 Merged-by: Andrew Patterson <[email protected]> Approved-by: Clemens Beck <[email protected]> Approved-by: Andrew Patterson <[email protected]> Reviewed-by: Balasankar 'Balu' C <[email protected]> Co-authored-by: Balasankar 'Balu' C <[email protected]>
2 parents 4dc9f56 + 65a8c2c commit a09322c

File tree

5 files changed

+44
-20
lines changed

5 files changed

+44
-20
lines changed

.gitlab-ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ variables:
7272
QA_PROJECT_PATH: 'gitlab-org/build/omnibus-gitlab-mirror'
7373
ARM64_RUNNER_TAG: 'arm64'
7474
PACKAGE_PROMOTION_RUNNER_TAG: 'promotion'
75+
NIGHTLY_REPO: 'nightly-builds'
76+
NIGHTLY_FIPS_REPO: 'nightly-fips-builds'
7577

7678
.distribution-amd64-tags:
7779
- distribution-runner
@@ -154,7 +156,10 @@ before_script:
154156
chmod -R 0600 ~/.ssh/;
155157
fi
156158
- bash scripts/ci/prepare_bundle.sh
157-
- if [ -n "$NIGHTLY" ]; then export STAGING_REPO=nightly-builds; export FIPS_STAGING_REPO=nightly-fips-builds; fi
159+
- if [ -n "$NIGHTLY" ]; then
160+
export STAGING_REPO=${NIGHTLY_REPO};
161+
export FIPS_STAGING_REPO=${NIGHTLY_FIPS_REPO};
162+
fi
158163

159164
fetch-assets:
160165
extends: .docker_job

gitlab-ci-config/workflow-rules.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ workflow:
4646
- if: '$PIPELINE_TYPE == null && $CI_PROJECT_PATH == $CANONICAL_PROJECT_PATH && $CI_COMMIT_REF_PROTECTED == "true"'
4747
variables:
4848
PIPELINE_TYPE: PROTECTED_TEST_PIPELINE
49-
- if: '$PIPELINE_TYPE == null && $CI_PROJECT_PATH == $CANONICAL_PROJECT_PATH && $CI_COMMIT_BRANCH'
50-
variables:
51-
PIPELINE_TYPE: GITLAB_BRANCH_TEST_PIPELINE
52-
- if: '$PIPELINE_TYPE == null && $CI_PROJECT_PATH == $DEV_PROJECT_PATH && $NIGHTLY && $CI_COMMIT_BRANCH && ($ee == "true" || $GITLAB_VERSION =~ /-ee$/)'
49+
- if: '$PIPELINE_TYPE == null && $NIGHTLY && $CI_COMMIT_BRANCH && ($ee == "true" || $GITLAB_VERSION =~ /-ee$/)'
5350
variables:
5451
PIPELINE_TYPE: EE_NIGHTLY_BUILD_PIPELINE
5552
CACHE_EDITION: "EE"
@@ -62,7 +59,7 @@ workflow:
6259
variables:
6360
PIPELINE_TYPE: EE_BRANCH_BUILD_PIPELINE
6461
CACHE_EDITION: "EE"
65-
- if: '$PIPELINE_TYPE == null && $CI_PROJECT_PATH == $DEV_PROJECT_PATH && $NIGHTLY && $CI_COMMIT_BRANCH'
62+
- if: '$PIPELINE_TYPE == null && $NIGHTLY && $CI_COMMIT_BRANCH'
6663
variables:
6764
PIPELINE_TYPE: CE_NIGHTLY_BUILD_PIPELINE
6865
CACHE_EDITION: "CE"
@@ -103,6 +100,9 @@ workflow:
103100
- if: '$PIPELINE_TYPE == null && $CI_PROJECT_PATH == $SECURITY_PROJECT_PATH && $CI_COMMIT_REF_PROTECTED == "true"'
104101
variables:
105102
PIPELINE_TYPE: PROTECTED_TEST_PIPELINE
103+
- if: '$PIPELINE_TYPE == null && $CI_PROJECT_PATH == $CANONICAL_PROJECT_PATH && $CI_COMMIT_BRANCH'
104+
variables:
105+
PIPELINE_TYPE: GITLAB_BRANCH_TEST_PIPELINE
106106
- if: '$PIPELINE_TYPE == null && $CI_PROJECT_PATH == $SECURITY_PROJECT_PATH && $CI_COMMIT_BRANCH'
107107
variables:
108108
PIPELINE_TYPE: GITLAB_BRANCH_TEST_PIPELINE

lib/gitlab/build/info/docker.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def tag
1414
def release_file_contents
1515
repo = Gitlab::Util.get_env('PACKAGECLOUD_REPO') # Target repository
1616

17-
download_url = if /dev.gitlab.org/.match?(Build::Info::CI.api_v4_url)
17+
download_url = if /dev.gitlab.org/.match?(Build::Info::CI.api_v4_url) || Build::Check.is_nightly?
1818
Build::Info::CI.package_download_url
1919
else
2020
Build::Info::CI.triggered_package_download_url

lib/gitlab/package_repository.rb

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def validate(dry_run)
3535

3636
def upload(repository = nil, dry_run = false)
3737
if upload_user.nil?
38-
puts "User for uploading to package server not specified!"
38+
puts "Owner of the repository to which packages are being uploaded not specified! Set `PACKAGECLOUD_USER` environment variable."
3939
return
4040
end
4141

@@ -51,20 +51,21 @@ def upload(repository = nil, dry_run = false)
5151
cmd = "LC_ALL='en_US.UTF-8' bin/package_cloud push #{upload_user}/#{pkg} --url=https://packages.gitlab.com"
5252
puts "Uploading...\n"
5353

54-
if dry_run
55-
puts cmd
56-
else
57-
Retriable.with_context(:package_publish, on: PackageUploadError) do
58-
result = `#{cmd}`
54+
puts "Running the command: #{cmd}"
5955

60-
if child_process_status == 1
61-
unless /filename: has already been taken/.match?(result)
62-
puts 'Upload to package server failed!.'
63-
raise PackageUploadError, "Upload to package server failed!."
64-
end
56+
next if dry_run
6557

66-
puts "Package #{pkg} has already been uploaded, skipping.\n"
58+
Retriable.with_context(:package_publish, on: PackageUploadError) do
59+
result = `#{cmd}`
60+
61+
if child_process_status == 1
62+
unless /filename: has already been taken/.match?(result)
63+
puts 'Upload to package server failed!.'
64+
puts "The command returned the output: #{result}"
65+
raise PackageUploadError, "Upload to package server failed!."
6766
end
67+
68+
puts "Package #{pkg} has already been uploaded, skipping.\n"
6869
end
6970
end
7071
end
@@ -119,6 +120,10 @@ def package_list(repository)
119120
end
120121

121122
def upload_user
123+
# Even though the variable says "upload user", this is acutally the user
124+
# who owns the repository to which packages are being uploaded. This
125+
# information is only used to generate the path to the repository - the
126+
# user who actually does the upload is known by the token.
122127
Gitlab::Util.get_env('PACKAGECLOUD_USER') if Gitlab::Util.get_env('PACKAGECLOUD_USER') && !Gitlab::Util.get_env('PACKAGECLOUD_USER').empty?
123128
end
124129

spec/lib/gitlab/package_repository_spec.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959

6060
context 'on non-stable branch' do
6161
before do
62+
unset_all_env_variables
6263
allow(IO).to receive(:popen).with(%w[git describe]).and_return("8.1.0+rc1.ce.0-1685-gd2a2c51\n")
6364
end
6465

@@ -72,6 +73,7 @@
7273

7374
context 'on a stable branch' do
7475
before do
76+
unset_all_env_variables
7577
allow(IO).to receive(:popen).with(%w[git describe]).and_return("8.12.8+ce.0-1-gdac92d4\n")
7678
end
7779

@@ -135,8 +137,12 @@
135137
describe '#upload' do
136138
describe 'with staging repository' do
137139
context 'when upload user is not specified' do
140+
before do
141+
unset_all_env_variables
142+
end
143+
138144
it 'prints a message and aborts' do
139-
expect { repo.upload('my-staging-repository', true) }.to output(%r{User for uploading to package server not specified!\n}).to_stdout
145+
expect { repo.upload('my-staging-repository', true) }.to output(%r{Owner of the repository to which packages are being uploaded not specified}).to_stdout
140146
end
141147
end
142148

@@ -278,6 +284,14 @@
278284
end
279285
end
280286

287+
def unset_all_env_variables
288+
stub_env_var('PACKAGECLOUD_TOKEN', nil)
289+
stub_env_var('PACKAGECLOUD_USER', nil)
290+
stub_env_var('PACKAGECLOUD_REPO', nil)
291+
stub_env_var('RASPBERRY_REPO', nil)
292+
stub_env_var('STAGING_REPO', nil)
293+
end
294+
281295
def set_all_env_variables
282296
stub_env_var("PACKAGECLOUD_REPO", "super-stable-1234")
283297
stub_env_var("RASPBERRY_REPO", "raspi")

0 commit comments

Comments
 (0)