Skip to content

Commit 94c0307

Browse files
Quattro8zoobestik
andauthored
Playground/timestamps fix (#5166)
* Update WritersideBuilder to new docker image version and add timestamps generation * Update timestamps script for getting date from nested folders * small fix: update version for settings.kts * Fix variable syntax in WritersideBuilder for timestamps generation * Add error handling to timestamps generation script in WritersideBuilder --------- Co-authored-by: Konstantin Chernenko <[email protected]>
1 parent b7eb6f0 commit 94c0307

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

.teamcity/documentation/builds/WritersideBuilder.kt

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@ import jetbrains.buildServer.configs.kotlin.triggers.vcs
99
abstract class WritersideBuilder(
1010
module: String,
1111
instance: String,
12-
customInit: BuildType.() -> Unit = {},
12+
customInit: BuildType.() -> Unit = {}
1313
postProcessAdditions: String = postProcessingScript(),
1414
) : BuildType({
15-
val dockerImageTag = "2025.07.8502"
15+
val dockerImageTag = "2.1.2180-p8506"
1616
val frontend = "file:///opt/static/"
1717

1818
name = "${instance.uppercase()} documentation build"
1919
description = "Build $module/$instance documentation with the docker"
2020

2121
artifactRules = """
2222
artifacts/*
23+
timestamps.json
2324
""".trimIndent()
2425

2526
triggers {
@@ -29,6 +30,38 @@ abstract class WritersideBuilder(
2930
}
3031

3132
steps {
33+
script {
34+
name = "Generate timestamps file"
35+
scriptContent = """
36+
set -e
37+
38+
echo "Generate timestamps"
39+
echo "{" > %teamcity.build.checkoutDir%/timestamps.json
40+
41+
# Process the main repository
42+
cd %teamcity.build.checkoutDir%
43+
git ls-tree -r --name-only HEAD | grep -E '\.(topic|md)$' | while read file; do
44+
timestamp=${'$'}(git log -1 --format="%at" -- "${'$'}file")
45+
echo "\"${'$'}file\": \"${'$'}timestamp\"," >> %teamcity.build.checkoutDir%/timestamps.json
46+
done
47+
48+
# Process all subdirectories containing .git folders
49+
find %teamcity.build.checkoutDir% -mindepth 2 -maxdepth 2 -type d -name ".git" | while read gitdir; do
50+
repo_dir=${'$'}(dirname "${'$'}gitdir")
51+
rel_dir=${'$'}(basename "${'$'}repo_dir")
52+
53+
cd "${'$'}repo_dir"
54+
git ls-tree -r --name-only HEAD | grep -E '\.(topic|md)$' | while read file; do
55+
timestamp=${'$'}(git log -1 --format="%at" -- "${'$'}file")
56+
echo "\"${'$'}rel_dir/${'$'}file\": \"${'$'}timestamp\"," >> %teamcity.build.checkoutDir%/timestamps.json
57+
done
58+
done
59+
60+
# Remove trailing comma from last entry
61+
sed -i '${'$'} s/.$//' %teamcity.build.checkoutDir%/timestamps.json
62+
echo "}" >> %teamcity.build.checkoutDir%/timestamps.json
63+
""".trimIndent()
64+
}
3265
script {
3366
name = "Build $module/$instance documentation with the docker"
3467
scriptContent = """
@@ -44,6 +77,7 @@ abstract class WritersideBuilder(
4477
-e RUNNER=teamcity
4578
-e FRONTEND=$frontend
4679
-e OUTPUT_DIR=/opt/sources/artifacts
80+
-e TIME=/opt/sources/timestamps.json
4781
""".trimIndent()
4882
}
4983
script {

.teamcity/settings.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ To debug in IntelliJ Idea, open the 'Maven Projects' tool window (View
2222
'Debug' option is available in the context menu for the task.
2323
*/
2424

25-
version = "2025.03"
25+
version = "2025.07"
2626

2727
project {
2828

0 commit comments

Comments
 (0)