gitlab 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b76c82ead8e87ca095bc2ad47515701b11c9735f
4
- data.tar.gz: 758f96760c958422f9642878247aad32cc5962be
3
+ metadata.gz: 495b1042cb1c31a952e20736b66c03ff91503e55
4
+ data.tar.gz: b1d768d0e57f2687e947d10e9401742d15815b18
5
5
  SHA512:
6
- metadata.gz: 14dcda9a02593219e14e7dd67f4480790022c755a7e2261da430784464a2cfc6c0c0f68f8eb3a599f08a39f27bf69e8c9b271bfc54ad4ae71393b56493e88283
7
- data.tar.gz: 2b0c3d034013eaffaf176de7a334c95efc15d4f979dfa9e83e4e70de881571925a6d7ec03571ba55076506580673e5bf9b2584e0e99e285f1b763ba7506008c2
6
+ metadata.gz: 9478123ca2e7e8bbb1a2ea4cc7a0bcea6675f3dcf54c40033e7d30512eb29b3ed2af07a8e92d940c2f7295b8c319dd70fe2a0e7ef2d344f1e566303704653e42
7
+ data.tar.gz: 976085a5f7b15f55ea2f2fe6a6ffc67c63d1b0c6d2417320b74e17bdad310f3401e6fe82efb8f3b06f52010d9fc561e92e3e4d3295ce5ee5f004eca836f7fef1
@@ -2,6 +2,13 @@
2
2
 
3
3
  ### Unreleased
4
4
 
5
+ ### 4.1.0 (26/05/2017)
6
+ - Add appropriate Content-Type header (@mltsy)
7
+ - Add `Jobs` endpoint methods (@hjanuschka)
8
+ - Update `BuildTriggers` to v4 API and rename to `PipelineTriggers`. (@IgnoredAmbience)
9
+ - Add support for `keys` resource (@dirker)
10
+ - Remove version-lock for terminal-table (@SuperTux88)
11
+
5
12
  ### 4.0.0 (10/04/2017)
6
13
  - Adds ability to create commits in a repository - (@logicminds)
7
14
  - Remove Ruby 1.x support from the project - (@orta)
@@ -22,7 +22,7 @@ Gem::Specification.new do |gem|
22
22
  gem.required_ruby_version = ">= 2.0.0"
23
23
 
24
24
  gem.add_runtime_dependency 'httparty'
25
- gem.add_runtime_dependency 'terminal-table', '1.7.1'
25
+ gem.add_runtime_dependency 'terminal-table'
26
26
 
27
27
  gem.add_development_dependency 'pry'
28
28
  gem.add_development_dependency 'rake'
@@ -5,17 +5,18 @@ module Gitlab
5
5
 
6
6
  include Branches
7
7
  include Builds
8
- include BuildTriggers
9
8
  include BuildVariables
10
9
  include Commits
11
10
  include Groups
12
11
  include Issues
12
+ include Keys
13
13
  include Labels
14
14
  include MergeRequests
15
15
  include Milestones
16
16
  include Namespaces
17
17
  include Notes
18
18
  include Pipelines
19
+ include PipelineTriggers
19
20
  include Projects
20
21
  include Repositories
21
22
  include RepositoryFiles
@@ -25,6 +26,7 @@ module Gitlab
25
26
  include SystemHooks
26
27
  include Tags
27
28
  include Users
29
+ include Jobs
28
30
 
29
31
  # Text representation of the client, masking private token.
30
32
  #
