Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
go-gitlab
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
go-gitlab
Commits
0d37fe7f
Commit
0d37fe7f
authored
Feb 14, 2018
by
Lorac
Committed by
Sander van Harmelen
Feb 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ListProjectPipelinesOptions (#327)
parent
b3ebd74a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
4 deletions
+59
-4
commits.go
commits.go
+1
-0
pipelines.go
examples/pipelines.go
+12
-1
gitlab.go
gitlab.go
+16
-0
pipelines.go
pipelines.go
+28
-2
pipelines_test.go
pipelines_test.go
+2
-1
No files found.
commits.go
View file @
0d37fe7f
...
...
@@ -386,6 +386,7 @@ const (
Success
BuildState
=
"success"
Failed
BuildState
=
"failed"
Canceled
BuildState
=
"canceled"
Skipped
BuildState
=
"skipped"
)
// SetCommitStatus sets the status of a commit in a project.
...
...
examples/pipelines.go
View file @
0d37fe7f
...
...
@@ -10,7 +10,18 @@ func pipelineExample() {
git
:=
gitlab
.
NewClient
(
nil
,
"yourtokengoeshere"
)
git
.
SetBaseURL
(
"https://gitlab.com/api/v4"
)
pipelines
,
_
,
err
:=
git
.
Pipelines
.
ListProjectPipelines
(
2743054
)
opt
:=
&
gitlab
.
ListProjectPipelinesOptions
{
Scope
:
gitlab
.
String
(
"branches"
),
Status
:
gitlab
.
Build
(
gitlab
.
Running
),
Ref
:
gitlab
.
String
(
"master"
),
YamlErrors
:
gitlab
.
Bool
(
true
),
Name
:
gitlab
.
String
(
"name"
),
Username
:
gitlab
.
String
(
"username"
),
OrderBy
:
gitlab
.
Order
(
gitlab
.
OrderByStatus
),
Sort
:
gitlab
.
String
(
"asc"
),
}
pipelines
,
_
,
err
:=
git
.
Pipelines
.
ListProjectPipelines
(
2743054
,
opt
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
...
...
gitlab.go
View file @
0d37fe7f
...
...
@@ -713,3 +713,19 @@ func Visibility(v VisibilityValue) *VisibilityValue {
*
p
=
v
return
p
}
// Order is a helper routine that allocates a new OrderBy
// to store v and returns a pointer to it.
func
Order
(
v
OrderBy
)
*
OrderBy
{
p
:=
new
(
OrderBy
)
*
p
=
v
return
p
}
// Build is a helper routine that allocates a new BuildState
// to store v and returns a pointer to it.
func
Build
(
v
BuildState
)
*
BuildState
{
p
:=
new
(
BuildState
)
*
p
=
v
return
p
}
pipelines.go
View file @
0d37fe7f
...
...
@@ -76,17 +76,43 @@ func (i PipelineList) String() string {
return
Stringify
(
i
)
}
// OrderBy represent in which order to sort the item
type
OrderBy
string
// These constants represent all valid order by values.
const
(
OrderByID
OrderBy
=
"id"
OrderByStatus
OrderBy
=
"status"
OrderByRef
OrderBy
=
"ref"
OrderByUserID
OrderBy
=
"user_id"
)
// ListProjectPipelinesOptions represents the available ListProjectPipelines() options.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/pipelines.html#list-project-pipelines
type
ListProjectPipelinesOptions
struct
{
ListOptions
Scope
*
string
`url:"scope,omitempty" json:"scope,omitempty"`
Status
*
BuildState
`url:"status,omitempty" json:"status,omitempty"`
Ref
*
string
`url:"ref,omitempty" json:"ref,omitempty"`
YamlErrors
*
bool
`url:"yaml_errors,omitempty" json:"yaml_errors,omitempty"`
Name
*
string
`url:"name,omitempty" json:"name,omitempty"`
Username
*
string
`url:"username,omitempty" json:"username,omitempty"`
OrderBy
*
OrderBy
`url:"order_by,omitempty" json:"order_by,omitempty"`
Sort
*
string
`url:"sort,omitempty" json:"sort,omitempty"`
}
// ListProjectPipelines gets a list of project piplines.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/pipelines.html#list-project-pipelines
func
(
s
*
PipelinesService
)
ListProjectPipelines
(
pid
interface
{},
options
...
OptionFunc
)
(
PipelineList
,
*
Response
,
error
)
{
func
(
s
*
PipelinesService
)
ListProjectPipelines
(
pid
interface
{},
opt
*
ListProjectPipelinesOptions
,
opt
ions
...
OptionFunc
)
(
PipelineList
,
*
Response
,
error
)
{
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"projects/%s/pipelines"
,
url
.
QueryEscape
(
project
))
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
nil
,
options
)
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
opt
,
options
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
...
...
pipelines_test.go
View file @
0d37fe7f
...
...
@@ -16,7 +16,8 @@ func TestListProjectPipelines(t *testing.T) {
fmt
.
Fprint
(
w
,
`[{"id":1},{"id":2}]`
)
})
piplines
,
_
,
err
:=
client
.
Pipelines
.
ListProjectPipelines
(
1
)
opt
:=
&
ListProjectPipelinesOptions
{
Ref
:
String
(
"master"
)}
piplines
,
_
,
err
:=
client
.
Pipelines
.
ListProjectPipelines
(
1
,
opt
)
if
err
!=
nil
{
t
.
Errorf
(
"Pipelines.ListProjectPipelines returned error: %v"
,
err
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment