Skip to content

Commit

Permalink
Merge branch 'master' into pathmatch
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Feb 27, 2024
2 parents 401bbf7 + 15e27fd commit e3ec0f3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fiatVersion=1.43.0
korkVersion=7.214.0
korkVersion=7.217.0
org.gradle.parallel=true
spinnakerGradleVersion=8.32.1
targetJava11=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,20 @@ class BuildController {
return Collections.emptyList()
}


@RequestMapping(value = '/builds/artifacts/{buildNumber}/{master}')
@PreAuthorize("hasPermission(#master, 'BUILD_SERVICE', 'READ')")
List<Artifact> getBuildResults(@PathVariable String master, @PathVariable
Integer buildNumber, @RequestParam("job") String job ,@Query("propertyFile") String propertyFile) {
def buildService = getBuildService(master)
GenericBuild build = jobStatus(buildService, master, job, buildNumber)
if (build && buildService instanceof BuildProperties && artifactExtractor != null) {
build.properties = buildService.getBuildProperties(job, build, propertyFile)
return artifactExtractor.extractArtifacts(build)
}
return Collections.emptyList()
}

@RequestMapping(value = '/builds/queue/{master}/{item}')
@PreAuthorize("hasPermission(#master, 'BUILD_SERVICE', 'READ')")
Object getQueueLocation(@PathVariable String master, @PathVariable int item) {
Expand Down Expand Up @@ -335,6 +349,22 @@ class BuildController {
return Collections.emptyMap()
}


@RequestMapping(value = '/builds/properties/{buildNumber}/{fileName}/{master}')
@PreAuthorize("hasPermission(#master, 'BUILD_SERVICE', 'READ')")
Map<String, Object> getProperties(
@PathVariable String master,
@PathVariable Integer buildNumber, @PathVariable
String fileName, @RequestParam("job") String job) {
def buildService = getBuildService(master)
if (buildService instanceof BuildProperties) {
BuildProperties buildProperties = (BuildProperties) buildService
def genericBuild = buildService.getGenericBuild(job, buildNumber)
return buildProperties.getBuildProperties(job, genericBuild, fileName)
}
return Collections.emptyMap()
}

private BuildOperations getBuildService(String master) {
def buildService = buildServices.getService(master)
if (buildService == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,21 @@ class BuildControllerSpec extends Specification {
.andReturn().response
}

void 'get properties of a build with job Name in query parameters' () {
given:
1 * jenkinsService.getGenericBuild(JOB_NAME, BUILD_NUMBER) >> genericBuild
1 * jenkinsService.getBuildProperties(JOB_NAME, genericBuild, FILE_NAME) >> ['foo': 'bar']

when:
MockHttpServletResponse response = mockMvc.perform(
get("/builds/properties/${BUILD_NUMBER}/${FILE_NAME}/${JENKINS_SERVICE}")
.param("job", JOB_NAME)
.accept(MediaType.APPLICATION_JSON)).andReturn().response

then:
response.contentAsString == "{\"foo\":\"bar\"}"
}

void 'get properties of a travis build'() {
given:
1 * travisService.getGenericBuild(JOB_NAME, BUILD_NUMBER) >> genericBuild
Expand Down

0 comments on commit e3ec0f3

Please sign in to comment.