Skip to content

Commit

Permalink
TeamCity: add basic project setup
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Obexer <[email protected]>
  • Loading branch information
cobexer committed Sep 3, 2024
1 parent 3073762 commit d995874
Show file tree
Hide file tree
Showing 5 changed files with 240 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .teamcity/README
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.
104 changes: 104 additions & 0 deletions .teamcity/pom.xml
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>
32 changes: 32 additions & 0 deletions .teamcity/settings.kts
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 {
buildType(BuildFileEvents)
}
47 changes: 47 additions & 0 deletions .teamcity/src/main/kotlin/Build.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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

object BuildFileEvents : FileEventsBaseBuildType({
name = "Build File Events"

artifactRules = """
build/reports/** => file-events/reports
build-logic/build/reports/** => build-logic/reports
""".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%")
param("env.JAVA_HOME", "%macos.java17.openjdk.aarch64%")

}

steps {
gradle {
name = "Gradle assemble"
tasks = "clean assemble"
}
}

requirements {
contains("teamcity.agent.jvm.os.name", "Mac OS X")
contains("teamcity.agent.jvm.os.arch", "aarch64")
}
})
53 changes: 53 additions & 0 deletions .teamcity/src/main/kotlin/FileEventsBaseBuildType.kt
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 FileEventsBaseBuildType(
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()
})

0 comments on commit d995874

Please sign in to comment.