@@ -0,0 +1,162 @@
1
+ class Gitlab::Client
2
+ # Defines methods related to projects.
3
+ # @see https://docs.gitlab.com/ee/api/jobs.html
4
+ module Jobs
5
+ # Gets a list of Jobs for a Project
6
+ #
7
+ # @example
8
+ # Gitlab.jobs(1)
9
+ # Gitlab.jobs("project")
10
+ #
11
+ # @param [Integer, String] id The ID or name of a project.
12
+ # @param [Hash] options A customizable set of options.
13
+ # @option options [Array] :scope The scope of jobs to show, one or array of: created, pending, running, failed, success, canceled, skipped, manual; showing all jobs if none provided.
14
+ # @return [Array<Gitlab::ObjectifiedHash>]
15
+ def jobs(project_id, options = {})
16
+ get("/projects/#{url_encode project_id}/jobs", query: options)
17
+ end
18
+
19
+ # Gets a list of Jobs from a pipeline
20
+ #
21
+ # @example
22
+ # Gitlab.pipeline_jobs(1, 2)
23
+ # Gitlab.pipeline_jobs("project", 2)
24
+ #
25
+ # @param [Integer, String] The ID or name of a project.
26
+ # @param [Integer] the id of the pipeline
27
+ # @param [Hash] options A customizable set of options.
28
+ # @option options [Array] :scope The scope of jobs to show, one or array of: created, pending, running, failed, success, canceled, skipped, manual; showing all jobs if none provided.
29
+ # @return [Array<Gitlab::ObjectifiedHash>]
30
+ def pipeline_jobs(project_id, pipeline_id, options = {})
31
+ get("/projects/#{url_encode project_id}/pipelines/#{pipeline_id}/jobs", query: options)
32
+ end
33
+
34
+ # Gets a single job
35
+ #
36
+ # @example
37
+ # Gitlab.job(1, 2)
38
+ # Gitlab.job("project", 2)
39
+ #
40
+ # @param [Integer, String] The ID or name of a project.
41
+ # @param [Integer] the id of the job
42
+ def job(project_id, job_id)
43
+ get("/projects/#{url_encode project_id}/jobs/#{job_id}")
44
+ end
45
+
46
+ # Gets artifacts from a job
47
+ #
48
+ # @example
49
+ # Gitlab.job_artifacts(1, 2)
50
+ # Gitlab.job_artifacts("project", 2)
51
+ #
52
+ # @param [Integer, String] The ID or name of a project.
53
+ # @param [Integer] the id of the job
54
+ # @return [Array<Gitlab::ObjectifiedHash>]
55
+ def job_artifacts(project_id, job_id)
56
+ get("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts",
57
+ format: nil,
58
+ headers: { Accept: 'text/plain' },
59
+ parser: ::Gitlab::Request::Parser)
60
+ end
61
+
62
+ # Download Job Artifact
63
+ #
64
+ # @example
65
+ # Gitlab.job_artifacts_download(1, "master", "release")
66
+ # Gitlab.job_artifacts_download("project", "master", "release")
67
+ #
68
+ # @param [Integer, String] id, The ID or name of a project.
69
+ # @param [String] ref, Ref Name
70
+ # @param [String] job, jobname
71
+ # @return [Array<Gitlab::ObjectifiedHash>]
72
+ def job_artifacts_download(project_id, ref_name, job_name)
73
+ get("/projects/#{url_encode project_id}/jobs/artifacts/#{ref_name}/download", query: { job: job_name },
74
+ format: nil,
75
+ headers: { Accept: 'text/plain' },
76
+ parser: ::Gitlab::Request::Parser)
77
+ end
78
+
79
+ # Get Job Trace
80
+ #
81
+ # @example
82
+ # Gitlab.job_trace(1,1)
83
+ # Gitlab.job_trace("project", 1)
84
+ #
85
+ # @param [Integer, String] The ID or name of a project.
86
+ # @param [Integer] the id of the job
87
+ # @return [Array<Gitlab::ObjectifiedHash>]
88
+ def job_trace(project_id, job_id)
89
+ get("/projects/#{url_encode project_id}/jobs/#{job_id}/trace",
90
+ format: nil,
91
+ headers: { Accept: 'text/plain' },
92
+ parser: ::Gitlab::Request::Parser)
93
+ end
94
+
95
+ # Cancel a job
96
+ #
97
+ # @example
98
+ # Gitlab.job_cancel(1,1)
99
+ # Gitlab.job_cancel("project", 1)
100
+ #
101
+ # @param [Integer, String] The ID or name of a project.
102
+ # @param [Integer] the id of the job
103
+ # @return [Array<Gitlab::ObjectifiedHash>]
104
+ def job_cancel(project_id, job_id)
105
+ post("/projects/#{url_encode project_id}/jobs/#{job_id}/cancel")
106
+ end
107
+
108
+ # Retry a job
109
+ #
110
+ # @example
111
+ # Gitlab.job_retry(1,1)
112
+ # Gitlab.job_retry("project", 1)
113
+ #
114
+ # @param [Integer, String] The ID or name of a project.
115
+ # @param [Integer] the id of the job
116
+ # @return [Array<Gitlab::ObjectifiedHash>]
117
+ def job_retry(project_id, job_id)
118
+ post("/projects/#{url_encode project_id}/jobs/#{job_id}/retry")
119
+ end
120
+
121
+ # Erase Job
122
+ #
123
+ # @example
124
+ # Gitlab.job_erase(1,1)
125
+ # Gitlab.job_erase("project", 1)
126
+ #
127
+ # @param [Integer, String] The ID or name of a project.
128
+ # @param [Integer] the id of the job
129
+ # @return [Array<Gitlab::ObjectifiedHash>]
130
+ def job_erase(project_id, job_id)
131
+ post("/projects/#{url_encode project_id}/jobs/#{job_id}/erase")
132
+ end
133
+
134
+ # Play a Job
135
+ # Triggers a manual action to start a job.
136
+ #
137
+ # @example
138
+ # Gitlab.job_play(1,1)
139
+ # Gitlab.job_play("project", 1)
140
+ #
141
+ # @param [Integer, String] The ID or name of a project.
142
+ # @param [Integer] the id of the job
143
+ # @return [Array<Gitlab::ObjectifiedHash>]
144
+ def job_play(project_id, job_id)
145
+ post("/projects/#{url_encode project_id}/jobs/#{job_id}/play")
146
+ end
147
+
148
+ # Keep Artifacts
149
+ # Prevents artifacts from being deleted when expiration is set.
150
+ #
151
+ # @example
152
+ # Gitlab.job_artifacts_keep(1,1)
153
+ # Gitlab.job_artifacts_keep("project", 1)
154
+ #
155
+ # @param [Integer, String] The ID or name of a project.
156
+ # @param [Integer] the id of the job
157
+ # @return [Array<Gitlab::ObjectifiedHash>]
158
+ def job_artifacts_keep(project_id, job_id)
159
+ post("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts/keep")
160
+ end
161
+ end
162
+ end
@@ -0,0 +1,16 @@
1
+ class Gitlab::Client
2
+ # Defines methods related to keys.
3
+ # @see https://docs.gitlab.com/ce/api/keys.html
4
+ module Keys
5
+ # Gets information about a key.
6
+ #
7
+ # @example
8
+ # Gitlab.key(1)
9
+ #
10
+ # @param [Integer] id The ID of a key.
11
+ # @return [Gitlab::ObjectifiedHash]
12
+ def key(id)
13
+ get("/keys/#{id}")
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,101 @@
1
+ class Gitlab::Client
2
+ # Defines methods related to pipelines.
3
+ # @see https://docs.gitlab.com/ce/api/pipeline_triggers.html
4
+ # @see https://docs.gitlab.com/ce/ci/triggers/README.html
5
+ module PipelineTriggers
6
+ # Gets a list of the project's pipeline triggers
7
+ #
8
+ # @example
9
+ # Gitlab.triggers(5)
10
+ #
11
+ # @param [Integer, String] project The ID or name of a project.
12
+ # @return [Array<Gitlab::ObjectifiedHash>] The list of triggers.
13
+ def triggers(project)
14
+ get("/projects/#{url_encode project}/triggers")
15
+ end
16
+
17
+ # Gets details of project's pipeline trigger.
18
+ #
19
+ # @example
20
+ # Gitlab.trigger(5, 1)
21
+ #
22
+ # @param [Integer, String] project The ID or name of a project.
23
+ # @param [Integer] trigger_id The trigger ID.
24
+ # @return [Gitlab::ObjectifiedHash] The trigger.
25
+ def trigger(project, trigger_id)
26
+ get("/projects/#{url_encode project}/triggers/#{trigger_id}")
27
+ end
28
+
29
+ # Create a pipeline trigger for a project.
30
+ #
31
+ # @example
32
+ # Gitlab.create_trigger(5, description: "my description")
33
+ #
34
+ # @param [Integer, String] project The ID or name of a project.
35
+ # @param [String] description The trigger name
36
+ # @return [Gitlab::ObjectifiedHash] The created trigger.
37
+ def create_trigger(project, description)
38
+ post("/projects/#{url_encode project}/triggers", body: {description: description})
39
+ end
40
+
41
+ # Update a project trigger
42
+ #
43
+ # @example
44
+ # Gitlab.update_trigger(5, 1, description: "my description")
45
+ #
46
+ # @param [Integer, String] project The ID or name of a project.
47
+ # @param [Integer] trigger_id The trigger ID.
48
+ # @param [Hash] options A customizable set of options.
49
+ # @option options [String] :description The trigger name.
50
+ # @return [Gitlab::ObjectifiedHash] The updated trigger.
51
+ def update_trigger(project, trigger_id, options={})
52
+ put("/projects/#{url_encode project}/triggers/#{trigger_id}", body: options)
53
+ end
54
+
55
+ # Take ownership of a project trigger
56
+ #
57
+ # @example
58
+ # Gitlab.trigger_take_ownership(5, 1)
59
+ #
60
+ # @param [Integer, String] project The ID or name of a project.
61
+ # @param [Integer] trigger_id The trigger ID.
62
+ # @return [Gitlab::ObjectifiedHash] The updated trigger.
63
+ def trigger_take_ownership(project, trigger_id)
64
+ post("/projects/#{url_encode project}/triggers/#{trigger_id}/take_ownership")
65
+ end
66
+
67
+ # Remove a project's pipeline trigger.
68
+ #
69
+ # @example
70
+ # Gitlab.remove_trigger(5, 1)
71
+ #
72
+ # @param [Integer, String] project The ID or name of a project.
73
+ # @param [Integer] trigger_id The trigger ID.
74
+ # @return [void] This API call returns an empty response body.
75
+ def remove_trigger(project, trigger_id)
76
+ delete("/projects/#{url_encode project}/triggers/#{trigger_id}")
77
+ end
78
+ alias_method :delete_trigger, :remove_trigger
79
+
80
+ # Run the given project pipeline trigger.
81
+ #
82
+ # @example
83
+ # Gitlab.trigger_build(5, '7b9148c158980bbd9bcea92c17522d', 'master')
84
+ # Gitlab.trigger_build(5, '7b9148c158980bbd9bcea92c17522d', 'master', { variable1: "value", variable2: "value2" })
85
+ #
86
+ # @see https://docs.gitlab.com/ce/ci/triggers/README.html
87
+ #
88
+ # @param [Integer, String] project The ID or name of the project.
89
+ # @param [String] token The token of a trigger.
90
+ # @param [String] ref Branch or tag name to build.
91
+ # @param [Hash] variables A set of build variables to use for the build. (optional)
92
+ # @return [Gitlab::ObjectifiedHash] The trigger.
93
+ def run_trigger(project, token, ref, variables={})
94
+ post("/projects/#{url_encode project}/trigger/pipeline", unauthenticated: true, body: {
95
+ token: token,
96
+ ref: ref,
97
+ variables: variables
98
+ })
99
+ end
100
+ end
101
+ end
@@ -120,7 +120,7 @@ class Gitlab::Client
120
120
  # @return [Gitlab::ObjectifiedHash]
