add revision to query params

master
Josha von Gizycki 5 years ago
parent bd09041826
commit b271bc3b88

@ -7,6 +7,7 @@ import javax.inject.Inject
import javax.ws.rs.*
import javax.ws.rs.core.MediaType
import javax.ws.rs.core.Response
import javax.ws.rs.core.Response.Status.PRECONDITION_REQUIRED
@Path("/builds")
class BuildsEndpoint(
@ -35,19 +36,24 @@ class BuildsEndpoint(
fun trigger(@PathParam("build")
build: String,
@QueryParam("key")
key: String?) =
key: String?,
@QueryParam("rev")
rev: String?) =
security.requireKey(build, key) {
val logFile = builds.createLogFile(build)
startBuildThread(build, logFile, it)
if (rev == null) {
return@requireKey Response.status(PRECONDITION_REQUIRED).build()
}
startBuildThread(build, rev, logFile, it)
Response.ok(mapOf(
"log" to logFile.absolutePath
))
.build()
)).build()
}
fun startBuildThread(build: String, logFile: File, config: BuildConfig) =
fun startBuildThread(build: String, rev: String, logFile: File, config: BuildConfig) =
Thread {
logger.info("preparing process for build $build with config ${config.asPublic()}")
logger.info("log file: $logFile")
@ -59,6 +65,7 @@ class BuildsEndpoint(
.apply {
environment().putAll(config.env)
environment()["ALFRED_LOG_FILE"] = logFile.absolutePath
environment()["ALFRED_GIT_REV"] = rev
}
.start()
.toHandle()

Loading…
Cancel
Save