2022-07-10 13:39:35 +03:00
|
|
|
import kotlin.io.path.readText
|
|
|
|
|
2022-07-10 11:46:20 +03:00
|
|
|
job("Build") {
|
|
|
|
gradlew("openjdk:11", "build")
|
|
|
|
}
|
|
|
|
|
|
|
|
job("Publish"){
|
|
|
|
startOn {
|
|
|
|
gitPush { enabled = false }
|
|
|
|
}
|
2022-07-10 12:01:20 +03:00
|
|
|
container("openjdk:11") {
|
2022-07-10 12:42:14 +03:00
|
|
|
env["SPACE_USER"] = Secrets("space_user")
|
|
|
|
env["SPACE_TOKEN"] = Secrets("space_token")
|
2022-07-10 12:01:20 +03:00
|
|
|
kotlinScript { api ->
|
2022-07-10 13:39:35 +03:00
|
|
|
|
2022-07-10 12:42:14 +03:00
|
|
|
val spaceUser = System.getenv("SPACE_USER")
|
|
|
|
val spaceToken = System.getenv("SPACE_TOKEN")
|
|
|
|
|
2022-07-10 13:39:35 +03:00
|
|
|
// write version to the build directory
|
|
|
|
api.gradlew("version")
|
|
|
|
|
|
|
|
//read version from build file
|
|
|
|
val version = java.nio.file.Path.of("build/project-version.txt").readText()
|
|
|
|
|
2022-07-10 12:01:20 +03:00
|
|
|
api.space().projects.automation.deployments.start(
|
|
|
|
project = api.projectIdentifier(),
|
|
|
|
targetIdentifier = TargetIdentifier.Key("gradle-tools"),
|
2022-07-10 13:39:35 +03:00
|
|
|
version = version,
|
2022-07-10 12:01:20 +03:00
|
|
|
// automatically update deployment status based on a status of a job
|
|
|
|
syncWithAutomationJob = true
|
|
|
|
)
|
2022-07-10 12:58:51 +03:00
|
|
|
try {
|
|
|
|
api.gradlew(
|
|
|
|
"publishAllPublicationsToSpaceRepository",
|
|
|
|
"-Ppublishing.space.user=\"$spaceUser\"",
|
|
|
|
"-Ppublishing.space.token=\"$spaceToken\"",
|
|
|
|
)
|
|
|
|
} catch (ex: Exception) {
|
|
|
|
println("Publish failed")
|
|
|
|
}
|
2022-07-10 12:01:20 +03:00
|
|
|
}
|
|
|
|
}
|
2022-07-10 11:46:20 +03:00
|
|
|
}
|