Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion src/main/java/org/kohsuke/github/GHWorkflowRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,41 @@ public PagedIterable<GHWorkflowJob> listJobs() {
* the io exception
*/
public void rerun() throws IOException {
root().createRequest().method("POST").withUrlPath(getApiRoute(), "rerun").send();
rerun(false);
}

/**
* Rerun the workflow run.
*
* @param enableDebugLogging
* whether to enable debug logging for the rerun
* @throws IOException
* the io exception
*/
public void rerun(boolean enableDebugLogging) throws IOException {
rerun("rerun", enableDebugLogging);
}

/**
* Rerun failed jobs and their dependent jobs for this workflow run.
*
* @throws IOException
* the io exception
*/
public void rerunFailedJobs() throws IOException {
rerunFailedJobs(false);
}

/**
* Rerun failed jobs and their dependent jobs for this workflow run.
*
* @param enableDebugLogging
* whether to enable debug logging for the rerun
* @throws IOException
* the io exception
*/
public void rerunFailedJobs(boolean enableDebugLogging) throws IOException {
rerun("rerun-failed-jobs", enableDebugLogging);
}

private String getApiRoute() {
Expand All @@ -611,6 +645,14 @@ private String getApiRoute() {
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/actions/runs/" + getId();
}

private void rerun(String endpoint, boolean enableDebugLogging) throws IOException {
Requester requester = root().createRequest().method("POST").withUrlPath(getApiRoute(), endpoint);
if (enableDebugLogging) {
requester.with("enable_debug_logging", true);
}
requester.send();
}

/**
* Wrap up.
*
Expand Down
18 changes: 18 additions & 0 deletions src/test/java/org/kohsuke/github/GHWorkflowRunTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,24 @@ public void testManualRunAndBasicInformation() throws IOException {
assertThat(workflowRun.getTriggeringActor(), hasProperty("login", equalTo("octocat_trigger")));
}

/**
* Test rerun variants.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@Test
public void testRerunVariants() throws IOException {
GHWorkflowRun workflowRun = repo.getWorkflowRun(686036126L);

assertThat(workflowRun.getId(), is(686036126L));

workflowRun.rerunFailedJobs();
workflowRun.rerunFailedJobs(true);
workflowRun.rerun(true);
workflowRun.rerun();
}

/**
* Test search on branch.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"login": "ayagmar"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"id": 348674220,
"name": "GHWorkflowRunTest",
"full_name": "hub4j-test-org/GHWorkflowRunTest",
"url": "https://api.github.com/repos/hub4j-test-org/GHWorkflowRunTest",
"owner": {
"login": "hub4j-test-org"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": 686036126,
"name": "Slow workflow",
"url": "https://api.github.com/repos/hub4j-test-org/GHWorkflowRunTest/actions/runs/686036126",
"html_url": "https://github.com/hub4j-test-org/GHWorkflowRunTest/actions/runs/686036126",
"status": "completed",
"conclusion": "failure",
"workflow_id": 6820849,
"run_attempt": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"id": "3e7dbf87-7930-4d75-aa8d-d65b76de98dc",
"name": "user",
"request": {
"url": "/user",
"method": "GET",
"headers": {
"Accept": {
"equalTo": "application/vnd.github+json"
}
}
},
"response": {
"status": 200,
"bodyFileName": "1-user.json",
"headers": {
"Content-Type": "application/json; charset=utf-8"
}
},
"uuid": "3e7dbf87-7930-4d75-aa8d-d65b76de98dc",
"persistent": true,
"insertionIndex": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"id": "fd7591c0-77eb-4e52-9b4b-0dc73777a5a0",
"name": "repos_hub4j-test-org_ghworkflowruntest",
"request": {
"url": "/repos/hub4j-test-org/GHWorkflowRunTest",
"method": "GET",
"headers": {
"Accept": {
"equalTo": "application/vnd.github+json"
}
}
},
"response": {
"status": 200,
"bodyFileName": "2-r_h_ghworkflowruntest.json",
"headers": {
"Content-Type": "application/json; charset=utf-8"
}
},
"uuid": "fd7591c0-77eb-4e52-9b4b-0dc73777a5a0",
"persistent": true,
"insertionIndex": 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"id": "77e5d70a-1cf7-44bf-b170-c458d7060d65",
"name": "repos_hub4j-test-org_ghworkflowruntest_actions_runs_686036126",
"request": {
"url": "/repos/hub4j-test-org/GHWorkflowRunTest/actions/runs/686036126",
"method": "GET",
"headers": {
"Accept": {
"equalTo": "application/vnd.github+json"
}
}
},
"response": {
"status": 200,
"bodyFileName": "3-r_h_g_actions_runs_686036126.json",
"headers": {
"Content-Type": "application/json; charset=utf-8"
}
},
"uuid": "77e5d70a-1cf7-44bf-b170-c458d7060d65",
"persistent": true,
"insertionIndex": 3
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"id": "16330f88-a67e-41e6-b636-58db8d3e8f0c",
"name": "repos_hub4j-test-org_ghworkflowruntest_actions_runs_686036126_rerun_failed_jobs",
"request": {
"url": "/repos/hub4j-test-org/GHWorkflowRunTest/actions/runs/686036126/rerun-failed-jobs",
"method": "POST",
"headers": {
"Accept": {
"equalTo": "application/vnd.github+json"
}
},
"bodyPatterns": [
{
"equalToJson": "{}",
"ignoreArrayOrder": true,
"ignoreExtraElements": false
}
]
},
"response": {
"status": 201,
"body": "{}",
"headers": {
"Content-Type": "application/json; charset=utf-8"
}
},
"uuid": "16330f88-a67e-41e6-b636-58db8d3e8f0c",
"persistent": true,
"insertionIndex": 4
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"id": "8b165443-a354-489f-8fee-73801637dbfd",
"name": "repos_hub4j-test-org_ghworkflowruntest_actions_runs_686036126_rerun_failed_jobs_debug",
"request": {
"url": "/repos/hub4j-test-org/GHWorkflowRunTest/actions/runs/686036126/rerun-failed-jobs",
"method": "POST",
"headers": {
"Accept": {
"equalTo": "application/vnd.github+json"
}
},
"bodyPatterns": [
{
"equalToJson": "{\"enable_debug_logging\":true}",
"ignoreArrayOrder": true,
"ignoreExtraElements": false
}
]
},
"response": {
"status": 201,
"body": "{}",
"headers": {
"Content-Type": "application/json; charset=utf-8"
}
},
"uuid": "8b165443-a354-489f-8fee-73801637dbfd",
"persistent": true,
"insertionIndex": 5
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"id": "d5f0000f-e754-447c-84fd-804df2dbed78",
"name": "repos_hub4j-test-org_ghworkflowruntest_actions_runs_686036126_rerun_debug",
"request": {
"url": "/repos/hub4j-test-org/GHWorkflowRunTest/actions/runs/686036126/rerun",
"method": "POST",
"headers": {
"Accept": {
"equalTo": "application/vnd.github+json"
}
},
"bodyPatterns": [
{
"equalToJson": "{\"enable_debug_logging\":true}",
"ignoreArrayOrder": true,
"ignoreExtraElements": false
}
]
},
"response": {
"status": 201,
"body": "{}",
"headers": {
"Content-Type": "application/json; charset=utf-8"
}
},
"uuid": "d5f0000f-e754-447c-84fd-804df2dbed78",
"persistent": true,
"insertionIndex": 6
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"id": "4d1bb285-92fe-49d8-a4bf-72a08ca8a7d6",
"name": "repos_hub4j-test-org_ghworkflowruntest_actions_runs_686036126_rerun",
"request": {
"url": "/repos/hub4j-test-org/GHWorkflowRunTest/actions/runs/686036126/rerun",
"method": "POST",
"headers": {
"Accept": {
"equalTo": "application/vnd.github+json"
}
},
"bodyPatterns": [
{
"equalToJson": "{}",
"ignoreArrayOrder": true,
"ignoreExtraElements": false
}
]
},
"response": {
"status": 201,
"body": "{}",
"headers": {
"Content-Type": "application/json; charset=utf-8"
}
},
"uuid": "4d1bb285-92fe-49d8-a4bf-72a08ca8a7d6",
"persistent": true,
"insertionIndex": 7
}
Loading