121
121
  # @note This method doesn't require private_token to be set.
122
122
  def session(email, password)
123
- post("/session", body: { email: email, password: password })
123
+ post("/session", body: { email: email, password: password }, unauthenticated: true)
124
124
  end
125
125
 
126
126
  # Gets a list of user's SSH keys.
@@ -6,7 +6,7 @@ module Gitlab
6
6
  class Request
7
7
  include HTTParty
8
8
  format :json
9
- headers 'Accept' => 'application/json'
9
+ headers 'Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded'
10
10
  parser proc { |body, _| parse(body) }
11
11
 
12
12
  attr_accessor :private_token, :endpoint
@@ -45,7 +45,7 @@ module Gitlab
45
45
 
46
46
  def post(path, options={})
47
47
  set_httparty_config(options)
48
- set_authorization_header(options, path)
48
+ set_authorization_header(options)
49
49
  validate self.class.post(@endpoint + path, options)
50
50
  end
51
51
 
@@ -96,9 +96,12 @@ module Gitlab
96
96
  private
97
97
 
98
98
  # Sets a PRIVATE-TOKEN or Authorization header for requests.
99
+ #
100
+ # @param [Hash] options A customizable set of options.
101
+ # @option options [Boolean] :unauthenticated true if the API call does not require user authentication.
99
102
  # @raise [Error::MissingCredentials] if private_token and auth_token are not set.
100
- def set_authorization_header(options, path=nil)
101
- unless path == '/session'
103
+ def set_authorization_header(options)
104
+ unless options[:unauthenticated]
102
105
  raise Error::MissingCredentials.new("Please provide a private_token or auth_token for user") unless @private_token
103
106
  if @private_token.length <= 20
104
107
  options[:headers] = { 'PRIVATE-TOKEN' => @private_token }
@@ -1,3 +1,3 @@
1
1
  module Gitlab
2
- VERSION = "4.0.0"
2
+ VERSION = "4.1.0"
3
3
  end
