[build] teamcity pusher to initiate Kotlin + Kotln/Native master snapshot

This commit is contained in:
Vasily Levchenko
2019-06-07 17:06:44 +03:00
parent e7396682f5
commit c5cc5c3d2f
3 changed files with 102 additions and 1 deletions
+8 -1
View File
@@ -18,7 +18,7 @@ import org.jetbrains.kotlin.konan.util.*
import org.jetbrains.kotlin.CopySamples
import org.jetbrains.kotlin.CopyCommonSources
import org.jetbrains.kotlin.PlatformInfo
import org.jetbrains.kotlin.konan.*
import org.jetbrains.kotlin.KotlinBuildPusher
buildscript {
apply from: "gradle/kotlinGradlePlugin.gradle"
@@ -549,4 +549,11 @@ task clean {
delete distDir
delete bundle.outputs.files
}
}
task pusher(type: KotlinBuildPusher){
kotlinVersion = project.kotlinVersion
konanVersion = KonanVersionGeneratedKt.getCurrentKonanVersion()
buildServer = "teamcity.jetbrains.com"
token = project.findProperty("teamcityBearToken") ?: System.getenv("TEAMCITY_BEAR_TOKEN")
}
+3
View File
@@ -43,6 +43,9 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-gradle-plugin"
compile project(':shared')
compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.10.0"
implementation 'io.ktor:ktor-client-auth:1.2.1'
implementation 'io.ktor:ktor-client-core:1.2.1'
implementation 'io.ktor:ktor-client-cio:1.2.1'
}
sourceSets.main.kotlin.srcDirs = ["src", "$projectDir/../../tools/benchmarks/shared/src"]
@@ -0,0 +1,91 @@
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.tasks.Input
import org.gradle.api.tasks.options.Option
open class KotlinBuildPusher: DefaultTask() {
@Input
@Option(option = "token", description = "Teamcity Bear token")
var token:String? = ""
@Input
@Option(option = "buildServer", description = "Teamcity server")
var buildServer:String = ""
@Input
@Option(option = "kotlinVersion", description = "Kotlin Compiler Version")
var kotlinVersion:String = ""
@Input
@Option(option = "konanVersion", description = "Kotlin Native Compiler Version")
var konanVersion:String = ""
@TaskAction
fun run() {
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" ) {
header("Authorization", "Bearer $token")
}
project.logger.info("pusher: buildId: $buildId")
/**
* <build>
* <buildType id="Kotlin_dev_DeployMavenArtifacts_OverrideNative"/>
* <lastChanges>
* <change locator="build:2330798"/>
* </lastChanges>
* <properties>
* <property name="system.versions.kotlin-native" value="1.3.50-dev-10483"/>
* </properties>
* </build>
*/
val content = buildString{
build{
buildType("Kotlin_dev_DeployMavenArtifacts_OverrideNative")
lastChanges {
change(buildId)
}
properties {
property("system.versions.kotlin-native", konanVersion)
}
}
}
project.logger.info("pusher: content: \"$content\"")
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)
}
project.logger.info("pusher: result: \"$res\"")
}
client.close()
}
}
internal fun StringBuilder.paired(tag:String, body:StringBuilder.()->Unit) {
appendln("<$tag>")
body()
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\"/>")