1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
# frozen_string_literal: true
class Gitlab::Client
# Defines methods related to pipeline schedules.
# @see https://docs.gitlab.com/ce/api/pipeline_schedules.html
module PipelineSchedules
# Gets a list of project pipeline schedules.
#
# @example
# Gitlab.pipeline_schedules(5)
# Gitlab.pipeline_schedules(5, { scope: 'active' })
#
# @param [Integer, String] project the ID or name of a project.
# @param [Hash] options A customizable set of options.
# @options options [String] :scope The scope of pipeline schedules, one of a 'active' or 'inactive'.
# @return [Array<Gitlab::ObjectifiedHash>]
def pipeline_schedules(project, options = {})
get("/projects/#{url_encode project}/pipeline_schedules", query: options)
end
# Gets a single pipeline schedule.
#
# @example
# Gitlab.pipeline_schedule(5, 3)
#
# @param [Integer, String] project The ID or name of a project.
# @param [Integer] id The ID of the pipeline schedule.
# @return [Gitlab::ObjectifiedHash]
def pipeline_schedule(project, id)
get("/projects/#{url_encode project}/pipeline_schedules/#{id}")
end
# Get all pipelines triggered by a pipeline schedule
#
# @example
# Gitlab.pipelines_by_pipeline_schedule(5, 3)
#
# @param [Integer, String] project The ID or name of a project.
# @param [Integer] id The ID of the pipeline schedule.
# @return [Array<Gitlab::ObjectifiedHash>]
def pipelines_by_pipeline_schedule(project, id)
get("/projects/#{url_encode project}/pipeline_schedules/#{id}/pipelines")
end
# Create a pipeline schedule.
#
# @example
# Gitlab.create_pipeline_schedule(5, { description: 'example' })
#
# @param [Integer, String] project The ID or name of a project.
# @param [Hash] options A customizable set of options.
# @option options [String] :description The description of pipeline scehdule.
# @option options [String] :ref The branch/tag name will be triggered.
# @option options [String] :cron The cron (e.g. 0 1 * * *).
# @option options [String] :cron_timezone The timezone supproted by ActiveSupport::TimeZone (e.g. Pacific Time (US & Canada)) (default: 'UTC').
# @option options [Boolean] :active The activation of pipeline schedule. If false is set, the pipeline schedule will deactivated initially (default: true).
# @return [Array<Gitlab::ObjectifiedHash>]
def create_pipeline_schedule(project, options = {})
post("/projects/#{url_encode project}/pipeline_schedules", body: options)
end
# Updates the pipeline schedule of a project.
#
# @example
# Gitlab.edit_pipeline_schedule(3, 2, { description: 'example2' })
#
# @param [Integer, String] project The ID or name of a project.
# @param [Integer] The pipeline schedule ID.
# @param [Hash] options A customizable set of options.
# @option options [String] :description The description of pipeline scehdule.
# @option options [String] :ref The branch/tag name will be triggered.
# @option options [String] :cron The cron (e.g. 0 1 * * *).
# @option options [String] :cron_timezone The timezone supproted by ActiveSupport::TimeZone (e.g. Pacific Time (US & Canada)) (default: 'UTC').
# @option options [Boolean] :active The activation of pipeline schedule. If false is set, the pipeline schedule will deactivated initially (default: true).
# @return [Array<Gitlab::ObjectifiedHash>] The updated pipeline schedule.
def edit_pipeline_schedule(project, pipeline_schedule_id, options = {})
put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}", body: options)
end
# Take ownership of a pipeline schedule.
#
# @example
# Gitlab.pipeline_schedule_take_ownership(5, 1)
#
# @param [Integer, String] project The ID or name of a project.
# @param [Integer] trigger_id The pipeline schedule ID.
# @return [Gitlab::ObjectifiedHash] The updated pipeline schedule.
def pipeline_schedule_take_ownership(project, pipeline_schedule_id)
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/take_ownership")
end
# Run a scheduled pipeline immediately.
#
# @example
# Gitlab.run_pipeline_schedule(5, 1)
#
# @param [Integer, String] project The ID or name of a project.
# @param [Integer] trigger_id The pipeline schedule ID.
# @return [Gitlab::ObjectifiedHash] Pipeline created message.
def run_pipeline_schedule(project, pipeline_schedule_id)
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/play")
end
# Delete a pipeline schedule.
#
# @example
# Gitlab.delete_pipeline_schedule(5, 1)
#
# @param [Integer, String] project The ID or name of a project.
# @param [Integer] trigger_id The pipeline schedule ID.
# @return [Gitlab::ObjectifiedHash] The deleted pipeline schedule.
def delete_pipeline_schedule(project, pipeline_schedule_id)
delete("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}")
end
# Create a pipeline schedule variable.
#
# @example
# Gitlab.create_pipeline_schedule_variable(5, 1, { key: 'foo', value: 'bar' })
#
# @param [Integer, String] project The ID or name of a project.
# @param [Integer] trigger_id The pipeline schedule ID.
# @param [Hash] options A customizable set of options.
# @option options [String] :key The key of a variable; must have no more than 255 characters; only A-Z, a-z, 0-9, and _ are allowed.
# @option options [String] :value The value of a variable
# @return [Array<Gitlab::ObjectifiedHash>] The created pipeline schedule variable.
def create_pipeline_schedule_variable(project, pipeline_schedule_id, options = {})
post("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables", body: options)
end
# Updates the variable of a pipeline schedule.
#
# @example
# Gitlab.edit_pipeline_schedule_variable(3, 2, "foo" { value: 'bar' })
#
# @param [Integer, String] project The ID or name of a project.
# @param [Integer] The pipeline schedule ID.
# @param [String] The key of a variable.
# @param [Hash] options A customizable set of options.
# @option options [String] :value The value of a variable.
# @return [Array<Gitlab::ObjectifiedHash>] The updated pipeline schedule variable.
def edit_pipeline_schedule_variable(project, pipeline_schedule_id, key, options = {})
put("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables/#{url_encode key}", body: options)
end
# Delete the variable of a pipeline schedule
#
# @example
# Gitlab.delete_pipeline_schedule_variable(3, 2, "foo")
#
# @param [Integer, String] project The ID or name of a project.
# @param [Integer] The pipeline schedule ID.
# @param [String] The key of a variable.
# @return [Array<Gitlab::ObjectifiedHash>] The deleted pipeline schedule variable.
def delete_pipeline_schedule_variable(project, pipeline_schedule_id, key, _options = {})
delete("/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}/variables/#{url_encode key}")
end
end
end
|