Skip to content

Commit

Permalink
[TW-90511] Update plugins within Windows-based docker images (#177)
Browse files Browse the repository at this point in the history
[TW-90511] Update plugins within Windows-based docker images

* Replace path creation from canonical to real path.

* Prevent plugins removal @ Docker images.

* Re-generate Dockerfile to address the new logic.
  • Loading branch information
AndreyKoltsov1997 authored Nov 29, 2024
1 parent b249d32 commit 8b7b39e
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ COPY TeamCity/buildAgent C:/BuildAgent
COPY scripts/*.cs /scripts/
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

# Workaround for TW-87124 - Windows-based plugin directories receive incorrect case, causing their inability ...
# ... to load. The directory will be fetched from the server upon the first update with proper case.
RUN Remove-Item -Recurse -Force C:/BuildAgent/plugins

COPY run-agent.ps1 /BuildAgent/run-agent.ps1

# JDK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference
RUN mkdir C:\\BuildAgent
COPY TeamCity/buildAgent C:/BuildAgent

# Workaround for TW-87124 - Windows 2022-based plugin directories receive incorrect case, causing their inability ...
# ... to load. The directory will be fetched from the server upon the first update with proper case.
RUN Remove-Item -Recurse -Force C:/BuildAgent/plugins

COPY run-agent.ps1 /BuildAgent/run-agent.ps1

# JDK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ COPY TeamCity/buildAgent C:/BuildAgent
COPY scripts/*.cs /scripts/
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

# Workaround for TW-87124 - Windows-based plugin directories receive incorrect case, causing their inability ...
# ... to load. The directory will be fetched from the server upon the first update with proper case.
RUN Remove-Item -Recurse -Force C:/BuildAgent/plugins

COPY run-agent.ps1 /BuildAgent/run-agent.ps1

# JDK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ COPY TeamCity/buildAgent C:/BuildAgent
COPY scripts/*.cs /scripts/
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

# Workaround for TW-87124 - Windows-based plugin directories receive incorrect case, causing their inability ...
# ... to load. The directory will be fetched from the server upon the first update with proper case.
RUN Remove-Item -Recurse -Force C:/BuildAgent/plugins

COPY run-agent.ps1 /BuildAgent/run-agent.ps1

# JDK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ COPY TeamCity/buildAgent C:/BuildAgent
COPY scripts/*.cs /scripts/
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

# Workaround for TW-87124 - Windows-based plugin directories receive incorrect case, causing their inability ...
# ... to load. The directory will be fetched from the server upon the first update with proper case.
RUN Remove-Item -Recurse -Force C:/BuildAgent/plugins

COPY run-agent.ps1 /BuildAgent/run-agent.ps1

# JDK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference
RUN mkdir C:\\BuildAgent
COPY TeamCity/buildAgent C:/BuildAgent

# Workaround for TW-87124 - Windows 2022-based plugin directories receive incorrect case, causing their inability ...
# ... to load. The directory will be fetched from the server upon the first update with proper case.
RUN Remove-Item -Recurse -Force C:/BuildAgent/plugins

COPY run-agent.ps1 /BuildAgent/run-agent.ps1

# JDK
Expand Down
25 changes: 11 additions & 14 deletions tool/agent-upgrade-dist/src/main/kotlin/Files.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,27 @@ import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.io.File
import java.io.InputStream
import java.nio.file.Paths

fun File.dir(): Sequence<File> = this.listFiles()?.asSequence() ?: emptySequence()

fun File.ensureDirExists(description: String = "", createIfNotExists: Boolean = false): File {
if (this.isDirectory()) {
if (description.isNotBlank()) {
println("$description directory: ${this.canonicalFile}")
if (this.exists()) {
if (this.isDirectory) {
throw Exception("\"$this\" - is not a directory.");
}
return this.canonicalFile
return Paths.get(path).toRealPath().toFile()
}

if (!this.exists()) {
if (createIfNotExists) {
this.mkdirs();
if (description.isNotBlank()) {
println("$description directory: ${this.canonicalFile}")
}
return this.canonicalFile
if (createIfNotExists) {
this.mkdirs()
if (description.isNotBlank()) {
println("$description directory: ${this.canonicalFile}")
}

throw Exception("Cannot find directory \"$this\".");
return Paths.get(path).toRealPath().toFile()
}

throw Exception("\"$this\" - is not a directory.");
throw Exception("\"$this\" does not exist")
}

fun InputStream.buffered(bufferSize: Long): InputStream {
Expand Down

0 comments on commit 8b7b39e

Please sign in to comment.