Custom condtition for "Suitable Builds"

Is there way to provide custom condition for the build to be "Suitable"?

Im using two configurations. One configuration produces artifacts for another but its not have a VSC Root. I need to build this only if there no build for specified version otherwise dependent configuration must use artifacts from last successful build

0
1 comment

Hi! It isn't possible to adjust the criteria for build suitability for snapshot dependencies described in the documentation. Still, in most cases, you can configure TeamCity for your scenario without having to adjust those.

As I understand, you are looking for some custom logic for deciding which build to download the artifact from. I am not sure I fully understand your use case, though. Here are my takeaways from the provided description:

  • The artifact-producer configuration has a VCS root attached, but the artifact-consumer configuration doesn't.
  • You specify the artifact version somehow when you run the consumer configuration.
  • You want the consumer to reuse a build of the producer if there is a build with the specified version of the artifact. Otherwise, the consumer should reuse the last successful build of the producer.

Assuming my understanding is correct, that should be achievable with a custom script. In such a scenario, the consumer will not "reuse" the builds of the producer but rather will download the artifact from the required build selected based on the logic specified in a custom script.
You can access the artifacts from a build with a given ID or the latest successful build using the patterns provided here.
How you determine the build ID may vary depending on how you specify the version and what you use as the version. Feel free to explain that if you need further guidance.

Alternatively, if you are willing to let your producer configuration run a new build if there isn't an artifact of the specified version, you can rely on snapshot dependency + artifact dependency on the build from the same chain. To make it work, do this:

  1. Consumer configuration settings > Version Control Settings > enable the 'Show changes from snapshot dependencies' option.
  2. Consumer configuration settings > Dependencies > add a snapshot dependency on the producer configuration.
  3. Consumer configuration settings > Dependencies > add an artifact dependency on the producer configuration, if it is not already added.
  4. In the artifact dependency settings, select 'Get artifacts from: Build from the same chain'.

I hope that helps!

0

Please sign in to leave a comment.