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
73f200a8
Unverified
Commit
73f200a8
authored
Feb 05, 2023
by
Thomas
Committed by
GitHub
Feb 05, 2023
Browse files
Extend "playJob" to support "job_variables_attributes" (#836)
parent
358b8c9a
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/JobApi.java
View file @
73f200a8
...
@@ -9,15 +9,14 @@ import java.nio.file.StandardCopyOption;
...
@@ -9,15 +9,14 @@ import java.nio.file.StandardCopyOption;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Optional
;
import
java.util.stream.Stream
;
import
java.util.stream.Stream
;
import
javax.ws.rs.core.Form
;
import
javax.ws.rs.core.Form
;
import
javax.ws.rs.core.GenericType
;
import
javax.ws.rs.core.GenericType
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response.Status
;
import
javax.ws.rs.core.Response.Status
;
import
org.gitlab4j.api.models.ArtifactsFile
;
import
org.gitlab4j.api.models.ArtifactsFile
;
import
org.gitlab4j.api.models.Job
;
import
org.gitlab4j.api.models.Job
;
import
org.gitlab4j.api.models.JobAttributes
;
/**
/**
* This class provides an entry point to all the GitLab API job calls.
* This class provides an entry point to all the GitLab API job calls.
...
@@ -532,9 +531,35 @@ public class JobApi extends AbstractApi implements Constants {
...
@@ -532,9 +531,35 @@ public class JobApi extends AbstractApi implements Constants {
* @throws GitLabApiException if any exception occurs during execution
* @throws GitLabApiException if any exception occurs during execution
*/
*/
public
Job
playJob
(
Object
projectIdOrPath
,
Long
jobId
)
throws
GitLabApiException
{
public
Job
playJob
(
Object
projectIdOrPath
,
Long
jobId
)
throws
GitLabApiException
{
return
playJob
(
projectIdOrPath
,
jobId
,
null
);
}
/**
* Play specified job with parameters in a project.
*
* <pre>
* <code>GitLab Endpoint: POST /projects/:id/jobs/:job_id/play</code>
* </pre>
*
* @param projectIdOrPath id, path of the project, or a Project instance holding the project ID
* or path
* @param jobId the ID to play job
* @param jobAttributes attributes for the played job
* @return job instance which just played
* @throws GitLabApiException if any exception occurs during execution
*/
public
Job
playJob
(
Object
projectIdOrPath
,
Long
jobId
,
JobAttributes
jobAttributes
)
throws
GitLabApiException
{
Response
response
;
if
(
jobAttributes
==
null
)
{
GitLabApiForm
formData
=
null
;
GitLabApiForm
formData
=
null
;
Response
response
=
post
(
Status
.
CREATED
,
formData
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"jobs"
,
jobId
,
"play"
);
response
=
post
(
Status
.
CREATED
,
formData
,
"projects"
,
return
(
response
.
readEntity
(
Job
.
class
));
getProjectIdOrPath
(
projectIdOrPath
),
"jobs"
,
jobId
,
"play"
);
}
else
{
response
=
post
(
Status
.
CREATED
,
jobAttributes
,
"projects"
,
getProjectIdOrPath
(
projectIdOrPath
),
"jobs"
,
jobId
,
"play"
);
}
return
(
response
.
readEntity
(
Job
.
class
));
}
}
/**
/**
...
...
src/main/java/org/gitlab4j/api/models/JobAttribute.java
0 → 100644
View file @
73f200a8
package
org.gitlab4j.api.models
;
import
org.gitlab4j.api.utils.JacksonJson
;
public
class
JobAttribute
{
private
String
key
;
private
String
value
;
public
JobAttribute
(
String
key
,
String
value
)
{
this
.
key
=
key
;
this
.
value
=
value
;
}
public
String
getKey
()
{
return
key
;
}
public
void
setKey
(
String
key
)
{
this
.
key
=
key
;
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
@Override
public
String
toString
()
{
return
(
JacksonJson
.
toJsonString
(
this
));
}
}
src/main/java/org/gitlab4j/api/models/JobAttributes.java
0 → 100644
View file @
73f200a8
package
org.gitlab4j.api.models
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
java.util.List
;
import
org.gitlab4j.api.utils.JacksonJson
;
public
class
JobAttributes
{
@JsonProperty
(
"job_variables_attributes"
)
private
List
<
JobAttribute
>
jobAttributes
;
public
JobAttributes
(
List
<
JobAttribute
>
jobAttributes
)
{
this
.
jobAttributes
=
jobAttributes
;
}
public
List
<
JobAttribute
>
getJobAttributes
()
{
return
jobAttributes
;
}
public
void
setJobAttributes
(
List
<
JobAttribute
>
jobAttributes
)
{
this
.
jobAttributes
=
jobAttributes
;
}
@Override
public
String
toString
()
{
return
(
JacksonJson
.
toJsonString
(
this
));
}
}
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