-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from gradle/cobexer/basic-teamcity-setup
TeamCity: add basic project setup
- Loading branch information
Showing
12 changed files
with
574 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
The archive contains settings for a TeamCity project. | ||
|
||
To edit the settings in IntelliJ Idea, open the pom.xml and | ||
select the 'Open as a project' option. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?xml version="1.0"?> | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<name>Gradle_Fileevents Config DSL Script</name> | ||
<groupId>Gradle_Fileevents</groupId> | ||
<artifactId>Gradle_Fileevents_dsl</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<parent> | ||
<groupId>org.jetbrains.teamcity</groupId> | ||
<artifactId>configs-dsl-kotlin-parent</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<repositories> | ||
<repository> | ||
<id>jetbrains-all</id> | ||
<url>https://download.jetbrains.com/teamcity-repository</url> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
</snapshots> | ||
</repository> | ||
<repository> | ||
<id>teamcity-server</id> | ||
<url>https://builds.gradle.org/app/dsl-plugins-repository</url> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
</snapshots> | ||
</repository> | ||
</repositories> | ||
|
||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>JetBrains</id> | ||
<url>https://download.jetbrains.com/teamcity-repository</url> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
|
||
<build> | ||
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory> | ||
<plugins> | ||
<plugin> | ||
<artifactId>kotlin-maven-plugin</artifactId> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<version>${kotlin.version}</version> | ||
|
||
<configuration/> | ||
<executions> | ||
<execution> | ||
<id>compile</id> | ||
<phase>process-sources</phase> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>test-compile</id> | ||
<phase>process-test-sources</phase> | ||
<goals> | ||
<goal>test-compile</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.jetbrains.teamcity</groupId> | ||
<artifactId>teamcity-configs-maven-plugin</artifactId> | ||
<version>${teamcity.dsl.version}</version> | ||
<configuration> | ||
<format>kotlin</format> | ||
<dstDir>target/generated-configs</dstDir> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jetbrains.teamcity</groupId> | ||
<artifactId>configs-dsl-kotlin-latest</artifactId> | ||
<version>${teamcity.dsl.version}</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jetbrains.teamcity</groupId> | ||
<artifactId>configs-dsl-kotlin-plugins-latest</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<type>pom</type> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-stdlib-jdk8</artifactId> | ||
<version>${kotlin.version}</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-script-runtime</artifactId> | ||
<version>${kotlin.version}</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import jetbrains.buildServer.configs.kotlin.* | ||
import jetbrains.buildServer.configs.kotlin.buildFeatures.perfmon | ||
import jetbrains.buildServer.configs.kotlin.triggers.vcs | ||
import jetbrains.buildServer.configs.kotlin.vcs.GitVcsRoot | ||
|
||
/* | ||
The settings script is an entry point for defining a TeamCity | ||
project hierarchy. The script should contain a single call to the | ||
project() function with a Project instance or an init function as | ||
an argument. | ||
VcsRoots, BuildTypes, Templates, and subprojects can be | ||
registered inside the project using the vcsRoot(), buildType(), | ||
template(), and subProject() methods respectively. | ||
To debug settings scripts in command-line, run the | ||
mvnDebug org.jetbrains.teamcity:teamcity-configs-maven-plugin:generate | ||
command and attach your debugger to the port 8000. | ||
To debug in IntelliJ Idea, open the 'Maven Projects' tool window (View | ||
-> Tool Windows -> Maven Projects), find the generate task node | ||
(Plugins -> teamcity-configs -> teamcity-configs:generate), the | ||
'Debug' option is available in the context menu for the task. | ||
*/ | ||
|
||
version = "2024.03" | ||
|
||
project { | ||
RootProject(this) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import jetbrains.buildServer.configs.kotlin.BuildType | ||
import jetbrains.buildServer.configs.kotlin.CheckoutMode | ||
import jetbrains.buildServer.configs.kotlin.DslContext | ||
import jetbrains.buildServer.configs.kotlin.buildFeatures.commitStatusPublisher | ||
import jetbrains.buildServer.configs.kotlin.buildFeatures.freeDiskSpace | ||
|
||
open class BaseBuildType( | ||
val init: BuildType.() -> Unit, | ||
): BuildType({ | ||
params { | ||
param("env.DEVELOCITY_ACCESS_KEY", "%ge.gradle.org.access.key%") | ||
} | ||
|
||
vcs { | ||
root(DslContext.settingsRoot) | ||
checkoutMode = CheckoutMode.ON_AGENT | ||
cleanCheckout = true | ||
} | ||
|
||
features { | ||
commitStatusPublisher { | ||
vcsRootExtId = DslContext.settingsRoot.id?.value | ||
publisher = github { | ||
githubUrl = "https://api.github.com" | ||
authType = personalToken { | ||
token = "%github.bot-teamcity.token%" | ||
} | ||
} | ||
} | ||
|
||
freeDiskSpace { | ||
requiredSpace = "1gb" | ||
failBuild = false | ||
} | ||
} | ||
this.init() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import jetbrains.buildServer.configs.kotlin.buildSteps.gradle | ||
|
||
class Build : BaseBuildType({ | ||
name = "Build File Events" | ||
|
||
artifactRules = """ | ||
build/reports/** => file-events/reports | ||
build-logic/build/reports/** => build-logic/reports | ||
build/libs => repo | ||
""".trimIndent() | ||
|
||
params { | ||
param("env.PGP_SIGNING_KEY", "%pgpSigningKey%") | ||
param("env.PGP_SIGNING_KEY_PASSPHRASE", "%pgpSigningPassphrase%") | ||
|
||
param("env.GRADLE_INTERNAL_REPO_URL", "%gradle.internal.repository.url%") | ||
} | ||
|
||
steps { | ||
gradle { | ||
name = "Gradle assemble" | ||
tasks = "clean assemble" | ||
} | ||
} | ||
|
||
runOn(Agent.MacOsAarch64, 17) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright 2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import jetbrains.buildServer.configs.kotlin.Requirements | ||
|
||
enum class Agent(val os: Os, val architecture: Architecture) { | ||
UbuntuAmd64(os = Os.Ubuntu16, architecture = Architecture.Amd64), | ||
UbuntuAarch64(os = Os.Ubuntu24, architecture = Architecture.Aarch64), | ||
AmazonLinuxAmd64(os = Os.AmazonLinux, architecture = Architecture.Amd64), | ||
AmazonLinuxAarch64(os = Os.AmazonLinux, architecture = Architecture.Aarch64), | ||
CentOsAmd64(os = Os.CentOs, architecture = Architecture.Amd64), | ||
WindowsAmd64(os = Os.Windows, architecture = Architecture.Amd64), | ||
MacOsAmd64(os = Os.MacOs, architecture = Architecture.Amd64), | ||
MacOsAarch64(os = Os.MacOs, architecture = Architecture.Aarch64), | ||
} | ||
|
||
interface Os { | ||
fun addAgentRequirements(requirements: Requirements) | ||
val osType: String | ||
|
||
object Ubuntu16 : Ubuntu(16) | ||
|
||
object Ubuntu24 : Ubuntu(24) | ||
|
||
object AmazonLinux : Linux() { | ||
override fun Requirements.additionalRequirements() { | ||
contains(osDistributionNameParameter, "amazon") | ||
} | ||
} | ||
|
||
object CentOs : Linux() { | ||
override fun Requirements.additionalRequirements() { | ||
contains(osDistributionNameParameter, "centos") | ||
contains(osDistributionVersionParameter, "9") | ||
} | ||
} | ||
|
||
object MacOs : OsWithNameRequirement("Mac OS X", "MacOs") | ||
|
||
object Windows : OsWithNameRequirement("Windows", "Windows") | ||
} | ||
|
||
private const val osDistributionNameParameter = "system.agent.os.distribution.name" | ||
private const val osDistributionVersionParameter = "system.agent.os.distribution.version" | ||
|
||
abstract class OsWithNameRequirement(private val osName: String, override val osType: String) : Os { | ||
override fun addAgentRequirements(requirements: Requirements) { | ||
requirements.contains("teamcity.agent.jvm.os.name", osName) | ||
requirements.additionalRequirements() | ||
} | ||
|
||
open fun Requirements.additionalRequirements() {} | ||
} | ||
|
||
abstract class Linux : OsWithNameRequirement("Linux", "Linux") | ||
|
||
abstract class Ubuntu(val version: Int) : Linux() { | ||
override fun Requirements.additionalRequirements() { | ||
contains(osDistributionNameParameter, "ubuntu") | ||
contains(osDistributionVersionParameter, version.toString()) | ||
} | ||
} | ||
|
||
enum class Architecture(val paramName: String) { | ||
Aarch64("aarch64") { | ||
override fun agentRequirementForOs(os: Os): String = "aarch64" | ||
}, | ||
Amd64("64bit") { | ||
override fun agentRequirementForOs(os: Os): String = when (os) { | ||
Os.MacOs -> "x86_64" | ||
else -> "amd64" | ||
} | ||
}; | ||
|
||
abstract fun agentRequirementForOs(os: Os): String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright 2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import jetbrains.buildServer.configs.kotlin.FailureAction | ||
import jetbrains.buildServer.configs.kotlin.ParameterDisplay | ||
import jetbrains.buildServer.configs.kotlin.buildSteps.gradle | ||
|
||
class Publish(build: Build, tests: TestTrigger) : BaseBuildType({ | ||
name = "Publish File Events" | ||
type = Type.DEPLOYMENT | ||
|
||
artifactRules = """ | ||
build/reports/** => file-events/reports | ||
build-logic/build/reports/** => build-logic/reports | ||
""".trimIndent() | ||
|
||
params { | ||
param("env.GRADLE_INTERNAL_REPO_URL", "%gradle.internal.repository.url%") | ||
param("ARTIFACTORY_USERNAME", "%gradle.internal.repository.build-tool.publish.username%") | ||
password("ARTIFACTORY_PASSWORD", "gradle.internal.repository.build-tool.publish.password%", display = ParameterDisplay.HIDDEN) | ||
param("env.ORG_GRADLE_PROJECT_publishApiKey", "%ARTIFACTORY_PASSWORD%") | ||
param("env.ORG_GRADLE_PROJECT_publishUserName", "%ARTIFACTORY_USERNAME%") | ||
} | ||
|
||
steps { | ||
gradle { | ||
name = "Gradle publish" | ||
tasks = "publish" | ||
} | ||
} | ||
|
||
dependencies { | ||
snapshot(build) { | ||
onDependencyFailure = FailureAction.FAIL_TO_START | ||
onDependencyCancel = FailureAction.FAIL_TO_START | ||
} | ||
dependency(build) { | ||
artifacts { | ||
cleanDestination = true | ||
artifactRules = "repo => build/remote/" | ||
} | ||
} | ||
snapshot(tests) { | ||
onDependencyFailure = FailureAction.FAIL_TO_START | ||
onDependencyCancel = FailureAction.FAIL_TO_START | ||
} | ||
} | ||
|
||
runOn(Agent.MacOsAarch64, 17) | ||
}) |
Oops, something went wrong.