Skip to content

Commit 2cb1e04

Browse files
committed
Fix bug in parsing of jobs
1 parent fc8889d commit 2cb1e04

File tree

6 files changed

+50
-12
lines changed

6 files changed

+50
-12
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
The format is based on [Keep a Changelog](http://keepachangelog.com/)
33
and this project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## 0.1.1 (02/06/2023)
6+
- Fixed bug in parsing of Jobs.
7+
58
## 0.1.0 (01/29/2023)
69
- Initial Release!

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This client library is released on Maven Central. Add a new dependency to your
1212
<dependency>
1313
<groupId>org.sourcelab</groupId>
1414
<artifactId>buildkite-api-client</artifactId>
15-
<version>0.1.0</version>
15+
<version>0.1.1</version>
1616
</dependency>
1717
```
1818

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>org.sourcelab</groupId>
88
<artifactId>buildkite-api-client</artifactId>
9-
<version>0.1.0</version>
9+
<version>0.1.1</version>
1010
<packaging>jar</packaging>
1111

1212
<!-- Require Maven 3.3.9 -->

src/main/java/org/sourcelab/buildkite/api/client/response/Job.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ public Job(
7777
@JsonProperty("exit_status") final int exitStatus,
7878
@JsonProperty("artifact_paths") final String artifactPaths,
7979
@JsonProperty("agent") final Agent agent,
80-
@JsonProperty("createdAt") final ZonedDateTime createdAt,
81-
@JsonProperty("scheduledAt") final ZonedDateTime scheduledAt,
82-
@JsonProperty("runnableAt") final ZonedDateTime runnableAt,
83-
@JsonProperty("startedAt") final ZonedDateTime startedAt,
84-
@JsonProperty("finishedAt") final ZonedDateTime finishedAt,
80+
@JsonProperty("created_at") final ZonedDateTime createdAt,
81+
@JsonProperty("scheduled_at") final ZonedDateTime scheduledAt,
82+
@JsonProperty("runnable_at") final ZonedDateTime runnableAt,
83+
@JsonProperty("started_at") final ZonedDateTime startedAt,
84+
@JsonProperty("finished_at") final ZonedDateTime finishedAt,
8585
@JsonProperty("retried") final Boolean retried,
86-
@JsonProperty("retriedInJobId") final String retriedInJobId,
87-
@JsonProperty("retriesCount") final Long retriesCount,
88-
@JsonProperty("retryType") final String retryType,
86+
@JsonProperty("retried_in_job_id") final String retriedInJobId,
87+
@JsonProperty("retries_count") final Long retriesCount,
88+
@JsonProperty("retry_type") final String retryType,
8989
@JsonProperty("parallel_group_index") final Integer parallelGroupIndex,
9090
@JsonProperty("parallel_group_total") final Integer parallelGroupTotal
9191
) {

src/test/java/org/sourcelab/buildkite/api/client/BuildkiteClientTest.java

+36-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.sourcelab.buildkite.api.client.response.Build;
3838
import org.sourcelab.buildkite.api.client.response.CurrentUserResponse;
3939
import org.sourcelab.buildkite.api.client.response.Emoji;
40+
import org.sourcelab.buildkite.api.client.response.Job;
4041
import org.sourcelab.buildkite.api.client.response.ListBuildsResponse;
4142
import org.sourcelab.buildkite.api.client.response.ListPipelinesResponse;
4243
import org.sourcelab.buildkite.api.client.response.MetaResponse;
@@ -504,12 +505,46 @@ void getBuild() {
504505
// Spot check
505506
assertEquals("build-id", build.getId());
506507
assertEquals("failed", build.getState());
508+
assertNotNull(build.getCreatedAt());
509+
assertNotNull(build.getScheduledAt());
510+
assertNotNull(build.getStartedAt());
511+
assertNotNull(build.getFinishedAt());
512+
513+
// Creator
507514
assertEquals("creator-id", build.getCreator().getId());
515+
516+
// Pipeline
508517
assertEquals("pipeline-id", build.getPipeline().getId());
509518
assertEquals("Run Tests", build.getPipeline().getName());
519+
520+
// Jobs
510521
assertEquals(4, build.getJobs().size());
511-
assertEquals("Compile & Verify", build.getJobs().get(0).getName());
522+
523+
// Job 0
524+
Job job = build.getJobs().get(0);
525+
assertEquals("Compile & Verify", job.getName());
526+
assertNotNull(job.getCreatedAt());
527+
assertNotNull(job.getScheduledAt());
528+
assertNotNull(job.getFinishedAt());
529+
assertNotNull(job.getStartedAt());
530+
assertEquals(0, job.getExitStatus());
531+
assertFalse(job.isRetried());
532+
assertNull(job.getRetriedInJobId());
533+
assertEquals(0, job.getRetriesCount());
534+
535+
// Job 1
536+
job = build.getJobs().get(1);
512537
assertEquals("Run tests", build.getJobs().get(1).getName());
538+
assertNotNull(job.getCreatedAt());
539+
assertNotNull(job.getScheduledAt());
540+
assertNotNull(job.getFinishedAt());
541+
assertNotNull(job.getStartedAt());
542+
assertEquals(0, job.getExitStatus());
543+
assertFalse(job.isRetried());
544+
assertNull(job.getRetriedInJobId());
545+
assertEquals(4, job.getRetriesCount());
546+
547+
513548
assertEquals(null, build.getJobs().get(2).getName());
514549
assertEquals("Annotate", build.getJobs().get(3).getName());
515550
}

src/test/resources/mockResponses/getBuild.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@
229229
"expired_at": null,
230230
"retried": false,
231231
"retried_in_job_id": null,
232-
"retries_count": null,
232+
"retries_count": 4,
233233
"retry_type": null,
234234
"parallel_group_index": null,
235235
"parallel_group_total": null,

0 commit comments

Comments
 (0)