Skip to content

Commit

Permalink
fix(jenkins): Pass stage start time to Igor when kicking off a build (s…
Browse files Browse the repository at this point in the history
…pinnaker#4045)

* fix(jenkins): Pass stage start time to Igor when kicking off a build

* fix(test): Fix up StartJenkinsJobTaskSpec
  • Loading branch information
jonsie authored Jan 25, 2021
1 parent 13f0358 commit 005617b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public Response build(String master, String jobName, Map<String, String> queryPa
return igorService.build(master, encode(jobName), queryParams, "");
}

public Response build(
String master, String jobName, Map<String, String> queryParams, String startTime) {
return igorService.build(master, encode(jobName), queryParams, startTime);
}

public String stop(String master, String jobName, String queuedBuild, Integer buildNumber) {
return igorService.stop(master, jobName, queuedBuild, buildNumber, "");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Response build(
@Path("name") String master,
@Path(encode = false, value = "jobName") String jobName,
@QueryMap Map<String, String> queryParams,
@Body String ignored);
@Body String startTime);

@PUT("/masters/{name}/jobs/{jobName}/stop/{queuedBuild}/{buildNumber}")
String stop(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class StartJenkinsJobTask implements RetryableTask {
String job = stage.context.job

try {
Response igorResponse = buildService.build(master, job, stage.context.parameters)
Response igorResponse = buildService.build(master, job, stage.context.parameters, stage.startTime.toString())

if (igorResponse.getStatus() == HttpStatus.ACCEPTED.value()) {
log.info("build for job=$job on master=$master is pending, waiting for build to start")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class StartJenkinsJobTaskSpec extends Specification {

and:
task.buildService = Stub(BuildService) {
build(stage.context.master, stage.context.job, stage.context.parameters) >>
build(stage.context.master, stage.context.job, stage.context.parameters, stage.startTime.toString()) >>
new Response("", 200, "OK", [], new TypedString(new ObjectMapper().writeValueAsString([result: 'SUCCESS', running: true, number: 4])))
}

Expand All @@ -68,7 +68,7 @@ class StartJenkinsJobTaskSpec extends Specification {

and:
task.buildService = Stub(BuildService) {
build(stage.context.master, stage.context.job, stage.context.parameters) >>
build(stage.context.master, stage.context.job, stage.context.parameters, stage.startTime.toString()) >>
new Response("", 200, "OK", [], new TypedString(new ObjectMapper().writeValueAsString([result: 'SUCCESS', running: true, number: 4])))
}

Expand All @@ -85,7 +85,7 @@ class StartJenkinsJobTaskSpec extends Specification {

and:
task.buildService = Stub(BuildService) {
build(stage.context.master, stage.context.job, stage.context.parameters) >> {throw RetrofitError.unexpectedError("http://test", new RuntimeException())}
build(stage.context.master, stage.context.job, stage.context.parameters, stage.startTime.toString()) >> {throw RetrofitError.unexpectedError("http://test", new RuntimeException())}
}

when:
Expand All @@ -101,7 +101,7 @@ class StartJenkinsJobTaskSpec extends Specification {

and:
task.buildService = Stub(BuildService) {
build(stage.context.master, stage.context.job, stage.context.parameters) >>
build(stage.context.master, stage.context.job, stage.context.parameters, stage.startTime.toString()) >>
new Response("", 202, "OK", [], null)
}

Expand Down

0 comments on commit 005617b

Please sign in to comment.