More parameters for KotlinBuildPusher
This commit is contained in:
committed by
Vasily Levchenko
parent
1723571b3a
commit
caa6ed0d53
@@ -1,47 +1,57 @@
|
||||
package org.jetbrains.kotlin
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.call.HttpClientCall
|
||||
import io.ktor.client.request.get
|
||||
import io.ktor.client.request.header
|
||||
import io.ktor.client.request.post
|
||||
import io.ktor.content.TextContent
|
||||
import io.ktor.http.ContentType
|
||||
import io.ktor.http.contentType
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.api.tasks.options.Option
|
||||
|
||||
|
||||
open class KotlinBuildPusher: DefaultTask() {
|
||||
|
||||
@Suppress("UnstableApiUsage")
|
||||
open class KotlinBuildPusher : DefaultTask() {
|
||||
@Input
|
||||
@Option(option = "token", description = "Teamcity Bear token")
|
||||
var token:String? = ""
|
||||
var token: String? = ""
|
||||
|
||||
@Input
|
||||
@Option(option = "buildServer", description = "Teamcity server")
|
||||
var buildServer:String = ""
|
||||
var buildServer: String = ""
|
||||
|
||||
@Input
|
||||
@Option(option = "compilerConfigurationId", description = "Teamcity configuration id")
|
||||
var compilerConfigurationId: String = "Kotlin_dev_Compiler"
|
||||
|
||||
@Input
|
||||
@Option(option = "overrideConfigurationId", description = "Teamcity kotlin override configuration id")
|
||||
var overrideConfigurationId: String = "Kotlin_dev_DeployMavenArtifacts_OverrideNative"
|
||||
|
||||
@Input
|
||||
@Option(option = "kotlinVersion", description = "Kotlin Compiler Version")
|
||||
var kotlinVersion:String = ""
|
||||
var kotlinVersion: String = ""
|
||||
|
||||
@Input
|
||||
@Option(option = "konanVersion", description = "Kotlin Native Compiler Version")
|
||||
var konanVersion:String = ""
|
||||
var konanVersion: String = ""
|
||||
|
||||
@TaskAction
|
||||
fun run() {
|
||||
requireNotNull(token, {"Teamcity Bear token required"})
|
||||
requireNotNull(token, { "Teamcity Bear token required" })
|
||||
val client = HttpClient()
|
||||
runBlocking {
|
||||
val buildId = client.get<String>(scheme = "https", host = buildServer, path = "/app/rest/builds/buildType:(id:Kotlin_dev_Compiler),number:$kotlinVersion/id" ) {
|
||||
val buildId = client.get<String>(
|
||||
scheme = "https",
|
||||
host = buildServer,
|
||||
path = "/app/rest/builds/buildType:(id:$compilerConfigurationId),number:$kotlinVersion/id"
|
||||
) {
|
||||
header("Authorization", "Bearer $token")
|
||||
}
|
||||
project.logger.info("pusher: buildId: $buildId")
|
||||
|
||||
/**
|
||||
* <build>
|
||||
* <buildType id="Kotlin_dev_DeployMavenArtifacts_OverrideNative"/>
|
||||
@@ -53,9 +63,9 @@ open class KotlinBuildPusher: DefaultTask() {
|
||||
* </properties>
|
||||
* </build>
|
||||
*/
|
||||
val content = buildString{
|
||||
build{
|
||||
buildType("Kotlin_dev_DeployMavenArtifacts_OverrideNative")
|
||||
val content = buildString {
|
||||
build {
|
||||
buildType(overrideConfigurationId)
|
||||
lastChanges {
|
||||
change(buildId)
|
||||
}
|
||||
@@ -65,7 +75,12 @@ open class KotlinBuildPusher: DefaultTask() {
|
||||
}
|
||||
}
|
||||
project.logger.info("pusher: content: \"$content\"")
|
||||
val res = client.post<String>(scheme = "https", host = buildServer, path = "/app/rest/buildQueue") {
|
||||
|
||||
val res = client.post<String>(
|
||||
scheme = "https",
|
||||
host = buildServer,
|
||||
path = "/app/rest/buildQueue"
|
||||
) {
|
||||
header("Authorization", "Bearer $token")
|
||||
header("Origin", "https://$buildServer")
|
||||
body = TextContent(content, ContentType.Application.Xml)
|
||||
@@ -82,10 +97,10 @@ internal fun StringBuilder.paired(tag:String, body:StringBuilder.()->Unit) {
|
||||
appendln("</$tag>")
|
||||
}
|
||||
|
||||
internal fun StringBuilder.build(body:StringBuilder.()->Unit) = paired("build", body)
|
||||
internal fun StringBuilder.buildType(id:String) = appendln("<buildType id=\"$id\"/>")
|
||||
internal fun StringBuilder.lastChanges(body:StringBuilder.()->Unit) = paired("lastChanges", body)
|
||||
internal fun StringBuilder.change(build:String) = appendln("<change locator=\"build:$build\"/>")
|
||||
internal fun StringBuilder.properties(body:StringBuilder.()->Unit) = paired("properties", body)
|
||||
internal fun StringBuilder.property(key:String, value:String) = appendln("<property name=\"$key\" value=\"$value\"/>")
|
||||
internal fun StringBuilder.build(body: StringBuilder.() -> Unit) = paired("build", body)
|
||||
internal fun StringBuilder.buildType(id: String) = appendln("<buildType id=\"$id\"/>")
|
||||
internal fun StringBuilder.lastChanges(body: StringBuilder.() -> Unit) = paired("lastChanges", body)
|
||||
internal fun StringBuilder.change(build: String) = appendln("<change locator=\"build:$build\"/>")
|
||||
internal fun StringBuilder.properties(body: StringBuilder.() -> Unit) = paired("properties", body)
|
||||
internal fun StringBuilder.property(key: String, value: String) = appendln("<property name=\"$key\" value=\"$value\"/>")
|
||||
|
||||
|
||||
+3
-1
@@ -630,9 +630,11 @@ task clean {
|
||||
}
|
||||
}
|
||||
|
||||
task pusher(type: KotlinBuildPusher){
|
||||
task pusher(type: KotlinBuildPusher){
|
||||
kotlinVersion = project.kotlinVersion
|
||||
konanVersion = KonanVersionGeneratedKt.getCurrentKonanVersion()
|
||||
buildServer = "teamcity.jetbrains.com"
|
||||
compilerConfigurationId = "Kotlin_dev_Compiler"
|
||||
overrideConfigurationId = "Kotlin_dev_DeployMavenArtifacts_OverrideNative"
|
||||
token = project.findProperty("teamcityBearToken") ?: System.getenv("TEAMCITY_BEAR_TOKEN")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user