diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-10 12:07:55 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-10 12:07:55 +0000 |
commit | 5e11c9b77cb1b2b77ee29359047b55807afe255d (patch) | |
tree | 40b02dead6acdcaab9cc15efc9ae4710c2ed78a8 /scripts | |
parent | 97d4d926630822d0e1a638206909679c962d2f0a (diff) | |
download | gitlab-ce-5e11c9b77cb1b2b77ee29359047b55807afe255d.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/get-job-id | 43 | ||||
-rwxr-xr-x | scripts/notifications.sh | 27 | ||||
-rwxr-xr-x | scripts/notify-slack | 14 | ||||
-rw-r--r-- | scripts/review_apps/base-config.yaml | 4 |
4 files changed, 72 insertions, 16 deletions
diff --git a/scripts/get-job-id b/scripts/get-job-id new file mode 100755 index 00000000000..a5d34dc545b --- /dev/null +++ b/scripts/get-job-id @@ -0,0 +1,43 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require 'gitlab' +require 'optparse' + +# +# Configure credentials to be used with gitlab gem +# +Gitlab.configure do |config| + config.endpoint = 'https://gitlab.com/api/v4' + config.private_token = ENV['GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN'] +end + +options = {} +OptionParser.new do |opts| + opts.on("-s", "--scope=SCOPE", "Find job with matching scope") do |scope| + options[:scope] = scope + end +end.parse! + +class PipelineJobFinder + def initialize(project_id, pipeline_id, job_name, options) + @project_id = project_id + @pipeline_id = pipeline_id + @job_name = job_name + @options = options + end + + def execute + Gitlab.pipeline_jobs(@project_id, @pipeline_id, @options).auto_paginate do |job| + break job if job.name == @job_name + end + end +end + +project_id, pipeline_id, job_name = ARGV + +job = PipelineJobFinder.new(project_id, pipeline_id, job_name, options).execute + +return if job.nil? + +puts job.id diff --git a/scripts/notifications.sh b/scripts/notifications.sh new file mode 100755 index 00000000000..d1b11d44e88 --- /dev/null +++ b/scripts/notifications.sh @@ -0,0 +1,27 @@ +# Sends Slack notification MSG to CI_SLACK_WEBHOOK_URL (which needs to be set). +# ICON_EMOJI needs to be set to an icon emoji name (without the `:` around it). +function notify_slack() { + CHANNEL=$1 + MSG=$2 + ICON_EMOJI=$3 + + if [ -z "$CHANNEL" ] || [ -z "$CI_SLACK_WEBHOOK_URL" ] || [ -z "$MSG" ] || [ -z "$ICON_EMOJI" ]; then + echo "Missing argument(s) - Use: $0 channel message icon_emoji" + echo "and set CI_SLACK_WEBHOOK_URL environment variable." + else + curl -X POST --data-urlencode 'payload={"channel": "#'"${CHANNEL}"'", "username": "GitLab QA Bot", "text": "'"${MSG}"'", "icon_emoji": "'":${ICON_EMOJI}:"'"}' "${CI_SLACK_WEBHOOK_URL}" + fi +} + +function notify_on_job_failure() { + JOB_NAME=$1 + CHANNEL=$2 + MSG=$3 + ICON_EMOJI=$4 + + local job_id + job_id=$(scripts/get-job-id "$CI_PROJECT_ID" "$CI_PIPELINE_ID" "$JOB_NAME" -s failed) + if [ -n "${job_id}" ]; then + notify_slack "${CHANNEL}" "${MSG}" "${ICON_EMOJI}" + fi +} diff --git a/scripts/notify-slack b/scripts/notify-slack deleted file mode 100755 index 5907fd8b986..00000000000 --- a/scripts/notify-slack +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -# Sends Slack notification MSG to CI_SLACK_WEBHOOK_URL (which needs to be set). -# ICON_EMOJI needs to be set to an icon emoji name (without the `:` around it). - -CHANNEL=$1 -MSG=$2 -ICON_EMOJI=$3 - -if [ -z "$CHANNEL" ] || [ -z "$CI_SLACK_WEBHOOK_URL" ] || [ -z "$MSG" ] || [ -z "$ICON_EMOJI" ]; then - echo "Missing argument(s) - Use: $0 channel message icon_emoji" - echo "and set CI_SLACK_WEBHOOK_URL environment variable." -else - curl -X POST --data-urlencode 'payload={"channel": "#'"$CHANNEL"'", "username": "GitLab QA Bot", "text": "'"$MSG"'", "icon_emoji": "'":$ICON_EMOJI:"'"}' "$CI_SLACK_WEBHOOK_URL" -fi diff --git a/scripts/review_apps/base-config.yaml b/scripts/review_apps/base-config.yaml index 1014bd9a89f..8465f32b741 100644 --- a/scripts/review_apps/base-config.yaml +++ b/scripts/review_apps/base-config.yaml @@ -8,6 +8,8 @@ global: configureCertmanager: false tls: secretName: tls-cert + initialRootPassword: + secret: shared-gitlab-initial-root-password certmanager: install: false gitlab: @@ -26,8 +28,6 @@ gitlab: mailroom: enabled: false migrations: - initialRootPassword: - secret: shared-gitlab-initial-root-password resources: requests: cpu: 350m |