Class: CiToolkit::GitlabRelease
- Inherits:
-
Object
- Object
- CiToolkit::GitlabRelease
- Defined in:
- lib/ci_toolkit/gitlab_release.rb
Overview
Can be used to create gitlab project releases and upload asset to project uploads
Instance Method Summary collapse
-
#create_release(project_id:, name:, description:, last_git_commit:, tag_name:, file_name:) ⇒ Object
rubocop:disable Metrics/ParameterLists.
-
#initialize(env = CiToolkit::BitriseEnv.new, bot = CiToolkit::GitlabBot.new) ⇒ GitlabRelease
constructor
A new instance of GitlabRelease.
-
#upload_file(project_id:, tag_name:, full_path_to_file:) ⇒ Object
rubocop:disable Metrics/MethodLength.
Constructor Details
#initialize(env = CiToolkit::BitriseEnv.new, bot = CiToolkit::GitlabBot.new) ⇒ GitlabRelease
Returns a new instance of GitlabRelease.
8 9 10 11 12 13 14 |
# File 'lib/ci_toolkit/gitlab_release.rb', line 8 def initialize( env = CiToolkit::BitriseEnv.new, bot = CiToolkit::GitlabBot.new ) @repo_slug = env.repository_slug @client = bot.client end |
Instance Method Details
#create_release(project_id:, name:, description:, last_git_commit:, tag_name:, file_name:) ⇒ Object
rubocop:disable Metrics/ParameterLists
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ci_toolkit/gitlab_release.rb', line 17 def create_release( project_id:, name:, description:, last_git_commit:, tag_name:, file_name: ) release_details = { name:, tag_name:, ref: last_git_commit, description:, assets: { links: [get_assets_details(project_id, tag_name, file_name)] } } @client.create_project_release(project_id, release_details) end |
#upload_file(project_id:, tag_name:, full_path_to_file:) ⇒ Object
rubocop:disable Metrics/MethodLength
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ci_toolkit/gitlab_release.rb', line 38 def upload_file(project_id:, tag_name:, full_path_to_file:) result = "" exit_status = nil curl_command = get_curl_command(project_id, tag_name, full_path_to_file) Open3.popen2e(*curl_command) do |_stdin, io, thread| io.sync = true io.each do |line| result = line.strip end exit_status = thread.value end unless exit_status.exitstatus.zero? raise StandardError, "Exit status of command '#{curl_command}' was #{exit_status.exitstatus} instead of 0." end result end |