Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
4829c204
Commit
4829c204
authored
Dec 11, 2023
by
Jeremie Bresson
Browse files
Merge remote-tracking branch 'origin/main' into 6.x
parents
4398dfed
6d5edeb9
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/PipelineApi.java
View file @
4829c204
...
...
@@ -9,6 +9,7 @@ import jakarta.ws.rs.core.Form;
import
jakarta.ws.rs.core.GenericType
;
import
jakarta.ws.rs.core.Response
;
import
org.gitlab4j.api.models.Bridge
;
import
org.gitlab4j.api.models.Pipeline
;
import
org.gitlab4j.api.models.PipelineFilter
;
import
org.gitlab4j.api.models.PipelineSchedule
;
...
...
@@ -856,4 +857,34 @@ public class PipelineApi extends AbstractApi implements Constants {
public
Stream
<
Variable
>
getPipelineVariablesStream
(
Object
projectIdOrPath
,
Long
pipelineId
)
throws
GitLabApiException
{
return
(
getPipelineVariables
(
projectIdOrPath
,
pipelineId
,
getDefaultPerPage
()).
stream
());
}
/**
* Get a Pager of bridges in a pipeline.
*
* <pre><code>GitLab Endpoint: GET /projects/:id/pipelines/:pipeline_id/bridges </code></pre>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the pipelines for
* @param pipelineId the pipeline ID to get the list of bridges for
* @param itemsPerPage the number of Bridge instances that will be fetched per page
* @return a list containing the bridges for the specified project ID and pipeline ID
* @throws GitLabApiException if any exception occurs during execution
*/
public
Pager
<
Bridge
>
getBridgesForPipeline
(
Object
projectIdOrPath
,
long
pipelineId
,
int
itemsPerPage
,
JobScope
scope
)
throws
GitLabApiException
{
return
(
new
Pager
<>(
this
,
Bridge
.
class
,
itemsPerPage
,
getDefaultPerPageParam
(),
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"pipelines"
,
pipelineId
,
"bridges"
,
scope
));
}
/**
* Get a Stream of bridges in a pipeline.
* <pre><code>GitLab Endpoint: GET /projects/:id/pipelines/:pipeline_id/bridges</code></pre>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path
* @param pipelineId the pipeline ID to get the list of bridges for
* @return a Stream containing the bridges for the specified project ID
* @throws GitLabApiException if any exception occurs during execution
*/
public
Stream
<
Bridge
>
getBridgesStream
(
Object
projectIdOrPath
,
long
pipelineId
,
JobScope
scope
)
throws
GitLabApiException
{
return
(
getBridgesForPipeline
(
projectIdOrPath
,
pipelineId
,
getDefaultPerPage
(),
scope
).
stream
());
}
}
src/main/java/org/gitlab4j/api/models/Bridge.java
0 → 100644
View file @
4829c204
package
org.gitlab4j.api.models
;
import
org.gitlab4j.api.utils.JacksonJson
;
import
java.util.Date
;
public
class
Bridge
{
private
Commit
commit
;
private
boolean
allowFailure
;
private
Date
createdAt
;
private
Date
startedAt
;
private
Date
finishedAt
;
private
Date
erasedAt
;
private
Double
duration
;
private
Double
queuedDuration
;
private
int
id
;
private
String
name
;
private
String
coverage
;
private
Pipeline
pipeline
;
private
String
ref
;
private
String
stage
;
private
String
status
;
private
boolean
tag
;
private
String
webUrl
;
private
User
user
;
private
DownstreamPipeline
downstreamPipeline
;
public
Commit
getCommit
()
{
return
commit
;
}
public
void
setCommit
(
Commit
commit
)
{
this
.
commit
=
commit
;
}
public
boolean
isAllowFailure
()
{
return
allowFailure
;
}
public
void
setAllowFailure
(
boolean
allowFailure
)
{
this
.
allowFailure
=
allowFailure
;
}
public
Date
getCreatedAt
()
{
return
createdAt
;
}
public
void
setCreatedAt
(
Date
createdAt
)
{
this
.
createdAt
=
createdAt
;
}
public
Date
getStartedAt
()
{
return
startedAt
;
}
public
void
setStartedAt
(
Date
startedAt
)
{
this
.
startedAt
=
startedAt
;
}
public
Date
getFinishedAt
()
{
return
finishedAt
;
}
public
void
setFinishedAt
(
Date
finishedAt
)
{
this
.
finishedAt
=
finishedAt
;
}
public
Date
getErasedAt
()
{
return
erasedAt
;
}
public
void
setErasedAt
(
Date
erasedAt
)
{
this
.
erasedAt
=
erasedAt
;
}
public
Double
getDuration
()
{
return
duration
;
}
public
void
setDuration
(
Double
duration
)
{
this
.
duration
=
duration
;
}
public
Double
getQueuedDuration
()
{
return
queuedDuration
;
}
public
void
setQueuedDuration
(
Double
queuedDuration
)
{
this
.
queuedDuration
=
queuedDuration
;
}
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getCoverage
()
{
return
coverage
;
}
public
void
setCoverage
(
String
coverage
)
{
this
.
coverage
=
coverage
;
}
public
Pipeline
getPipeline
()
{
return
pipeline
;
}
public
void
setPipeline
(
Pipeline
pipeline
)
{
this
.
pipeline
=
pipeline
;
}
public
String
getRef
()
{
return
ref
;
}
public
void
setRef
(
String
ref
)
{
this
.
ref
=
ref
;
}
public
String
getStage
()
{
return
stage
;
}
public
void
setStage
(
String
stage
)
{
this
.
stage
=
stage
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
boolean
isTag
()
{
return
tag
;
}
public
void
setTag
(
boolean
tag
)
{
this
.
tag
=
tag
;
}
public
String
getWebUrl
()
{
return
webUrl
;
}
public
void
setWebUrl
(
String
webUrl
)
{
this
.
webUrl
=
webUrl
;
}
public
User
getUser
()
{
return
user
;
}
public
void
setUser
(
User
user
)
{
this
.
user
=
user
;
}
public
DownstreamPipeline
getDownstreamPipeline
()
{
return
downstreamPipeline
;
}
public
void
setDownstreamPipeline
(
DownstreamPipeline
downstreamPipeline
)
{
this
.
downstreamPipeline
=
downstreamPipeline
;
}
@Override
public
String
toString
()
{
return
(
JacksonJson
.
toJsonString
(
this
));
}
}
src/main/java/org/gitlab4j/api/models/DownstreamPipeline.java
0 → 100644
View file @
4829c204
package
org.gitlab4j.api.models
;
import
org.gitlab4j.api.utils.JacksonJson
;
import
java.util.Date
;
public
class
DownstreamPipeline
{
private
int
id
;
private
String
sha
;
private
String
ref
;
private
String
status
;
private
Date
createdAt
;
private
Date
updatedAt
;
private
String
webUrl
;
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
public
String
getSha
()
{
return
sha
;
}
public
void
setSha
(
String
sha
)
{
this
.
sha
=
sha
;
}
public
String
getRef
()
{
return
ref
;
}
public
void
setRef
(
String
ref
)
{
this
.
ref
=
ref
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
Date
getCreatedAt
()
{
return
createdAt
;
}
public
void
setCreatedAt
(
Date
createdAt
)
{
this
.
createdAt
=
createdAt
;
}
public
Date
getUpdatedAt
()
{
return
updatedAt
;
}
public
void
setUpdatedAt
(
Date
updatedAt
)
{
this
.
updatedAt
=
updatedAt
;
}
public
String
getWebUrl
()
{
return
webUrl
;
}
public
void
setWebUrl
(
String
webUrl
)
{
this
.
webUrl
=
webUrl
;
}
@Override
public
String
toString
()
{
return
(
JacksonJson
.
toJsonString
(
this
));
}
}
src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java
View file @
4829c204
...
...
@@ -45,6 +45,7 @@ import org.gitlab4j.api.models.Badge;
import
org.gitlab4j.api.models.Blame
;
import
org.gitlab4j.api.models.Board
;
import
org.gitlab4j.api.models.Branch
;
import
org.gitlab4j.api.models.Bridge
;
import
org.gitlab4j.api.models.ChildEpic
;
import
org.gitlab4j.api.models.GitLabCiTemplate
;
import
org.gitlab4j.api.models.GitLabCiTemplateElement
;
...
...
@@ -499,6 +500,12 @@ public class TestGitLabApiBeans {
assertTrue
(
compareJson
(
job
,
"job.json"
));
}
@Test
public
void
testBridge
()
throws
Exception
{
Bridge
bridge
=
unmarshalResource
(
Bridge
.
class
,
"bridge.json"
);
assertTrue
(
compareJson
(
bridge
,
"bridge.json"
));
}
@Test
public
void
testDeployKeys
()
throws
Exception
{
List
<
DeployKey
>
deployKeys
=
unmarshalResourceList
(
DeployKey
.
class
,
"deploy-keys.json"
);
...
...
src/test/java/org/gitlab4j/api/TestJobApi.java
View file @
4829c204
...
...
@@ -27,7 +27,10 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
import
static
org
.
junit
.
jupiter
.
api
.
Assumptions
.
assumeTrue
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
org.gitlab4j.api.models.Bridge
;
import
org.gitlab4j.api.models.Job
;
import
org.gitlab4j.api.models.Project
;
import
org.junit.jupiter.api.AfterAll
;
...
...
src/test/java/org/gitlab4j/api/TestPipelineApi.java
View file @
4829c204
...
...
@@ -12,8 +12,11 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
import
org.gitlab4j.api.models.Bridge
;
import
org.gitlab4j.api.models.Pipeline
;
import
org.gitlab4j.api.models.PipelineSchedule
;
import
org.gitlab4j.api.models.Project
;
...
...
@@ -21,11 +24,7 @@ import org.gitlab4j.api.models.RepositoryFile;
import
org.gitlab4j.api.models.RepositoryFileResponse
;
import
org.gitlab4j.api.models.Trigger
;
import
org.gitlab4j.api.models.Variable
;
import
org.junit.jupiter.api.AfterAll
;
import
org.junit.jupiter.api.BeforeAll
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Tag
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.*
;
import
org.junit.jupiter.api.extension.ExtendWith
;
@Tag
(
"integration"
)
...
...
@@ -354,4 +353,12 @@ public class TestPipelineApi extends AbstractIntegrationTest {
gitLabApi
.
getPipelineApi
().
deletePipeline
(
testProject
,
pipeline
.
getId
());
}
}
@Test
@Disabled
(
"disable till 'Move the test infrastructure to Testcontainers #925'"
)
public
void
testGetBridges
()
throws
GitLabApiException
{
Set
<
Bridge
>
bridges
=
gitLabApi
.
getPipelineApi
().
getBridgesStream
(
testProject
,
4L
,
Constants
.
JobScope
.
SUCCESS
).
collect
(
Collectors
.
toSet
());
assertNotNull
(
bridges
);
}
}
src/test/resources/org/gitlab4j/api/bridge.json
0 → 100644
View file @
4829c204
{
"commit"
:
{
"author_email"
:
"admin@example.com"
,
"author_name"
:
"Administrator"
,
"created_at"
:
"2015-12-24T15:51:21.802Z"
,
"id"
:
"0ff3ae198f8601a285adcf5c0fff204ee6fba5fd"
,
"message"
:
"Test the CI integration."
,
"short_id"
:
"0ff3ae19"
,
"title"
:
"Test the CI integration."
},
"allow_failure"
:
false
,
"created_at"
:
"2015-12-24T15:51:21.802Z"
,
"started_at"
:
"2015-12-24T17:54:27.722Z"
,
"finished_at"
:
"2015-12-24T17:58:27.895Z"
,
"erased_at"
:
"2015-12-24T17:58:27.895Z"
,
"duration"
:
240.0
,
"queued_duration"
:
0.123
,
"id"
:
7
,
"name"
:
"teaspoon"
,
"pipeline"
:
{
"id"
:
6
,
"ref"
:
"main"
,
"sha"
:
"0ff3ae198f8601a285adcf5c0fff204ee6fba5fd"
,
"status"
:
"pending"
,
"created_at"
:
"2012-09-20T06:06:12Z"
,
"updated_at"
:
"2012-09-20T06:06:12Z"
,
"web_url"
:
"https://example.com/foo/bar/pipelines/6"
},
"ref"
:
"main"
,
"stage"
:
"test"
,
"status"
:
"pending"
,
"tag"
:
false
,
"web_url"
:
"https://example.com/foo/bar/-/jobs/7"
,
"user"
:
{
"id"
:
1
,
"name"
:
"Administrator"
,
"username"
:
"root"
,
"state"
:
"active"
,
"avatar_url"
:
"http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon"
,
"web_url"
:
"http://gitlab.dev/root"
,
"created_at"
:
"2012-09-20T06:06:12Z"
,
"bio"
:
"some bio"
,
"location"
:
"any location"
,
"public_email"
:
""
,
"skype"
:
""
,
"linkedin"
:
""
,
"twitter"
:
""
,
"website_url"
:
""
,
"organization"
:
""
},
"downstream_pipeline"
:
{
"id"
:
5
,
"sha"
:
"f62a4b2fb89754372a346f24659212eb8da13601"
,
"ref"
:
"main"
,
"status"
:
"pending"
,
"created_at"
:
"2012-09-20T06:06:12Z"
,
"updated_at"
:
"2012-09-20T06:06:12Z"
,
"web_url"
:
"https://example.com/diaspora/diaspora-client/pipelines/5"
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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