File without changes
@@ -0,0 +1,43 @@
1
+ {
2
+ "commit": {
3
+ "author_email": "admin@example.com",
4
+ "author_name": "Administrator",
5
+ "created_at": "2015-12-24T16:51:14.000+01:00",
6
+ "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
7
+ "message": "Test the CI integration.",
8
+ "short_id": "0ff3ae19",
9
+ "title": "Test the CI integration."
10
+ },
11
+ "coverage": null,
12
+ "created_at": "2015-12-24T15:51:21.880Z",
13
+ "artifacts_file": null,
14
+ "finished_at": "2015-12-24T17:54:31.198Z",
15
+ "id": 8,
16
+ "name": "rubocop",
17
+ "pipeline": {
18
+ "id": 6,
19
+ "ref": "master",
20
+ "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
21
+ "status": "pending"
22
+ },
23
+ "ref": "master",
24
+ "runner": null,
25
+ "stage": "test",
26
+ "started_at": "2015-12-24T17:54:30.733Z",
27
+ "status": "failed",
28
+ "tag": false,
29
+ "user": {
30
+ "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
31
+ "bio": null,
32
+ "created_at": "2015-12-21T13:14:24.077Z",
33
+ "id": 1,
34
+ "linkedin": "",
35
+ "name": "Administrator",
36
+ "skype": "",
37
+ "state": "active",
38
+ "twitter": "",
39
+ "username": "root",
40
+ "web_url": "http://gitlab.dev/root",
41
+ "website_url": ""
42
+ }
43
+ }
@@ -0,0 +1 @@
1
+ asdasd
@@ -0,0 +1,91 @@
1
+ [
2
+ {
3
+ "commit": {
4
+ "author_email": "admin@example.com",
5
+ "author_name": "Administrator",
6
+ "created_at": "2015-12-24T16:51:14.000+01:00",
7
+ "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
8
+ "message": "Test the CI integration.",
9
+ "short_id": "0ff3ae19",
10
+ "title": "Test the CI integration."
11
+ },
12
+ "coverage": null,
13
+ "created_at": "2015-12-24T15:51:21.802Z",
14
+ "artifacts_file": {
15
+ "filename": "artifacts.zip",
16
+ "size": 1000
17
+ },
18
+ "finished_at": "2015-12-24T17:54:27.895Z",
19
+ "id": 7,
20
+ "name": "teaspoon",
21
+ "pipeline": {
22
+ "id": 6,
23
+ "ref": "master",
24
+ "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
25
+ "status": "pending"
26
+ },
27
+ "ref": "master",
28
+ "runner": null,
29
+ "stage": "test",
30
+ "started_at": "2015-12-24T17:54:27.722Z",
31
+ "status": "failed",
32
+ "tag": false,
33
+ "user": {
34
+ "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
35
+ "bio": null,
36
+ "created_at": "2015-12-21T13:14:24.077Z",
37
+ "id": 1,
38
+ "linkedin": "",
39
+ "name": "Administrator",
40
+ "skype": "",
41
+ "state": "active",
42
+ "twitter": "",
43
+ "username": "root",
44
+ "web_url": "http://gitlab.dev/root",
45
+ "website_url": ""
46
+ }
47
+ },
48
+ {
49
+ "commit": {
50
+ "author_email": "admin@example.com",
51
+ "author_name": "Administrator",
52
+ "created_at": "2015-12-24T16:51:14.000+01:00",
53
+ "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
54
+ "message": "Test the CI integration.",
55
+ "short_id": "0ff3ae19",
56
+ "title": "Test the CI integration."
57
+ },
58
+ "coverage": null,
59
+ "created_at": "2015-12-24T15:51:21.727Z",
60
+ "artifacts_file": null,
61
+ "finished_at": "2015-12-24T17:54:24.921Z",
62
+ "id": 6,
63
+ "name": "spinach:other",
64
+ "pipeline": {
65
+ "id": 6,
66
+ "ref": "master",
67
+ "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
68
+ "status": "pending"
69
+ },
70
+ "ref": "master",
71
+ "runner": null,
72
+ "stage": "test",
73
+ "started_at": "2015-12-24T17:54:24.729Z",
74
+ "status": "failed",
75
+ "tag": false,
76
+ "user": {
77
+ "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
78
+ "bio": null,
79
+ "created_at": "2015-12-21T13:14:24.077Z",
80
+ "id": 1,
81
+ "linkedin": "",
82
+ "name": "Administrator",
83
+ "skype": "",
84
+ "state": "active",
85
+ "twitter": "",
86
+ "username": "root",
87
+ "web_url": "http://gitlab.dev/root",
88
+ "website_url": ""
89
+ }
90
+ }
91
+ ]
@@ -0,0 +1,91 @@
1
+ [
2
+ {
3
+ "commit": {
4
+ "author_email": "admin@example.com",
5
+ "author_name": "Administrator",
6
+ "created_at": "2015-12-24T16:51:14.000+01:00",
7
+ "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
8
+ "message": "Test the CI integration.",
9
+ "short_id": "0ff3ae19",
10
+ "title": "Test the CI integration."
11
+ },
12
+ "coverage": null,
13
+ "created_at": "2015-12-24T15:51:21.802Z",
14
+ "artifacts_file": {
15
+ "filename": "artifacts.zip",
16
+ "size": 1000
17
+ },
18
+ "finished_at": "2015-12-24T17:54:27.895Z",
19
+ "id": 7,
20
+ "name": "teaspoon",
21
+ "pipeline": {
22
+ "id": 6,
23
+ "ref": "master",
24
+ "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
25
+ "status": "pending"
26
+ },
27
+ "ref": "master",
28
+ "runner": null,
29
+ "stage": "test",
30
+ "started_at": "2015-12-24T17:54:27.722Z",
31
+ "status": "failed",
32
+ "tag": false,
33
+ "user": {
34
+ "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
35
+ "bio": null,
36
+ "created_at": "2015-12-21T13:14:24.077Z",
37
+ "id": 1,
38
+ "linkedin": "",
39
+ "name": "Administrator",
40
+ "skype": "",
41
+ "state": "active",
42
+ "twitter": "",
43
+ "username": "root",
44
+ "web_url": "http://gitlab.dev/root",
45
+ "website_url": ""
46
+ }
47
+ },
48
+ {
49
+ "commit": {
50
+ "author_email": "admin@example.com",
51
+ "author_name": "Administrator",
52
+ "created_at": "2015-12-24T16:51:14.000+01:00",
53
+ "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
54
+ "message": "Test the CI integration.",
55
+ "short_id": "0ff3ae19",
56
+ "title": "Test the CI integration."
57
+ },
58
+ "coverage": null,
59
+ "created_at": "2015-12-24T15:51:21.727Z",
60
+ "artifacts_file": null,
61
+ "finished_at": "2015-12-24T17:54:24.921Z",
62
+ "id": 6,
63
+ "name": "spinach:other",
64
+ "pipeline": {
65
+ "id": 6,
66
+ "ref": "master",
67
+ "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd",
68
+ "status": "pending"
69
+ },
70
+ "ref": "master",
71
+ "runner": null,
72
+ "stage": "test",
73
+ "started_at": "2015-12-24T17:54:24.729Z",
74
+ "status": "failed",
75
+ "tag": false,
76
+ "user": {
77
+ "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
78
+ "bio": null,
79
+ "created_at": "2015-12-21T13:14:24.077Z",
80
+ "id": 1,
81
+ "linkedin": "",
82
+ "name": "Administrator",
83
+ "skype": "",
84
+ "state": "active",
85
+ "twitter": "",
86
+ "username": "root",
87
+ "web_url": "http://gitlab.dev/root",
88
+ "website_url": ""
89
+ }
90
+ }
91
+ ]
@@ -0,0 +1 @@
1
+ {"id":8,"variables":{"a":"10"}}
@@ -1,7 +1,10 @@
1
1
  {
2
- "created_at": "2015-12-23T16:25:56.760Z",
2
+ "id": 10,
3
+ "description": "my trigger",
4
+ "created_at": "2016-01-07T09:53:58.235Z",
3
5
  "deleted_at": null,
4
6
  "last_used": null,
5
- "token": "7b9148c158980bbd9bcea92c17522d",
6
- "updated_at": "2015-12-23T16:25:56.760Z"
7
+ "token": "6d056f63e50fe6f8c5f8f4aa10edb7",
8
+ "updated_at": "2016-01-07T09:53:58.235Z",
9
+ "owner": null
7
10
  }
@@ -1,16 +1,12 @@
1
1
  [
2
2
  {
3
- "created_at": "2015-12-23T16:24:34.716Z",
4
- "deleted_at": null,
5
- "last_used": "2016-01-04T15:41:21.986Z",
6
- "token": "fbdb730c2fbdb095a0862dbd8ab88b",
7
- "updated_at": "2015-12-23T16:24:34.716Z"
8
- },
9
- {
10
- "created_at": "2015-12-23T16:25:56.760Z",
3
+ "id": 10,
4
+ "description": "my trigger",
5
+ "created_at": "2016-01-07T09:53:58.235Z",
11
6
  "deleted_at": null,
12
7
  "last_used": null,
13
- "token": "7b9148c158980bbd9bcea92c17522d",
14
- "updated_at": "2015-12-23T16:25:56.760Z"
8
+ "token": "6d056f63e50fe6f8c5f8f4aa10edb7",
9
+ "updated_at": "2016-01-07T09:53:58.235Z",
10
+ "owner": null
15
11
  }
16
12
  ]
@@ -0,0 +1,135 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ describe '.jobs' do
5
+ before do
6
+ stub_get('/projects/1/jobs', 'jobs')
7
+ @projects = Gitlab.jobs(1)
8
+ end
9
+
10
+ it 'should get the correct resource' do
11
+ expect(a_get('/projects/1/jobs')).to have_been_made
12
+ end
13
+ end
14
+
15
+ describe '.jobs - with scopes' do
16
+ before do
17
+ stub_get('/projects/1/jobs?scope[]=created&scope[]=running', 'jobs')
18
+ @projects = Gitlab.jobs(1, scope: %w[created running])
19
+ end
20
+
21
+ it 'should get the correct resource' do
22
+ expect(a_get('/projects/1/jobs?scope[]=created&scope[]=running')).to have_been_made
23
+ end
24
+ end
25
+
26
+ describe '.pipeline_jobs' do
27
+ before do
28
+ stub_get('/projects/1/pipelines/1/jobs', 'pipeline_jobs')
29
+ @projects = Gitlab.pipeline_jobs(1, 1)
30
+ end
31
+ it 'should get the correct resource' do
32
+ expect(a_get('/projects/1/pipelines/1/jobs')).to have_been_made
33
+ end
34
+ end
35
+
36
+ describe '.pipeline_jobs - with scope' do
37
+ before do
38
+ stub_get('/projects/1/pipelines/1/jobs?scope[]=running&scope[]=created', 'pipeline_jobs')
39
+ @projects = Gitlab.pipeline_jobs(1, 1, scope: %w[running created])
40
+ end
41
+ it 'should get the correct resource' do
42
+ expect(a_get('/projects/1/pipelines/1/jobs?scope[]=running&scope[]=created')).to have_been_made
43
+ end
44
+ end
45
+
46
+ describe '.job' do
47
+ before do
48
+ stub_get('/projects/1/jobs/1', 'job')
49
+ @projects = Gitlab.job(1, 1)
50
+ end
51
+ it 'should get the correct resource' do
52
+ expect(a_get('/projects/1/jobs/1')).to have_been_made
53
+ end
54
+ end
55
+
56
+ describe '.job_artifacts' do
57
+ before do
58
+ stub_get('/projects/1/jobs/1/artifacts', 'job')
59
+ @projects = Gitlab.job_artifacts(1, 1)
60
+ end
61
+ it 'should get the correct resource' do
62
+ expect(a_get('/projects/1/jobs/1/artifacts')).to have_been_made
63
+ end
64
+ end
65
+
66
+ describe '.job_artifacts_download' do
67
+ before do
68
+ stub_get('/projects/1/jobs/artifacts/master/download?job=Release%20Build', 'job')
69
+ @projects = Gitlab.job_artifacts_download(1, 'master', 'Release Build')
70
+ end
71
+ it 'should get the correct resource' do
72
+ expect(a_get('/projects/1/jobs/artifacts/master/download?job=Release%20Build')).to have_been_made
73
+ end
74
+ end
75
+
76
+ describe '.job_trace' do
77
+ before do
78
+ stub_get('/projects/1/jobs/1/trace', 'job_trace')
79
+ @projects = Gitlab.job_trace(1, 1)
80
+ end
81
+ it 'should get the correct resource' do
82
+ expect(a_get('/projects/1/jobs/1/trace')).to have_been_made
83
+ end
84
+ end
85
+
86
+ describe '.job_cancel' do
87
+ before do
88
+ stub_post('/projects/1/jobs/1/cancel', 'job')
89
+ @projects = Gitlab.job_cancel(1, 1)
90
+ end
91
+ it 'should get the correct resource' do
92
+ expect(a_post('/projects/1/jobs/1/cancel')).to have_been_made
93
+ end
94
+ end
95
+
96
+ describe '.job_retry' do
97
+ before do
98
+ stub_post('/projects/1/jobs/1/retry', 'job')
99
+ @projects = Gitlab.job_retry(1, 1)
100
+ end
101
+ it 'should get the correct resource' do
102
+ expect(a_post('/projects/1/jobs/1/retry')).to have_been_made
103
+ end
104
+ end
105
+
106
+ describe '.job_erase' do
107
+ before do
108
+ stub_post('/projects/1/jobs/1/erase', 'job')
109
+ @projects = Gitlab.job_erase(1, 1)
110
+ end
111
+ it 'should get the correct resource' do
112
+ expect(a_post('/projects/1/jobs/1/erase')).to have_been_made
113
+ end
114
+ end
115
+
116
+ describe '.job_play' do
117
+ before do
118
+ stub_post('/projects/1/jobs/1/play', 'job')
119
+ @projects = Gitlab.job_play(1, 1)
120
+ end
121
+ it 'should get the correct resource' do
122
+ expect(a_post('/projects/1/jobs/1/play')).to have_been_made
123
+ end
124
+ end
125
+
126
+ describe '.job_artifacts_keep' do
127
+ before do
128
+ stub_post('/projects/1/jobs/1/artifacts/keep', 'job')
129
+ @projects = Gitlab.job_artifacts_keep(1, 1)
130
+ end
131
+ it 'should get the correct resource' do
132
+ expect(a_post('/projects/1/jobs/1/artifacts/keep')).to have_been_made
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ describe ".key" do
5
+ before do
6
+ stub_get("/keys/1", "key")
7
+ @key = Gitlab.key(1)
8
+ end
9
+
10
+ it "should get the correct resource" do
11
+ expect(a_get("/keys/1")).to have_been_made
12
+ end
13
+
14
+ it "should return information about a key" do
15
+ expect(@key.id).to eq(1)
16
+ expect(@key.title).to eq("narkoz@helium")
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,157 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gitlab::Client do
4
+ it { should respond_to :delete_trigger }
5
+
6
+ describe ".triggers" do
7
+ before do
8
+ stub_get("/projects/3/triggers", "triggers")
9
+ @triggers = Gitlab.triggers(3)
10
+ end
11
+
12
+ it "should get the correct resource" do
13
+ expect(a_get("/projects/3/triggers")).to have_been_made
14
+ end
15
+
16
+ it "should return an array of project's triggers" do
17
+ expect(@triggers).to be_a Gitlab::PaginatedResponse
18
+ expect(@triggers.first.token).to eq("6d056f63e50fe6f8c5f8f4aa10edb7")
19
+ end
20
+ end
21
+
22
+ describe ".trigger" do
23
+ before do
24
+ stub_get("/projects/3/triggers/10", "trigger")
25
+ @trigger = Gitlab.trigger(3, 10)
26
+ end
27
+
28
+ it "should get the correct resource" do
29
+ expect(a_get("/projects/3/triggers/10")).to have_been_made
30
+ end
31
+
32
+ it "should return information about a trigger" do
33
+ expect(@trigger.created_at).to eq("2016-01-07T09:53:58.235Z")
34
+ expect(@trigger.token).to eq("6d056f63e50fe6f8c5f8f4aa10edb7")
35
+ end
36
+ end
37
+
38
+ describe ".create_trigger" do
39
+ before do
40
+ stub_post("/projects/3/triggers", "trigger")
41
+ @trigger = Gitlab.create_trigger(3, "my description")
42
+ end
43
+
44
+ it "should get the correct resource" do
45
+ expect(a_post("/projects/3/triggers").
46
+ with(body: { description: "my description" })).to have_been_made
47
+ end
48
+
49
+ it "should return information about a new trigger" do
50
+ expect(@trigger.created_at).to eq("2016-01-07T09:53:58.235Z")
51
+ expect(@trigger.token).to eq("6d056f63e50fe6f8c5f8f4aa10edb7")
52
+ end
53
+ end
54
+
55
+ describe ".update_trigger" do
56
+ before do
57
+ stub_put("/projects/3/triggers/1", "trigger")
58
+ @trigger = Gitlab.update_trigger(3, 1, description: "my description")
59
+ end
60
+
61
+ it "should get the correct resource" do
62
+ expect(a_put("/projects/3/triggers/1").
63
+ with(body: { description: "my description" })).to have_been_made
64
+ end
65
+
66
+ it "should return information about the trigger" do
67
+ expect(@trigger.created_at).to eq("2016-01-07T09:53:58.235Z")
68
+ expect(@trigger.token).to eq("6d056f63e50fe6f8c5f8f4aa10edb7")
69
+ end
70
+ end
71
+
72
+ describe ".trigger_take_ownership" do
73
+ before do
74
+ stub_post("/projects/3/triggers/1/take_ownership", "trigger")
75
+ @trigger = Gitlab.trigger_take_ownership(3, 1)
76
+ end
77
+
78
+ it "should get the correct resource" do
79
+ expect(a_post("/projects/3/triggers/1/take_ownership")).to have_been_made
80
+ end
81
+
82
+ it "should return information about the trigger" do
83
+ expect(@trigger.created_at).to eq("2016-01-07T09:53:58.235Z")
84
+ expect(@trigger.token).to eq("6d056f63e50fe6f8c5f8f4aa10edb7")
85
+ end
86
+ end
87
+
88
+ describe ".remove_trigger" do
89
+ before do
90
+ stub_delete("/projects/3/triggers/10", "empty")
91
+ @trigger = Gitlab.remove_trigger(3, 10)
92
+ end
93
+
94
+ it "should get the correct resource" do
95
+ expect(a_delete("/projects/3/triggers/10")).to have_been_made
96
+ end
97
+ end
98
+
99
+ describe ".run_trigger" do
100
+ before do
101
+ stub_request(:post, "#{Gitlab.endpoint}/projects/3/trigger/pipeline").
102
+ to_return(body: load_fixture("run_trigger"), status: 200)
103
+ end
104
+
105
+ context "when private_token is not set" do
106
+ before do
107
+ Gitlab.private_token = nil
108
+ end
109
+
110
+ it "should not raise Error::MissingCredentials" do
111
+ expect { Gitlab.run_trigger(3, "7b9148c158980bbd9bcea92c17522d", "master", {a: 10}) }.to_not raise_error
112
+ end
113
+
114
+ after do
115
+ Gitlab.private_token = 'secret'
116
+ end
117
+ end
118
+
119
+ context "without variables" do
120
+ before do
121
+ @trigger = Gitlab.run_trigger(3, "7b9148c158980bbd9bcea92c17522d", "master")
122
+ end
123
+
124
+ it "should get the correct resource" do
125
+ expect(a_request(:post, "#{Gitlab.endpoint}/projects/3/trigger/pipeline").
126
+ with(body: {
127
+ token: "7b9148c158980bbd9bcea92c17522d",
128
+ ref: "master"
129
+ })).to have_been_made
130
+ end
131
+
132
+ it "should return information about the triggered build" do
133
+ expect(@trigger.id).to eq(8)
134
+ end
135
+ end
136
+
137
+ context "with variables" do
138
+ before do
139
+ @trigger = Gitlab.run_trigger(3, "7b9148c158980bbd9bcea92c17522d", "master", {a: 10})
140
+ end
141
+
142
+ it "should get the correct resource" do
143
+ expect(a_request(:post, "#{Gitlab.endpoint}/projects/3/trigger/pipeline").
144
+ with(body: {
145
+ token: "7b9148c158980bbd9bcea92c17522d",
146
+ ref: "master",
147
+ variables: {a: "10"}
148
+ })).to have_been_made
149
+ end
150
+
151
+ it "should return information about the triggered build" do
152
+ expect(@trigger.id).to eq(8)
153
+ expect(@trigger.variables.a).to eq("10")
154
+ end
155
+ end
156
+ end
157
+ end
@@ -15,7 +15,7 @@ describe Gitlab::Request do
15
15
  expect(default_options).to be_a Hash
