diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-08 18:08:59 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-08 18:08:59 +0300 |
commit | c6c5dd8848b78528d7ad7f044a0c95be629d372e (patch) | |
tree | 261577e229ade85472353eb5b380c1e4fed9bc60 /app/models | |
parent | d0aeb5df3d6b06165355b023a25b79c7bd74a27d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/pipeline.rb | 103 | ||||
-rw-r--r-- | app/models/ci/runner.rb | 4 | ||||
-rw-r--r-- | app/models/integrations/jira.rb | 10 |
3 files changed, 15 insertions, 102 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 21d17f11c50..bd426e02b9c 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -845,97 +845,6 @@ module Ci end end - def predefined_variables - Gitlab::Ci::Variables::Collection.new.tap do |variables| - variables.append(key: 'CI_PIPELINE_IID', value: iid.to_s) - variables.append(key: 'CI_PIPELINE_SOURCE', value: source.to_s) - variables.append(key: 'CI_PIPELINE_CREATED_AT', value: created_at&.iso8601) - - variables.concat(predefined_commit_variables) - variables.concat(predefined_merge_request_variables) - - if open_merge_requests_refs.any? - variables.append(key: 'CI_OPEN_MERGE_REQUESTS', value: open_merge_requests_refs.join(',')) - end - - variables.append(key: 'CI_GITLAB_FIPS_MODE', value: 'true') if Gitlab::FIPS.enabled? - - variables.append(key: 'CI_KUBERNETES_ACTIVE', value: 'true') if has_kubernetes_active? - variables.append(key: 'CI_DEPLOY_FREEZE', value: 'true') if freeze_period? - - if external_pull_request_event? && external_pull_request - variables.concat(external_pull_request.predefined_variables) - end - end - end - - def predefined_commit_variables - strong_memoize(:predefined_commit_variables) do - Gitlab::Ci::Variables::Collection.new.tap do |variables| - next variables unless sha.present? - - variables.append(key: 'CI_COMMIT_SHA', value: sha) - variables.append(key: 'CI_COMMIT_SHORT_SHA', value: short_sha) - variables.append(key: 'CI_COMMIT_BEFORE_SHA', value: before_sha) - variables.append(key: 'CI_COMMIT_REF_NAME', value: source_ref) - variables.append(key: 'CI_COMMIT_REF_SLUG', value: source_ref_slug) - variables.append(key: 'CI_COMMIT_BRANCH', value: ref) if branch? - variables.append(key: 'CI_COMMIT_MESSAGE', value: git_commit_message.to_s) - variables.append(key: 'CI_COMMIT_TITLE', value: git_commit_full_title.to_s) - variables.append(key: 'CI_COMMIT_DESCRIPTION', value: git_commit_description.to_s) - variables.append(key: 'CI_COMMIT_REF_PROTECTED', value: (!!protected_ref?).to_s) - variables.append(key: 'CI_COMMIT_TIMESTAMP', value: git_commit_timestamp.to_s) - variables.append(key: 'CI_COMMIT_AUTHOR', value: git_author_full_text.to_s) - - # legacy variables - variables.append(key: 'CI_BUILD_REF', value: sha) - variables.append(key: 'CI_BUILD_BEFORE_SHA', value: before_sha) - variables.append(key: 'CI_BUILD_REF_NAME', value: source_ref) - variables.append(key: 'CI_BUILD_REF_SLUG', value: source_ref_slug) - - variables.concat(predefined_commit_tag_variables) - end - end - end - - def predefined_merge_request_variables - strong_memoize(:predefined_merge_request_variables) do - Gitlab::Ci::Variables::Collection.new.tap do |variables| - next variables unless merge_request? - - variables.append(key: 'CI_MERGE_REQUEST_EVENT_TYPE', value: merge_request_event_type.to_s) - variables.append(key: 'CI_MERGE_REQUEST_SOURCE_BRANCH_SHA', value: source_sha.to_s) - variables.append(key: 'CI_MERGE_REQUEST_TARGET_BRANCH_SHA', value: target_sha.to_s) - - diff = self.merge_request_diff - if diff.present? - variables.append(key: 'CI_MERGE_REQUEST_DIFF_ID', value: diff.id.to_s) - variables.append(key: 'CI_MERGE_REQUEST_DIFF_BASE_SHA', value: diff.base_commit_sha) - end - - variables.concat(merge_request.predefined_variables) - end - end - end - - def predefined_commit_tag_variables - strong_memoize(:predefined_commit_ref_variables) do - Gitlab::Ci::Variables::Collection.new.tap do |variables| - next variables unless tag? - - git_tag = project.repository.find_tag(ref) - - next variables unless git_tag - - variables.append(key: 'CI_COMMIT_TAG', value: ref) - variables.append(key: 'CI_COMMIT_TAG_MESSAGE', value: git_tag.message) - - # legacy variable - variables.append(key: 'CI_BUILD_TAG', value: ref) - end - end - end - def queued_duration return unless started_at @@ -1407,6 +1316,12 @@ module Ci (Time.current - created_at).ceil / 60 end + def merge_request_diff + return unless merge_request? + + merge_request.merge_request_diff_for(merge_request_diff_sha) + end + private def cancel_jobs(jobs, retries: 1, auto_canceled_by_pipeline_id: nil) @@ -1459,12 +1374,6 @@ module Ci end end - def merge_request_diff - return unless merge_request? - - merge_request.merge_request_diff_for(merge_request_diff_sha) - end - def push_details strong_memoize(:push_details) do Gitlab::Git::Push.new(project, before_sha, sha, git_ref) diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index db58a995f0b..eea8915b690 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -502,6 +502,10 @@ module Ci token.start_with?(CREATED_RUNNER_TOKEN_PREFIX) end + def ensure_machine(machine_xid:, &blk) + RunnerMachine.safe_find_or_create_by!(runner_id: id, machine_xid: machine_xid.to_s, &blk) # rubocop: disable Performance/ActiveRecordSubtransactionMethods + end + private scope :with_upgrade_status, ->(upgrade_status) do diff --git a/app/models/integrations/jira.rb b/app/models/integrations/jira.rb index 45302a0bd09..d96a848c72e 100644 --- a/app/models/integrations/jira.rb +++ b/app/models/integrations/jira.rb @@ -48,21 +48,21 @@ module Integrations section: SECTION_TYPE_CONNECTION, required: true, title: -> { s_('JiraService|Web URL') }, - help: -> { s_('JiraService|Base URL of the Jira instance.') }, + help: -> { s_('JiraService|Base URL of the Jira instance') }, placeholder: 'https://jira.example.com', exposes_secrets: true field :api_url, section: SECTION_TYPE_CONNECTION, title: -> { s_('JiraService|Jira API URL') }, - help: -> { s_('JiraService|If different from Web URL.') }, + help: -> { s_('JiraService|If different from the Web URL') }, exposes_secrets: true field :username, section: SECTION_TYPE_CONNECTION, required: true, - title: -> { s_('JiraService|Username or Email') }, - help: -> { s_('JiraService|Use a username for server version and an email for cloud version.') } + title: -> { s_('JiraService|Username or email') }, + help: -> { s_('JiraService|Username for the server version or an email for the cloud version') } field :password, section: SECTION_TYPE_CONNECTION, @@ -70,7 +70,7 @@ module Integrations title: -> { s_('JiraService|Password or API token') }, non_empty_password_title: -> { s_('JiraService|Enter new password or API token') }, non_empty_password_help: -> { s_('JiraService|Leave blank to use your current password or API token.') }, - help: -> { s_('JiraService|Use a password for server version and an API token for cloud version.') } + help: -> { s_('JiraService|Password for the server version or an API token for the cloud version') } field :jira_issue_transition_id, api_only: true |