diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /scripts/api | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'scripts/api')
-rw-r--r-- | scripts/api/create_issue.rb | 29 | ||||
-rw-r--r-- | scripts/api/pipeline_failed_jobs.rb | 2 |
2 files changed, 30 insertions, 1 deletions
diff --git a/scripts/api/create_issue.rb b/scripts/api/create_issue.rb new file mode 100644 index 00000000000..2117c285771 --- /dev/null +++ b/scripts/api/create_issue.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'gitlab' +require_relative 'default_options' + +class CreateIssue + def initialize(options) + @project = options.fetch(:project) + + # Force the token to be a string so that if api_token is nil, it's set to '', + # allowing unauthenticated requests (for forks). + api_token = options.delete(:api_token).to_s + + warn "No API token given." if api_token.empty? + + @client = Gitlab.client( + endpoint: options.delete(:endpoint) || API::DEFAULT_OPTIONS[:endpoint], + private_token: api_token + ) + end + + def execute(issue_data) + client.create_issue(project, issue_data.delete(:title), issue_data) + end + + private + + attr_reader :project, :client +end diff --git a/scripts/api/pipeline_failed_jobs.rb b/scripts/api/pipeline_failed_jobs.rb index c25567af698..df9a7e76dcd 100644 --- a/scripts/api/pipeline_failed_jobs.rb +++ b/scripts/api/pipeline_failed_jobs.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'gitlab' -require 'optparse' + require_relative 'default_options' class PipelineFailedJobs |