16
16
  expect(default_options[:parser]).to be_a Proc
17
17
  expect(default_options[:format]).to eq(:json)
18
- expect(default_options[:headers]).to eq('Accept' => 'application/json')
18
+ expect(default_options[:headers]).to eq('Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded')
19
19
  expect(default_options[:default_params]).to be_nil
20
20
  end
21
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nihad Abbasov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-10 00:00:00.000000000 Z
11
+ date: 2017-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: terminal-table
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.7.1
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 1.7.1
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -120,17 +120,19 @@ files:
120
120
  - lib/gitlab/cli_helpers.rb
121
121
  - lib/gitlab/client.rb
122
122
  - lib/gitlab/client/branches.rb
123
- - lib/gitlab/client/build_triggers.rb
124
123
  - lib/gitlab/client/build_variables.rb
125
124
  - lib/gitlab/client/builds.rb
126
125
  - lib/gitlab/client/commits.rb
127
126
  - lib/gitlab/client/groups.rb
128
127
  - lib/gitlab/client/issues.rb
128
+ - lib/gitlab/client/jobs.rb
129
+ - lib/gitlab/client/keys.rb
129
130
  - lib/gitlab/client/labels.rb
130
131
  - lib/gitlab/client/merge_requests.rb
131
132
  - lib/gitlab/client/milestones.rb
