diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /app/models/ci/runner.rb | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'app/models/ci/runner.rb')
-rw-r--r-- | app/models/ci/runner.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index 7a1d52f5aea..61194c9b7d1 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -77,6 +77,7 @@ module Ci has_one :last_build, -> { order('id DESC') }, class_name: 'Ci::Build' before_save :ensure_token + before_save :update_semver, if: -> { version_changed? } scope :active, -> (value = true) { where(active: value) } scope :paused, -> { active(false) } @@ -429,6 +430,7 @@ module Ci values = values&.slice(:version, :revision, :platform, :architecture, :ip_address, :config, :executor) || {} values[:contacted_at] = Time.current values[:executor_type] = EXECUTOR_NAME_TO_TYPES.fetch(values.delete(:executor), :unknown) + values[:semver] = semver_from_version(values[:version]) cache_attributes(values) @@ -449,6 +451,16 @@ module Ci read_attribute(:contacted_at) end + def semver_from_version(version) + parsed_runner_version = ::Gitlab::VersionInfo.parse(version) + + parsed_runner_version.valid? ? parsed_runner_version.to_s : nil + end + + def update_semver + self.semver = semver_from_version(self.version) + end + def namespace_ids strong_memoize(:namespace_ids) do runner_namespaces.pluck(:namespace_id).compact |