JetBrains / teamcity-pipelines-dsl

Experimental Kotlin DSL library for TeamCity pipelines
Apache License 2.0
40 stars 20 forks source link

VCSRoot "useMirrors = false" will always be overwritten #7

Open swalsberger opened 4 years ago

swalsberger commented 4 years ago

Hey there,

i am using the pipeline dsl for some of my projekt an have a issue, where my centos docker container, on my windows agent cant access the path in the ./git/objects/info/alternates (directing somewhere on the windows VM, C:\BuildAgent.... )

i can fix this by enabling the "use mirrors" flag in the VCS root.

But for the pipeline script, it will be overwritten after settings are synced.

my VCS root in my settings.kts looks like this

object MyVCS: GitVcsRoot({
    name = "project name"
    url = "gitlab url"
    branch = "master"

    useTagsAsBranches = true
    useMirrors = false

    branchSpec = """
      +:refs/heads/(*)
      +:refs/tags/(*)
    """.trimIndent()

    authMethod ...

})

Any idea why this flag is always set to true?

swalsberger commented 4 years ago

Teamcity Version 2019.1.2

karanagai commented 4 years ago

Hi @swalsberger do you keep the versioned settings of this project in the same repository?

swalsberger commented 4 years ago

Hi @karanagai yes, it is stored in the .teamcity directory

swalsberger commented 4 years ago

our setup looks like this .teamcity/settings.kts .teamcity/pom.xml .teamcity/libs # imported as a submodule an contains all our builTypes we use in the settings

karanagai commented 4 years ago

@swalsberger it seems you are using portable DSL. TeamCity assumes that the VCS root is not defined within the DSL, but only present in the project configuration in TeamCity data directory, and tries to ignore such a definition if it comes from DSL.

The corresponding VCS root must be editable via UI though and editing such a VCS root will not produce DSL patches. So the simplest solution is to set the corresponding setting via admin UI. To keep your DSL cleaner you could then remove the VCS root definition from your DSL and change all references to it in DSL to DslContext.settingsRoot.

If you still want to configure the VCS root that keeps your source code from DSL you could store versioned settings in a separate repository, which is generally advisable anyway.

swalsberger commented 4 years ago

@karanagai I removed GitVcsRoot Object from the settings.kts and replaced the instance with DslContext.settingsRoot -> works

("admin UI" did you mea the "Edit Project Settings" in the Project, or is there a special are in the admisitration area?)

in the UI, i disabled the versioned settings edited the VCS Root (disabled the Mirror flag) enabled versioned settings again -> choosed export to VCS in the popup (import overwrites the flag)

The Flag stays to false now, but i guess the settings are not updated anymore Beacuse of this error/info message in the "current status:" on the Versioned Settings section

Cannot find previous revision of project: [MyProject], skip updating settings to revision 212681ece8b2c2b78156cd39d06c5a32dfc208e8. 

.

If you still want to configure the VCS root that keeps your source code from DSL you could store versioned settings in a separate repository, which is generally advisable anyway.

Our settings.kts is quiet small. it contains only the project {} settings with the order and sequence of our BuildTypes (these types are stored in a separate repo an will be imported via submodule) . The settings.kts is in our Repos, because we have some parameters inside, so we can change these for each project separately.

orsenthil commented 3 years ago

ping. I tried to follow the instructions in this bug report. Changing settings in UI for VCSRoot while keeping the version settings is not working. Specifically, I wanted to turn-off useMirrors option, but it keeps turning ON.

karanagai commented 3 years ago

@orsenthil Hi! Are you using portable DSL? Is this the same VCS root that is used to store versioned settings in your project? Also which version of TeamCity are you using?

orsenthil commented 3 years ago

Hi @karanagai , yes I am using portable DSL and yes, same VCS root is used to store the versioned settings. And we are using TeamCity Enterprise 2020.1.4 (build 78906)

orsenthil commented 3 years ago

This seems like a teamcity bug https://youtrack.jetbrains.com/issue/TW-71566 that will be resolved in a higher version of Teamcity (2021.1).