Artifact Migration Tool

TeamCity Enterprise 2022.10.2 (build 117025)
Windows Server 2008R2
PSVersion 3.0
Java 1.8

application.config:

teamcity.storage.migration.access.token=AiV***XVX
teamcity.storage.migration.artifact.directories=C:\TeamCity\Data\system\artifacts;
teamcity.storage.migration.host=https://myserver.mydomain.com
teamcity.storage.migration.processing.threadCount=4
teamcity.storage.migration.s3.upload.numberOfRetries=5
teamcity.storage.migration.s3.upload.retryDelayMs=3000
teamcity.storage.migration.failWhenCannotAccessStorageSettings=false
teamcity.storage.migration.s3.custom.profile.PROJECT_EXT_111=foo-bar

I also have confirmed AWS ~/.aws/configuration works

I get an error when running the tool:

PS C:\Users\..\bin> .\migrate -p MY_SPECIAL_PROJECT_ID
Data directory 'C:TeamCityDatasystemartifacts' not found
Exception in thread "main" java.lang.IllegalArgumentException: Authentication token not found. Please provide a valid TeamCity authentication token
        at jetbrains.buildServer.artifacts.migration.rest.TeamCityRestClient.<init>(TeamCityRestClient.kt:27)
        at jetbrains.buildServer.artifacts.migration.Main.run(Main.kt:102)
        at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:198)
        at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:18)
        at com.github.ajalt.clikt.core.CliktCommand.parse(CliktCommand.kt:395)
        at com.github.ajalt.clikt.core.CliktCommand.parse$default(CliktCommand.kt:392)
        at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:410)
        at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:435)
        at jetbrains.buildServer.artifacts.migration.MainKt.main(Main.kt:337)

I also have a valid Token, for sure it works with API requests, but I am not sure if I formatted the artifact path(s) correct for this parameter teamcity.storage.migration.artifact.directories. It is not explained in the documentation (https://www.jetbrains.com/help/teamcity/artifacts-migration-tool.html#Required+Properties) and just says

  • teamcity.storage.migration.artifact.directories — the list of TeamCity artifact directories separated with `;`

Anyone know of an example I can follow to try this out? I'm quite stuck in my troubleshooting.

0
6 comments

Hi Blush,

Since those are Java properties, you can either use forward slashes or escape backward slashes. I.e.:

teamcity.storage.migration.artifact.directories=C:/TeamCity/Data/system/artifacts

or

teamcity.storage.migration.artifact.directories=C:\\TeamCity\\Data\\system\\artifacts

Let me know if that helps.

1

Hi Mikhail, yes that resolved one of the two issues (and helps me understand how it works!). My only remaining issue is with the token being rejected, but I can use it to call the Rest API with 200 status. I have an open support ticket. I'll post the resolution in this thread.

PS C:\Users\..\Downloads\artifacts-migration-tool\teamcity-artifacts-migration-tool-2022.10\bin> .\migrate -p MY_SPECIAL_PROJECT

Exception in thread "main" java.lang.IllegalArgumentException: Authentication token not found. Please provide a valid Te
amCity authentication token
        at jetbrains.buildServer.artifacts.migration.rest.TeamCityRestClient.<init>(TeamCityRestClient.kt:27)
        at jetbrains.buildServer.artifacts.migration.Main.run(Main.kt:102)
        at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:198)
        at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:18)
        at com.github.ajalt.clikt.core.CliktCommand.parse(CliktCommand.kt:395)
        at com.github.ajalt.clikt.core.CliktCommand.parse$default(CliktCommand.kt:392)
        at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:410)
        at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:435)
        at jetbrains.buildServer.artifacts.migration.MainKt.main(Main.kt:337)
PS C:\Users\..\Downloads\artifacts-migration-tool\teamcity-artifacts-migration-tool-2022.10\bin> Invoke-WebRequest
 -Headers @{"Authorization"="Bearer $tokenValue"} -Uri http://localhost/app/rest/builds


StatusCode        : 200
StatusDescription :
Content           : <?xml version="1.0" encoding="UTF-8" standalone="yes"?><builds count="100" href="/app/rest/builds"
                    nextHref="/app/rest/builds?locator=count:100,start:100"><build id="1011111"
                    buildTypeId="ApiGateway_A...
RawContent        : HTTP/1.1 200
                    TeamCity-Node-Id: MAIN_SERVER
                    Transfer-Encoding: chunked
                    Keep-Alive: timeout=60
                    Connection: keep-alive
                    Cache-Control: no-store
                    Content-Type: application/xml
                    Date: Wed, 22 Mar 2023...
Forms             : {}
Headers           : {[TeamCity-Node-Id, MAIN_SERVER], [Transfer-Encoding, chunked], [Keep-Alive, timeout=60],
                    [Connection, keep-alive]...}
Images            : {}
InputFields       : {}
Links             : {}
ParsedHtml        : System.__ComObject
RawContentLength  : 40400
0

Found that there was an invisible character pasted in with my token :( that fixed the auth issue.

I noticed an other issue. You can get an error that is hard to understand when running the migration tool:

Current target storage in project 'foo' is the same as the source storage

This is unclear since I clearly state in the application.properties I want the destination to be S3 bucket. What you need to do is update the TeamCity Project's Target Artifact Storage "Active" before you run the migration command. It makes sense but this is not documented.

0
Hi Blush,

Judging by the error, the migration tool can't see the token, as if the field is empty. The token is not rejected. Could you please double-check that there are no special or hidden characters on that line?
0

Hi Mikhail,

There was definitely an invisible character when pasting from Mac to Windows. This usually happens when I create a file from Powershell and forget to encode with UTF-8 but this time I just when 100% UI based. Still after deleting the line and pasting again it worked. Same token value same parameter value (I searched and compared and the original and new matched equally). So it must have been an invisible character like ^m or similar.

0
Hi Blush,

Glad to hear the issue is resolved.

Any other questions, just let me know.
0

Please sign in to leave a comment.