132
133
  - lib/gitlab/client/namespaces.rb
133
134
  - lib/gitlab/client/notes.rb
135
+ - lib/gitlab/client/pipeline_triggers.rb
134
136
  - lib/gitlab/client/pipelines.rb
135
137
  - lib/gitlab/client/projects.rb
136
138
  - lib/gitlab/client/repositories.rb
@@ -163,6 +165,7 @@ files:
163
165
  - spec/fixtures/builds.json
164
166
  - spec/fixtures/builds_commits.json
165
167
  - spec/fixtures/compare_merge_request_diff.json
168
+ - spec/fixtures/empty.json
166
169
  - spec/fixtures/error_already_exists.json
167
170
  - spec/fixtures/error_project_not_found.json
168
171
  - spec/fixtures/get_repository_file.json
@@ -179,6 +182,9 @@ files:
179
182
  - spec/fixtures/groups.json
180
183
  - spec/fixtures/issue.json
181
184
  - spec/fixtures/issues.json
185
+ - spec/fixtures/job.json
186
+ - spec/fixtures/job_trace.json
187
+ - spec/fixtures/jobs.json
182
188
  - spec/fixtures/key.json
183
189
  - spec/fixtures/keys.json
184
190
  - spec/fixtures/label.json
@@ -200,6 +206,7 @@ files:
200
206
  - spec/fixtures/pipeline.json
201
207
  - spec/fixtures/pipeline_cancel.json
202
208
  - spec/fixtures/pipeline_create.json
209
+ - spec/fixtures/pipeline_jobs.json
203
210
  - spec/fixtures/pipeline_retry.json
204
211
  - spec/fixtures/pipelines.json
205
212
  - spec/fixtures/project.json
@@ -236,6 +243,7 @@ files:
236
243
  - spec/fixtures/release_create.json
237
244
  - spec/fixtures/release_update.json
238
245
  - spec/fixtures/repository_file.json
246
+ - spec/fixtures/run_trigger.json
239
247
  - spec/fixtures/runner.json
240
248
  - spec/fixtures/runner_delete.json
241
249
  - spec/fixtures/runner_edit.json
@@ -270,18 +278,20 @@ files:
270
278
  - spec/gitlab/cli_helpers_spec.rb
271
279
  - spec/gitlab/cli_spec.rb
272
280
  - spec/gitlab/client/branches_spec.rb
273
- - spec/gitlab/client/build_triggers_spec.rb
274
281
  - spec/gitlab/client/build_variables_spec.rb
275
282
  - spec/gitlab/client/builds_spec.rb
276
283
  - spec/gitlab/client/client_spec.rb
277
284
  - spec/gitlab/client/commits_spec.rb
278
285
  - spec/gitlab/client/groups_spec.rb
279
286
  - spec/gitlab/client/issues_spec.rb
287
+ - spec/gitlab/client/jobs_spec.rb
288
+ - spec/gitlab/client/keys_spec.rb
280
289
  - spec/gitlab/client/labels_spec.rb
281
290
  - spec/gitlab/client/merge_requests_spec.rb
282
291
  - spec/gitlab/client/milestones_spec.rb
283
292
  - spec/gitlab/client/namespaces_spec.rb
284
293
  - spec/gitlab/client/notes_spec.rb
294
+ - spec/gitlab/client/pipeline_triggers_spec.rb
285
295
  - spec/gitlab/client/pipelines_spec.rb
286
296
  - spec/gitlab/client/projects_spec.rb
287
297
  - spec/gitlab/client/repositories_spec.rb
@@ -339,6 +349,7 @@ test_files:
339
349
  - spec/fixtures/builds.json
340
350
  - spec/fixtures/builds_commits.json
341
351
  - spec/fixtures/compare_merge_request_diff.json
352
+ - spec/fixtures/empty.json
342
353
  - spec/fixtures/error_already_exists.json
343
354
  - spec/fixtures/error_project_not_found.json
344
355
  - spec/fixtures/get_repository_file.json
@@ -355,6 +366,9 @@ test_files:
355
366
  - spec/fixtures/groups.json
356
367
  - spec/fixtures/issue.json
357
368
  - spec/fixtures/issues.json
369
+ - spec/fixtures/job.json
370
+ - spec/fixtures/job_trace.json
371
+ - spec/fixtures/jobs.json
358
372
  - spec/fixtures/key.json
359
373
  - spec/fixtures/keys.json
360
374
  - spec/fixtures/label.json
@@ -376,6 +390,7 @@ test_files:
376
390
  - spec/fixtures/pipeline.json
377
391
  - spec/fixtures/pipeline_cancel.json
378
392
  - spec/fixtures/pipeline_create.json
393
+ - spec/fixtures/pipeline_jobs.json
379
394
  - spec/fixtures/pipeline_retry.json
380
395
  - spec/fixtures/pipelines.json
381
396
  - spec/fixtures/project.json
