Native Gradle build: why are artifact dependencies getting deleted?

Answered

New to TeamCity, migrating from a different CI product, and trying to figure out how to configure a working build for a c++ project on version 9.1.6.

The problem I'm having is that the agent is deleting my dependency directories right before (or during) the component build, and I can't find a record of why this is happening anywhere in the build log.

The build layout for any component in the system looks like so:

<base-dir>

      |

      |------<to-be-built>

      |-------<dependency-1>

                      |-------Include

                      |-------Lib

      |-------<dependency-2>

                      |-------Include

                      |-------Lib

 

...so, whatever the checkoutDir is for the <to-be-built> component, it is assumed that all dependencies will be found in peer directories, named after the dependency, with no version information in the folder name.

For example, if version 3.0.2 of "MyExe" depends on version 1.1.0 of "SomeLibA" and version 2.1.0 of "SomeLibB", the file system should look like so:

MyExe_3.0.2

      |---------MyExe

      |---------SomeLibA

      |---------SomeLibB 

 

So, to create this build layout, the build configuration for version 3.0.2 of "MyExe" has specified a custom checkout directory like so: "MyExe_3.0.2/MyExe".

So far, so good. The dependencies are configured as artifact dependencies and their destination directory is specified as '../<dependency-name>'. This also seems straightforward.

When I kick off the build, though, I see the to-be-built component being retrieved, then I see the dependencies arrive, and then the gradle task I've configured for the build runs, and right at that moment, or just before, all of the dependency directories get wiped out, and of course the component can't find any of its dependencies' include files and compilation fails.

I've turned off 'Clean all files in the checkout directory' on the component and 'Clean destination paths before downloading artifacts' on all dependencies, but this has no effect.

I've only found 2 hints possibly related to this behavior, but I'm not sure why either of them would be causing this problem.

The first is a little warning symbol on the Version Control Settings tab for "MyExe" which says "This directory might be cleaned by TeamCity before the build", referring to the custom directory. But, the directory that's getting cleaned out during the build run is not the checkout directory, it's the checkout directory's parent directory.

The only other possible candidate I can find is that the gradle task I've configured isn't the only task specified when the build runs. Instead of seeing "gradlew.bat myGradleTask" in the build log, I'm seeing "gradlew.bat --init-script C:\TeamCity\BuildAgent\plugins\gradle-runner\scripts\init.gradle myGradleTask".

But, I've looked through that init script, and didn't see anything related to directory cleanup.

Does anyone have an idea what is going on, and how to work around it so this build can complete successfully? Acceptable solutions have to preserve the build layout requirements above.

1 comment

So, it appears I was a victim of the Automatic Clean Checkout feature, which apparently goes into effect whenever the checkbox for 'Clean all files in the checkout directory before the build' is disabled.

 

https://confluence.jetbrains.com/display/TCD9/Clean+Checkout

 

0

Please sign in to leave a comment.