Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 14:18:50 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 14:18:50 +0300
commit8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch)
treea77e7fe7a93de11213032ed4ab1f33a3db51b738 /scripts
parent00b35af3db1abfe813a778f643dad221aad51fca (diff)
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build_assets_image2
-rwxr-xr-xscripts/gemfile_lock_changed.sh2
-rwxr-xr-xscripts/gitaly-test-build1
-rw-r--r--scripts/gitaly_test.rb27
-rwxr-xr-xscripts/lint-changelog-filenames4
-rwxr-xr-xscripts/lint-conflicts.sh2
-rwxr-xr-xscripts/lint-doc.sh4
-rw-r--r--scripts/review_apps/base-config.yaml2
-rwxr-xr-xscripts/review_apps/review-apps.sh12
-rw-r--r--scripts/rspec_helpers.sh24
-rwxr-xr-xscripts/static-analysis181
-rw-r--r--scripts/sync-stable-branch.sh54
-rwxr-xr-xscripts/trigger-build26
-rw-r--r--scripts/utils.sh26
14 files changed, 218 insertions, 149 deletions
diff --git a/scripts/build_assets_image b/scripts/build_assets_image
index 9eb1ccd5515..12beddfa184 100755
--- a/scripts/build_assets_image
+++ b/scripts/build_assets_image
@@ -1,7 +1,7 @@
# Exit early if we don't want to build the image
if [[ "${BUILD_ASSETS_IMAGE}" != "true" ]]
then
- exit 0
+ exit 0
fi
# Generate the image name based on the project this is being run in
diff --git a/scripts/gemfile_lock_changed.sh b/scripts/gemfile_lock_changed.sh
index 24e2c685f11..eec31af1f77 100755
--- a/scripts/gemfile_lock_changed.sh
+++ b/scripts/gemfile_lock_changed.sh
@@ -2,7 +2,7 @@
gemfile_lock_changed() {
if [ -n "$(git diff --name-only -- Gemfile.lock)" ]; then
- cat << EOF
+ cat <<EOF
Gemfile was updated but Gemfile.lock was not updated.
Usually, when Gemfile is updated, you should run
diff --git a/scripts/gitaly-test-build b/scripts/gitaly-test-build
index fcf0049162b..5254d957afd 100755
--- a/scripts/gitaly-test-build
+++ b/scripts/gitaly-test-build
@@ -14,6 +14,7 @@ class GitalyTestBuild
def run
abort 'gitaly build failed' unless system(env, 'make', chdir: tmp_tests_gitaly_dir)
+ ensure_gitlab_shell_secret!
check_gitaly_config!
# Starting gitaly further validates its configuration
diff --git a/scripts/gitaly_test.rb b/scripts/gitaly_test.rb
index e6f2c9885d9..c69c4ea747b 100644
--- a/scripts/gitaly_test.rb
+++ b/scripts/gitaly_test.rb
@@ -4,6 +4,7 @@
# Please be careful when modifying this file. Your changes must work
# both for local development rspec runs, and in CI.
+require 'securerandom'
require 'socket'
module GitalyTest
@@ -11,10 +12,22 @@ module GitalyTest
File.expand_path('../tmp/tests/gitaly', __dir__)
end
+ def tmp_tests_gitlab_shell_dir
+ File.expand_path('../tmp/tests/gitlab-shell', __dir__)
+ end
+
+ def rails_gitlab_shell_secret
+ File.expand_path('../.gitlab_shell_secret', __dir__)
+ end
+
def gemfile
File.join(tmp_tests_gitaly_dir, 'ruby', 'Gemfile')
end
+ def gitlab_shell_secret_file
+ File.join(tmp_tests_gitlab_shell_dir, '.gitlab_shell_secret')
+ end
+
def env
env_hash = {
'HOME' => File.expand_path('tmp/tests'),
@@ -70,6 +83,20 @@ module GitalyTest
pid
end
+ # Taken from Gitlab::Shell.generate_and_link_secret_token
+ def ensure_gitlab_shell_secret!
+ secret_file = rails_gitlab_shell_secret
+ shell_link = gitlab_shell_secret_file
+
+ unless File.size?(secret_file)
+ File.write(secret_file, SecureRandom.hex(16))
+ end
+
+ unless File.exist?(shell_link)
+ FileUtils.ln_s(secret_file, shell_link)
+ end
+ end
+
def check_gitaly_config!
puts "Checking gitaly-ruby Gemfile..."
diff --git a/scripts/lint-changelog-filenames b/scripts/lint-changelog-filenames
index 2355ac6f7b2..fc07b7153aa 100755
--- a/scripts/lint-changelog-filenames
+++ b/scripts/lint-changelog-filenames
@@ -6,7 +6,7 @@ lint_paths="changelogs/unreleased"
invalid_files=$(find $lint_paths -type f -not -name "*.yml" -not -name ".gitkeep")
if [ -n "$invalid_files" ]; then
- echo "Changelog files must end in .yml, but these did not:"
- echo "$invalid_files" | sed -e "s/^/* /"
+ echo "Changelog files must end in .yml, but these did not:"
+ echo "$invalid_files" | sed -e "s/^/* /"
exit 1
fi
diff --git a/scripts/lint-conflicts.sh b/scripts/lint-conflicts.sh
index 239e227a41e..2d240e420d9 100755
--- a/scripts/lint-conflicts.sh
+++ b/scripts/lint-conflicts.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-output=`git grep -En '^<<<<<<< '`
+output=$(git grep -En '^<<<<<<< ')
echo $output
test -z "$output"
diff --git a/scripts/lint-doc.sh b/scripts/lint-doc.sh
index d9de48fd0c0..ca9747987df 100755
--- a/scripts/lint-doc.sh
+++ b/scripts/lint-doc.sh
@@ -40,8 +40,8 @@ then
fi
# Do not use 'README.md', instead use 'index.md'
-# Number of 'README.md's as of 2018-03-26
-NUMBER_READMES=46
+# Number of 'README.md's as of 2020-05-28
+NUMBER_READMES=45
FIND_READMES=$(find doc/ -name "README.md" | wc -l)
echo '=> Checking for new README.md files...'
echo
diff --git a/scripts/review_apps/base-config.yaml b/scripts/review_apps/base-config.yaml
index a34bb23a5e6..6fb6943fb90 100644
--- a/scripts/review_apps/base-config.yaml
+++ b/scripts/review_apps/base-config.yaml
@@ -66,7 +66,7 @@ gitlab:
limits:
cpu: 100m
memory: 700M
- unicorn:
+ webservice:
resources:
requests:
cpu: 746m
diff --git a/scripts/review_apps/review-apps.sh b/scripts/review_apps/review-apps.sh
index 097fe9c8cca..1214ee5f462 100755
--- a/scripts/review_apps/review-apps.sh
+++ b/scripts/review_apps/review-apps.sh
@@ -245,7 +245,7 @@ function deploy() {
IMAGE_REPOSITORY="registry.gitlab.com/gitlab-org/build/cng-mirror"
gitlab_migrations_image_repository="${IMAGE_REPOSITORY}/gitlab-rails-ee"
gitlab_sidekiq_image_repository="${IMAGE_REPOSITORY}/gitlab-sidekiq-ee"
- gitlab_unicorn_image_repository="${IMAGE_REPOSITORY}/gitlab-webservice-ee"
+ gitlab_webservice_image_repository="${IMAGE_REPOSITORY}/gitlab-webservice-ee"
gitlab_task_runner_image_repository="${IMAGE_REPOSITORY}/gitlab-task-runner-ee"
gitlab_gitaly_image_repository="${IMAGE_REPOSITORY}/gitaly"
gitlab_shell_image_repository="${IMAGE_REPOSITORY}/gitlab-shell"
@@ -275,11 +275,11 @@ HELM_CMD=$(cat << EOF
--set gitlab.sidekiq.annotations.commit="${CI_COMMIT_SHORT_SHA}" \
--set gitlab.sidekiq.image.repository="${gitlab_sidekiq_image_repository}" \
--set gitlab.sidekiq.image.tag="${CI_COMMIT_REF_SLUG}" \
- --set gitlab.unicorn.annotations.commit="${CI_COMMIT_SHORT_SHA}" \
- --set gitlab.unicorn.image.repository="${gitlab_unicorn_image_repository}" \
- --set gitlab.unicorn.image.tag="${CI_COMMIT_REF_SLUG}" \
- --set gitlab.unicorn.workhorse.image="${gitlab_workhorse_image_repository}" \
- --set gitlab.unicorn.workhorse.tag="${CI_COMMIT_REF_SLUG}" \
+ --set gitlab.webservice.annotations.commit="${CI_COMMIT_SHORT_SHA}" \
+ --set gitlab.webservice.image.repository="${gitlab_webservice_image_repository}" \
+ --set gitlab.webservice.image.tag="${CI_COMMIT_REF_SLUG}" \
+ --set gitlab.webservice.workhorse.image="${gitlab_workhorse_image_repository}" \
+ --set gitlab.webservice.workhorse.tag="${CI_COMMIT_REF_SLUG}" \
--set gitlab.task-runner.image.repository="${gitlab_task_runner_image_repository}" \
--set gitlab.task-runner.image.tag="${CI_COMMIT_REF_SLUG}"
EOF
diff --git a/scripts/rspec_helpers.sh b/scripts/rspec_helpers.sh
index 0c9d3505ff3..110567a15be 100644
--- a/scripts/rspec_helpers.sh
+++ b/scripts/rspec_helpers.sh
@@ -110,3 +110,27 @@ function rspec_paralellized_job() {
date
}
+
+function rspec_matched_tests() {
+ local test_file_count_threshold=20
+ local matching_tests_file=${1}
+ local rspec_opts=${2}
+ local test_files="$(cat "${matching_tests_file}")"
+ local test_file_count=$(wc -w "${matching_tests_file}" | awk {'print $1'})
+
+ if [[ "${test_file_count}" -gt "${test_file_count_threshold}" ]]; then
+ echo "There are more than ${test_file_count_threshold} FOSS test files matched,"
+ echo "which would take too long to run in this job."
+ echo "To reduce the likelihood of breaking FOSS pipelines,"
+ echo "please add [RUN AS-IF-FOSS] to the MR title and restart the pipeline."
+ echo "This would run all as-if-foss jobs in this merge request"
+ echo "and remove this job from the pipeline."
+ exit 1
+ fi
+
+ if [[ -n $test_files ]]; then
+ rspec_simple_job "${rspec_opts} ${test_files}"
+ else
+ echo "No test files to run"
+ fi
+}
diff --git a/scripts/static-analysis b/scripts/static-analysis
index ede29b85b8d..9103a9c14af 100755
--- a/scripts/static-analysis
+++ b/scripts/static-analysis
@@ -5,103 +5,118 @@ require_relative '../lib/gitlab'
require_relative '../lib/gitlab/popen'
require_relative '../lib/gitlab/popen/runner'
-def emit_warnings(static_analysis)
- static_analysis.warned_results.each do |result|
- puts
- puts "**** #{result.cmd.join(' ')} had the following warning(s):"
- puts
- puts result.stderr
- puts
- end
-end
+class StaticAnalysis
+ ALLOWED_WARNINGS = [
+ # https://github.com/browserslist/browserslist/blob/d0ec62eb48c41c218478cd3ac28684df051cc865/node.js#L329
+ # warns if caniuse-lite package is older than 6 months. Ignore this
+ # warning message so that GitLab backports don't fail.
+ "Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade`"
+ ].freeze
+
+ # `gettext:updated_check` and `gitlab:sidekiq:sidekiq_queues_yml:check` will fail on FOSS installations
+ # (e.g. gitlab-org/gitlab-foss) since they test against a single
+ # file that is generated by an EE installation, which can
+ # contain values that a FOSS installation won't find. To work
+ # around this we will only enable this task on EE installations.
+ TASKS_BY_DURATIONS_SECONDS_DESC = {
+ %w[bin/rake lint:haml] => 338,
+ (Gitlab.ee? ? %w[bin/rake gettext:updated_check] : nil) => 308,
+ # Most of the time, RuboCop finishes in 30 seconds, but sometimes it can take around 1200 seconds so we set a
+ # duration of 300 to lower the likelihood that it will run in the same job as another long task...
+ %w[bundle exec rubocop --parallel] => 300,
+ %w[yarn run eslint] => 197,
+ %w[yarn run prettier-all] => 124,
+ %w[bin/rake gettext:lint] => 96,
+ %w[bundle exec license_finder] => 49,
+ %w[bin/rake scss_lint] => 38,
+ %w[bin/rake lint:static_verification] => 22,
+ %w[bin/rake gitlab:sidekiq:all_queues_yml:check] => 13,
+ (Gitlab.ee? ? %w[bin/rake gitlab:sidekiq:sidekiq_queues_yml:check] : nil) => 13,
+ %w[bin/rake config_lint] => 11,
+ %w[yarn run stylelint] => 9,
+ %w[scripts/lint-conflicts.sh] => 0.59,
+ %w[yarn run block-dependencies] => 0.35,
+ %w[scripts/lint-rugged] => 0.23,
+ %w[scripts/gemfile_lock_changed.sh] => 0.02,
+ %w[scripts/frontend/check_no_partial_karma_jest.sh] => 0.01,
+ %w[scripts/lint-changelog-filenames] => 0.01
+ }.reject { |k| k.nil? }.sort_by { |a| -a[1] }.to_h.keys.freeze
+
+ def run_tasks!
+ tasks = tasks_to_run((ENV['CI_NODE_INDEX'] || 1).to_i, (ENV['CI_NODE_TOTAL'] || 1).to_i)
+
+ static_analysis = Gitlab::Popen::Runner.new
+
+ static_analysis.run(tasks) do |cmd, &run|
+ puts
+ puts "$ #{cmd.join(' ')}"
+
+ result = run.call
+
+ puts "==> Finished in #{result.duration} seconds"
+ puts
+ end
-def emit_errors(static_analysis)
- static_analysis.failed_results.each do |result|
puts
- puts "**** #{result.cmd.join(' ')} failed with the following error(s):"
+ puts '==================================================='
puts
- puts result.stdout
- puts result.stderr
puts
- end
-end
-ALLOWED_WARNINGS = [
- # https://github.com/browserslist/browserslist/blob/d0ec62eb48c41c218478cd3ac28684df051cc865/node.js#L329
- # warns if caniuse-lite package is older than 6 months. Ignore this
- # warning message so that GitLab backports don't fail.
- "Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade`"
-].freeze
+ if static_analysis.all_success_and_clean?
+ puts 'All static analyses passed successfully.'
+ elsif static_analysis.all_success?
+ puts 'All static analyses passed successfully, but we have warnings:'
+ puts
-def warning_count(static_analysis)
- static_analysis.warned_results
- .count { |result| !ALLOWED_WARNINGS.include?(result.stderr.strip) }
-end
+ emit_warnings(static_analysis)
-def jobs_to_run(node_index, node_total)
- all_tasks = [
- %w[bin/rake lint:all],
- %w[bundle exec license_finder],
- %w[yarn run eslint],
- %w[yarn run stylelint],
- %w[yarn run prettier-all],
- %w[yarn run block-dependencies],
- %w[bundle exec rubocop --parallel],
- %w[scripts/lint-conflicts.sh],
- %w[scripts/lint-rugged],
- %w[scripts/frontend/check_no_partial_karma_jest.sh],
- %w[scripts/lint-changelog-filenames],
- %w[scripts/gemfile_lock_changed.sh]
- ]
-
- case node_total
- when 1
- all_tasks
- when 2
- rake_lint_all, *rest_jobs = all_tasks
- case node_index
- when 1
- [rake_lint_all]
+ exit 2 if warning_count(static_analysis).nonzero?
else
- rest_jobs
- end
- else
- raise "Parallelization > 2 (currently set to #{node_total}) isn't supported yet!"
- end
-end
-
-tasks = jobs_to_run((ENV['CI_NODE_INDEX'] || 1).to_i, (ENV['CI_NODE_TOTAL'] || 1).to_i)
-static_analysis = Gitlab::Popen::Runner.new
+ puts 'Some static analyses failed:'
-static_analysis.run(tasks) do |cmd, &run|
- puts
- puts "$ #{cmd.join(' ')}"
+ emit_warnings(static_analysis)
+ emit_errors(static_analysis)
- result = run.call
-
- puts "==> Finished in #{result.duration} seconds"
- puts
-end
+ exit 1
+ end
+ end
-puts
-puts '==================================================='
-puts
-puts
+ def emit_warnings(static_analysis)
+ static_analysis.warned_results.each do |result|
+ puts
+ puts "**** #{result.cmd.join(' ')} had the following warning(s):"
+ puts
+ puts result.stderr
+ puts
+ end
+ end
-if static_analysis.all_success_and_clean?
- puts 'All static analyses passed successfully.'
-elsif static_analysis.all_success?
- puts 'All static analyses passed successfully, but we have warnings:'
- puts
+ def emit_errors(static_analysis)
+ static_analysis.failed_results.each do |result|
+ puts
+ puts "**** #{result.cmd.join(' ')} failed with the following error(s):"
+ puts
+ puts result.stdout
+ puts result.stderr
+ puts
+ end
+ end
- emit_warnings(static_analysis)
+ def warning_count(static_analysis)
+ static_analysis.warned_results
+ .count { |result| !ALLOWED_WARNINGS.include?(result.stderr.strip) }
+ end
- exit 2 if warning_count(static_analysis).nonzero?
-else
- puts 'Some static analyses failed:'
+ def tasks_to_run(node_index, node_total)
+ tasks = []
+ TASKS_BY_DURATIONS_SECONDS_DESC.each_with_index do |task, i|
+ tasks << task if i % node_total == (node_index - 1)
+ end
- emit_warnings(static_analysis)
- emit_errors(static_analysis)
+ tasks
+ end
+end
- exit 1
+if $0 == __FILE__
+ StaticAnalysis.new.run_tasks!
end
diff --git a/scripts/sync-stable-branch.sh b/scripts/sync-stable-branch.sh
index 5aaec323628..59ab52844fb 100644
--- a/scripts/sync-stable-branch.sh
+++ b/scripts/sync-stable-branch.sh
@@ -7,56 +7,56 @@ set -e
if [[ "$MERGE_TRAIN_TRIGGER_TOKEN" == '' ]]
then
- echo 'The variable MERGE_TRAIN_TRIGGER_TOKEN must be set to a non-empty value'
- exit 1
+ echo 'The variable MERGE_TRAIN_TRIGGER_TOKEN must be set to a non-empty value'
+ exit 1
fi
if [[ "$MERGE_TRAIN_TRIGGER_URL" == '' ]]
then
- echo 'The variable MERGE_TRAIN_TRIGGER_URL must be set to a non-empty value'
- exit 1
+ echo 'The variable MERGE_TRAIN_TRIGGER_URL must be set to a non-empty value'
+ exit 1
fi
if [[ "$CI_COMMIT_REF_NAME" == '' ]]
then
- echo 'The variable CI_COMMIT_REF_NAME must be set to a non-empty value'
- exit 1
+ echo 'The variable CI_COMMIT_REF_NAME must be set to a non-empty value'
+ exit 1
fi
if [[ "$SOURCE_PROJECT" == '' ]]
then
- echo 'The variable SOURCE_PROJECT must be set to a non-empty value'
- exit 1
+ echo 'The variable SOURCE_PROJECT must be set to a non-empty value'
+ exit 1
fi
if [[ "$TARGET_PROJECT" == '' ]]
then
- echo 'The variable TARGET_PROJECT must be set to a non-empty value'
- exit 1
+ echo 'The variable TARGET_PROJECT must be set to a non-empty value'
+ exit 1
fi
if [[ "$TARGET_PROJECT" != "gitlab-org/gitlab-foss" ]]
then
- echo 'This is a security FOSS merge train'
- echo "Checking if $CI_COMMIT_SHA is available on canonical"
+ echo 'This is a security FOSS merge train'
+ echo "Checking if $CI_COMMIT_SHA is available on canonical"
- gitlab_com_commit_status=$(curl -s "https://gitlab.com/api/v4/projects/278964/repository/commits/$CI_COMMIT_SHA" | jq -M .status)
+ gitlab_com_commit_status=$(curl -s "https://gitlab.com/api/v4/projects/278964/repository/commits/$CI_COMMIT_SHA" | jq -M .status)
- if [[ "$gitlab_com_commit_status" != "null" ]]
- then
- echo 'Commit available on canonical, skipping merge train'
- exit 0
- fi
+ if [[ "$gitlab_com_commit_status" != "null" ]]
+ then
+ echo 'Commit available on canonical, skipping merge train'
+ exit 0
+ fi
- echo 'Commit not available, triggering a merge train'
+ echo 'Commit not available, triggering a merge train'
fi
curl -X POST \
- -F token="$MERGE_TRAIN_TRIGGER_TOKEN" \
- -F ref=master \
- -F "variables[MERGE_FOSS]=1" \
- -F "variables[SOURCE_BRANCH]=$CI_COMMIT_REF_NAME" \
- -F "variables[TARGET_BRANCH]=${CI_COMMIT_REF_NAME/-ee/}" \
- -F "variables[SOURCE_PROJECT]=$SOURCE_PROJECT" \
- -F "variables[TARGET_PROJECT]=$TARGET_PROJECT" \
- "$MERGE_TRAIN_TRIGGER_URL"
+ -F token="$MERGE_TRAIN_TRIGGER_TOKEN" \
+ -F ref=master \
+ -F "variables[MERGE_FOSS]=1" \
+ -F "variables[SOURCE_BRANCH]=$CI_COMMIT_REF_NAME" \
+ -F "variables[TARGET_BRANCH]=${CI_COMMIT_REF_NAME/-ee/}" \
+ -F "variables[SOURCE_PROJECT]=$SOURCE_PROJECT" \
+ -F "variables[TARGET_PROJECT]=$TARGET_PROJECT" \
+ "$MERGE_TRAIN_TRIGGER_URL"
diff --git a/scripts/trigger-build b/scripts/trigger-build
index c7b45480bf3..b8bea95a069 100755
--- a/scripts/trigger-build
+++ b/scripts/trigger-build
@@ -16,6 +16,10 @@ module Trigger
%w[gitlab gitlab-ee].include?(ENV['CI_PROJECT_NAME'])
end
+ def self.security?
+ %r{\Agitlab-org/security(\z|/)}.match?(ENV['CI_PROJECT_NAMESPACE'])
+ end
+
def self.non_empty_variable_value(variable)
variable_value = ENV[variable]
@@ -26,6 +30,9 @@ module Trigger
class Base
def invoke!(post_comment: false, downstream_job_name: nil)
+ # gitlab-bot's token "GitLab multi-project pipeline polling"
+ Gitlab.private_token = access_token
+
pipeline_variables = variables
puts "Triggering downstream pipeline on #{downstream_project_path}"
@@ -40,7 +47,7 @@ module Trigger
puts "Triggered downstream pipeline: #{pipeline.web_url}\n"
puts "Waiting for downstream pipeline status"
- Trigger::CommitComment.post!(pipeline, access_token) if post_comment
+ Trigger::CommitComment.post!(pipeline) if post_comment
downstream_job =
if downstream_job_name
Gitlab.pipeline_jobs(downstream_project_path, pipeline.id).auto_paginate.find do |potential_job|
@@ -49,9 +56,9 @@ module Trigger
end
if downstream_job
- Trigger::Job.new(downstream_project_path, downstream_job.id, access_token)
+ Trigger::Job.new(downstream_project_path, downstream_job.id)
else
- Trigger::Pipeline.new(downstream_project_path, pipeline.id, access_token)
+ Trigger::Pipeline.new(downstream_project_path, pipeline.id)
end
end
@@ -140,6 +147,7 @@ module Trigger
{
'GITLAB_VERSION' => Trigger.non_empty_variable_value('CI_MERGE_REQUEST_SOURCE_BRANCH_SHA') || ENV['CI_COMMIT_SHA'],
'ALTERNATIVE_SOURCES' => 'true',
+ 'SECURITY_SOURCES' => Trigger.security? ? 'true' : 'false',
'ee' => Trigger.ee? ? 'true' : 'false',
'QA_BRANCH' => ENV['QA_BRANCH'] || 'master'
}
@@ -197,9 +205,7 @@ module Trigger
end
class CommitComment
- def self.post!(downstream_pipeline, access_token)
- Gitlab.private_token = access_token
-
+ def self.post!(downstream_pipeline)
Gitlab.create_commit_comment(
ENV['CI_PROJECT_PATH'],
Trigger.non_empty_variable_value('CI_MERGE_REQUEST_SOURCE_BRANCH_SHA') || ENV['CI_COMMIT_SHA'],
@@ -214,7 +220,7 @@ module Trigger
INTERVAL = 60 # seconds
MAX_DURATION = 3600 * 3 # 3 hours
- attr_reader :project, :id, :api_token
+ attr_reader :project, :id
def self.unscoped_class_name
name.split('::').last
@@ -224,14 +230,10 @@ module Trigger
unscoped_class_name.downcase
end
- def initialize(project, id, api_token)
+ def initialize(project, id)
@project = project
@id = id
- @api_token = api_token
@start = Time.now.to_i
-
- # gitlab-bot's token "GitLab multi-project pipeline polling"
- Gitlab.private_token = api_token
end
def wait!
diff --git a/scripts/utils.sh b/scripts/utils.sh
index 897f8d5a8b8..f81e5c8982a 100644
--- a/scripts/utils.sh
+++ b/scripts/utils.sh
@@ -1,25 +1,25 @@
function retry() {
+ if eval "$@"; then
+ return 0
+ fi
+
+ for i in 2 1; do
+ sleep 3s
+ echo "Retrying $i..."
if eval "$@"; then
- return 0
+ return 0
fi
-
- for i in 2 1; do
- sleep 3s
- echo "Retrying $i..."
- if eval "$@"; then
- return 0
- fi
- done
- return 1
+ done
+ return 1
}
function setup_db_user_only() {
- source scripts/create_postgres_user.sh
+ source scripts/create_postgres_user.sh
}
function setup_db() {
- run_timed_command "setup_db_user_only"
- run_timed_command "bundle exec rake db:drop db:create db:structure:load db:migrate gitlab:db:setup_ee"
+ run_timed_command "setup_db_user_only"
+ run_timed_command "bundle exec rake db:drop db:create db:structure:load db:migrate gitlab:db:setup_ee"
}
function install_api_client_dependencies_with_apk() {