@@ -412,6 +427,7 @@ test_files:
412
427
  - spec/fixtures/release_create.json
413
428
  - spec/fixtures/release_update.json
414
429
  - spec/fixtures/repository_file.json
430
+ - spec/fixtures/run_trigger.json
415
431
  - spec/fixtures/runner.json
416
432
  - spec/fixtures/runner_delete.json
417
433
  - spec/fixtures/runner_edit.json
@@ -446,18 +462,20 @@ test_files:
446
462
  - spec/gitlab/cli_helpers_spec.rb
447
463
  - spec/gitlab/cli_spec.rb
448
464
  - spec/gitlab/client/branches_spec.rb
449
- - spec/gitlab/client/build_triggers_spec.rb
450
465
  - spec/gitlab/client/build_variables_spec.rb
451
466
  - spec/gitlab/client/builds_spec.rb
452
467
  - spec/gitlab/client/client_spec.rb
453
468
  - spec/gitlab/client/commits_spec.rb
454
469
  - spec/gitlab/client/groups_spec.rb
455
470
  - spec/gitlab/client/issues_spec.rb
471
+ - spec/gitlab/client/jobs_spec.rb
472
+ - spec/gitlab/client/keys_spec.rb
456
473
  - spec/gitlab/client/labels_spec.rb
457
474
  - spec/gitlab/client/merge_requests_spec.rb
458
475
  - spec/gitlab/client/milestones_spec.rb
459
476
  - spec/gitlab/client/namespaces_spec.rb
460
477
  - spec/gitlab/client/notes_spec.rb
478
+ - spec/gitlab/client/pipeline_triggers_spec.rb
461
479
  - spec/gitlab/client/pipelines_spec.rb
462
480
  - spec/gitlab/client/projects_spec.rb
463
481
  - spec/gitlab/client/repositories_spec.rb
@@ -1,51 +0,0 @@
1
- class Gitlab::Client
2
- # Defines methods related to builds.
3
- # @see https://docs.gitlab.com/ce/api/build_triggers.html
4
- module BuildTriggers
5
- # Gets a list of the project's build triggers
6
- #
7
- # @example
8
- # Gitlab.triggers(5)
9
- #
10
- # @param [Integer, String] project The ID or name of a project.
11
- # @return [Array<Gitlab::ObjectifiedHash>] The list of triggers.
12
- def triggers(project)
13
- get("/projects/#{url_encode project}/triggers")
14
- end
15
-
16
- # Gets details of project's build trigger.
17
- #
18
- # @example
19
- # Gitlab.trigger(5, '7b9148c158980bbd9bcea92c17522d')
20
- #
21
- # @param [Integer, String] project The ID or name of a project.
22
- # @param [String] token The token of a trigger.
23
- # @return [Gitlab::ObjectifiedHash] The trigger.
24
- def trigger(project, token)
25
- get("/projects/#{url_encode project}/triggers/#{token}")
26
- end
27
-
28
- # Create a build trigger for a project.
29
- #
30
- # @example
31
- # Gitlab.create_trigger(5)
32
- #
33
- # @param [Integer, String] project The ID or name of a project.
34
- # @return [Gitlab::ObjectifiedHash] The trigger.
35
- def create_trigger(project)
36
- post("/projects/#{url_encode project}/triggers")
37
- end
38
-
39
- # Remove a project's build trigger.
40
- #
41
- # @example
42
- # Gitlab.remove_trigger(5, '7b9148c158980bbd9bcea92c17522d')
43
- #
44
- # @param [Integer, String] project The ID or name of a project.
45
- # @param [String] token The token of a trigger.
46
- # @return [Gitlab::ObjectifiedHash] The trigger.
47
- def remove_trigger(project, token)
48
- delete("/projects/#{url_encode project}/triggers/#{token}")
49
- end
50
- end
51
- end
@@ -1,67 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Gitlab::Client do
4
- describe ".triggers" do
5
- before do
6
- stub_get("/projects/3/triggers", "triggers")
7
- @triggers = Gitlab.triggers(3)
8
- end
9
-
10
- it "should get the correct resource" do
11
- expect(a_get("/projects/3/triggers")).to have_been_made
12
- end
13
-
14
- it "should return an array of project's triggers" do
15
- expect(@triggers).to be_a Gitlab::PaginatedResponse
16
- expect(@triggers.first.token).to eq("fbdb730c2fbdb095a0862dbd8ab88b")
17
- end
18
- end
19
-
20
- describe ".trigger" do
21
- before do
22
- stub_get("/projects/3/triggers/7b9148c158980bbd9bcea92c17522d", "trigger")
23
- @trigger = Gitlab.trigger(3, "7b9148c158980bbd9bcea92c17522d")
24
- end
25
-
26
- it "should get the correct resource" do
27
- expect(a_get("/projects/3/triggers/7b9148c158980bbd9bcea92c17522d")).to have_been_made
28
- end
29
-
30
- it "should return information about a trigger" do
31
- expect(@trigger.created_at).to eq("2015-12-23T16:25:56.760Z")
32
- expect(@trigger.token).to eq("7b9148c158980bbd9bcea92c17522d")
33
- end
34
- end
35
-
36
- describe ".create_trigger" do
37
- before do
38
- stub_post("/projects/3/triggers", "trigger")
39
- @trigger = Gitlab.create_trigger(3)
40
- end
41
-
42
- it "should get the correct resource" do
43
- expect(a_post("/projects/3/triggers")).to have_been_made
44
- end
45
-
46
- it "should return information about a new trigger" do
47
- expect(@trigger.created_at).to eq("2015-12-23T16:25:56.760Z")
48
- expect(@trigger.token).to eq("7b9148c158980bbd9bcea92c17522d")
49
- end
50
- end
51
-
52
- describe ".remove_trigger" do
53
- before do
54
- stub_delete("/projects/3/triggers/7b9148c158980bbd9bcea92c17522d", "trigger")
55
- @trigger = Gitlab.remove_trigger(3, "7b9148c158980bbd9bcea92c17522d")
56
- end
57
-
58
- it "should get the correct resource" do
59
- expect(a_delete("/projects/3/triggers/7b9148c158980bbd9bcea92c17522d")).to have_been_made
60
- end
61
-
62
- it "should return information about a deleted trigger" do
63
- expect(@trigger.created_at).to eq("2015-12-23T16:25:56.760Z")
64
- expect(@trigger.token).to eq("7b9148c158980bbd9bcea92c17522d")
65
- end
66
- end
67
- end