From d634c32fd44ed811b4c4fe5b93025fe8ea9faa49 Mon Sep 17 00:00:00 2001 From: Michael Kuzmin Date: Wed, 19 Dec 2018 22:50:36 +0300 Subject: [PATCH] Enable TeamCity DSL --- .teamcity/.gitignore | 2 + .teamcity/pom.xml | 104 +++++++++++++++++++++++++++++++ .teamcity/settings.kts | 137 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 243 insertions(+) create mode 100644 .teamcity/.gitignore create mode 100644 .teamcity/pom.xml create mode 100644 .teamcity/settings.kts diff --git a/.teamcity/.gitignore b/.teamcity/.gitignore new file mode 100644 index 000000000..7f995f335 --- /dev/null +++ b/.teamcity/.gitignore @@ -0,0 +1,2 @@ +*.iml +target/ diff --git a/.teamcity/pom.xml b/.teamcity/pom.xml new file mode 100644 index 000000000..49f9e3cd6 --- /dev/null +++ b/.teamcity/pom.xml @@ -0,0 +1,104 @@ + + + 4.0.0 + PackerVSphere Config DSL Script + PackerVSphere + PackerVSphere_dsl + 1.0-SNAPSHOT + + + org.jetbrains.teamcity + configs-dsl-kotlin-parent + 1.0-SNAPSHOT + + + + + jetbrains-all + https://download.jetbrains.com/teamcity-repository + + true + + + + teamcity-server + https://teamcity.jetbrains.com/app/dsl-plugins-repository + + true + + + + + + + JetBrains + https://download.jetbrains.com/teamcity-repository + + + + + . + + + kotlin-maven-plugin + org.jetbrains.kotlin + ${kotlin.version} + + + + + compile + process-sources + + compile + + + + test-compile + process-test-sources + + test-compile + + + + + + org.jetbrains.teamcity + teamcity-configs-maven-plugin + ${teamcity.dsl.version} + + kotlin + target/generated-configs + + + + + + + + org.jetbrains.teamcity + configs-dsl-kotlin + ${teamcity.dsl.version} + compile + + + org.jetbrains.teamcity + configs-dsl-kotlin-plugins + 1.0-SNAPSHOT + pom + compile + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + compile + + + org.jetbrains.kotlin + kotlin-script-runtime + ${kotlin.version} + compile + + + \ No newline at end of file diff --git a/.teamcity/settings.kts b/.teamcity/settings.kts new file mode 100644 index 000000000..bd70696cf --- /dev/null +++ b/.teamcity/settings.kts @@ -0,0 +1,137 @@ +import jetbrains.buildServer.configs.kotlin.v2018_2.* +import jetbrains.buildServer.configs.kotlin.v2018_2.buildFeatures.PullRequests +import jetbrains.buildServer.configs.kotlin.v2018_2.buildFeatures.commitStatusPublisher +import jetbrains.buildServer.configs.kotlin.v2018_2.buildFeatures.pullRequests +import jetbrains.buildServer.configs.kotlin.v2018_2.buildSteps.dockerCompose +import jetbrains.buildServer.configs.kotlin.v2018_2.buildSteps.script +import jetbrains.buildServer.configs.kotlin.v2018_2.triggers.vcs +import jetbrains.buildServer.configs.kotlin.v2018_2.vcs.GitVcsRoot + +version = "2018.2" + +project { + description = "https://github.com/jetbrains-infra/packer-builder-vsphere" + + vcsRoot(GitHub) + + buildType(Build) + + features { + + feature { + type = "IssueTracker" + param("type", "GithubIssues") + param("repository", "https://github.com/jetbrains-infra/packer-builder-vsphere") + } + } +} + +object GitHub : GitVcsRoot({ + name = "packer-builder-vsphere" + url = "https://github.com/jetbrains-infra/packer-builder-vsphere" + branch = "master" + branchSpec = "+:refs/heads/(*)" + userNameStyle = GitVcsRoot.UserNameStyle.FULL +}) + +object Build : BuildType({ + val path = "src/github.com/jetbrains-infra/packer-builder-vsphere" + val golangImage = "jetbrainsinfra/golang:1.10.4" + + name = "Build" + + vcs { + root(GitHub, "+:. => $path") + } + + requirements { + equals("docker.server.osType", "linux") + exists("dockerCompose.version") + + doesNotContain("teamcity.agent.name", "ubuntu-single-build") + } + + params { + password("env.VPN_PASSWORD", "credentialsJSON:8c355e81-9a26-4788-8fea-c854cd646c35") + param ("env.VSPHERE_USERNAME", """vsphere65.test\teamcity""") + password("env.VSPHERE_PASSWORD", "credentialsJSON:3e99d6c8-b66f-410a-a865-eaf1b12664ad") + + param("env.GOPATH", "%teamcity.build.checkoutDir%") + param("env.GOCACHE", "%teamcity.build.checkoutDir%/build") + } + + steps { + script { + name = "Build" + workingDir = path + scriptContent = "./build.sh" + dockerImage = golangImage + dockerPull = true + } + + dockerCompose { + name = "Start VPN tunnel" + file = "$path/teamcity-services.yml" + } + + script { + name = "Test" + workingDir = path + scriptContent = """ + set -eux + + go test -c ./driver + go test -c ./iso + go test -c ./clone + + ./test.sh | go-test-teamcity + """.trimIndent() + dockerImage = golangImage + dockerPull = true + dockerRunParameters = "--network=container:vpn" + } + script { + name = "gofmt" + executionMode = BuildStep.ExecutionMode.RUN_ON_FAILURE + workingDir = path + scriptContent = "./gofmt.sh" + dockerImage = golangImage + dockerPull = true + } + } + + features { + commitStatusPublisher { + publisher = github { + githubUrl = "https://api.github.com" + authType = personalToken { + token = "credentialsJSON:95bbfc46-3141-4bed-86ec-f8ec751f3e94" + } + } + param("github_oauth_user", "mkuzmin") + } + pullRequests { + provider = github { + authType = token { + token = "credentialsJSON:39727f26-62ed-4152-ab9a-f6845076a979" + } + filterAuthorRole = PullRequests.GitHubRoleFilter.EVERYBODY + } + } + } + + triggers { + vcs { + triggerRules = "-:*.md" + branchFilter = """ + +:* + -:temp-* + -:pull/* + """.trimIndent() + } + } + maxRunningBuilds = 2 + + artifactRules = "$path/bin/* => packer-builder-vsphere-%build.number%.zip" + allowExternalStatus = true +})