Skip to content

Commit

Permalink
fix(jenkins): Enable properties and artifacts with job name as query …
Browse files Browse the repository at this point in the history
…parameter (#4661) (#4677)

* fix(jenkins): Enable properties and artifacts with job name as query parameter

* fix(jenkins): Enable properties and artifacts with job name as query parameter

---------

Co-authored-by: Jason <[email protected]>
(cherry picked from commit fa91381)

Co-authored-by: Christos Arvanitis <[email protected]>
Co-authored-by: Jason <[email protected]>
  • Loading branch information
3 people authored Mar 14, 2024
1 parent e02d155 commit ff02bea
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,16 @@ public Map<String, Object> getBuild(Integer buildNumber, String master, String j

public Map<String, Object> getPropertyFile(
Integer buildNumber, String fileName, String master, String job) {
return igorService.getPropertyFile(buildNumber, fileName, master, encode(job));
return this.igorFeatureFlagProperties.isJobNameAsQueryParameter()
? igorService.getPropertyFileWithJobAsQueryParam(buildNumber, fileName, master, encode(job))
: igorService.getPropertyFile(buildNumber, fileName, master, encode(job));
}

public List<Artifact> getArtifacts(
Integer buildNumber, String fileName, String master, String job) {
return igorService.getArtifacts(buildNumber, fileName, master, encode(job));
return this.igorFeatureFlagProperties.isJobNameAsQueryParameter()
? igorService.getArtifactsWithJobAsQueryParam(buildNumber, fileName, master, encode(job))
: igorService.getArtifacts(buildNumber, fileName, master, encode(job));
}

public Response updateBuild(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ Map<String, Object> getPropertyFile(
@Path("master") String master,
@Path(encode = false, value = "job") String job);

@GET("/builds/properties/{buildNumber}/{fileName}/{master}")
Map<String, Object> getPropertyFileWithJobAsQueryParam(
@Path("buildNumber") Integer buildNumber,
@Path("fileName") String fileName,
@Path("master") String master,
@Query(value = "job") String job);

@GET("/{repoType}/{projectKey}/{repositorySlug}/compareCommits")
List compareCommits(
@Path("repoType") String repoType,
Expand All @@ -93,6 +100,13 @@ List<Artifact> getArtifacts(
@Path("master") String master,
@Path(value = "job", encode = false) String job);

@GET("/builds/artifacts/{buildNumber}/{master}")
List<Artifact> getArtifactsWithJobAsQueryParam(
@Path("buildNumber") Integer buildNumber,
@Query("propertyFile") String propertyFile,
@Path("master") String master,
@Query(value = "job") String job);

@POST("/gcb/builds/create/{account}")
GoogleCloudBuild createGoogleCloudBuild(
@Path("account") String account, @Body Map<String, Object> job);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ class BuildServiceSpec extends Specification {
1 * igorService.getPropertyFile(BUILD_NUMBER, FILENAME, MASTER, JOB_NAME_ENCODED)
}

void 'getPropertyFile method with job in query when flag is true'() {
IgorFeatureFlagProperties igorFeatureFlagProperties = new IgorFeatureFlagProperties()
igorFeatureFlagProperties.setJobNameAsQueryParameter(true)
buildService = new BuildService(igorService, igorFeatureFlagProperties)

when:
buildService.getPropertyFile(BUILD_NUMBER, FILENAME, MASTER, JOB_NAME)

then:
1 * igorService.getPropertyFileWithJobAsQueryParam(BUILD_NUMBER, FILENAME, MASTER, JOB_NAME_ENCODED)
}

void 'stop method sends job name in path when flag is false'() {
IgorFeatureFlagProperties igorFeatureFlagProperties = new IgorFeatureFlagProperties()
igorFeatureFlagProperties.setJobNameAsQueryParameter(false)
Expand Down

0 comments on commit ff02bea

Please sign in to comment.