Promoting and applying properties on a custom dependency?

If I get custom dependencies from another job via artifactory.  How do I easily apply properties to them from the consuming job?

Lets say I have a custom dep that is using the @B
Custom build dep:
repo-local:com/company/product/files/**/*@Build :: Name#LATEST

which results in a bunch of files under files that are version specific, which is resolved via the LATEST specified above.

the only thing I can think of is using custom published artifacts to republish the files back to the same location with additional properties.

**/*somefilenamepattern=> com/company/product/files/**/;prop=val1

But this is troublesome because I can’t really know what version folder is from the job and the full version from within the tc job(only at runtime of the build) so it leads to having to use ** patterns all over. (not even sure if this would work)

Is there a nice mechanism that I am missing to be able to reference the resolved build name and build number from the running job? 

Thank you for your help!
--dave

6 comments
Comment actions Permalink

This also sorta relates to my other comment on another post:

https://teamcity-support.jetbrains.com/hc/en-us/community/posts/206818195-Is-it-possible-to-loop-through-dependencies-properties-?page=1#community_comment_115000248790

Is there a way to iterate over the deps that are resolved from within the custom script?

0
Comment actions Permalink

Hi Dave,

I've been checking your previous threads and your comments and I'm still uncertain of what your exact goal is. From some of them, it seems you are just trying to retrieve parameters from dependencies, in which case you can reuse them through the dep.<build_config_id>.parameter_name, but in other post you seem to be trying to extract the build ID out of a name of a file in artifactory.

How are you getting the dependencies from artifactory? If that's an ability from the artifactory plugin, I'm afraid I can't really help with that, you would need to contact the artifactory developers asking them how to do it, or to provide that kind of parameters/utility.

The Build Number/ID are parameters from a given build. If it's configured as a dependency, you can access them via the dep.<id>.parameter, as mentioned above, but you need to know which build configuration produced it, and its external ID.

If I'm missing something, it would be useful if you could explain your whole use case/workflow, and what exactly you are trying to achieve.

0
Comment actions Permalink

I guess what I am trying to describe in this ticket is related to the artifactory resolution which is a function of the artifactory plugin.  @Build :: Name#LATEST gets resolved to a set of files in the build and I want to act upon the set of files/builds resolved after the resolution happens.  I was hoping that this would be a common issue, but maybe its not.  I'm sorry if you do not support this plugin and I will need to research the code myself and try and follow up with the developers....  The question in relation to the plugin is how to resolve a custom dependency in artifactory and then resuse that dependency information to promote/tag the dependency within artifactory. 

With regard to the other question/comment about trying to iterate over the dependency information.  Lets say you want to list out all the dependencies that are coming into a job, I know that I can within the editor %dep.<id>.parameter% to get that information in the script, which requires that you actually type out the %dep.<id>.parameter% in the custom script with each additional dependency added.  I would like to figure out a way to actually list all the dependencies that are defined on the job without having to statically maintain those dependency names in the script.  I want to iterate over the dep.* variables and place that information in a text file.

I hope that this clarification helps.

0
Comment actions Permalink

Hi Dave,

The artifactory question then I'll leave to artifactory. Regarding your "iterate over dep.*" question, we don't provide anything built in in TeamCity to do it, although in the Build Result page - Parameters tab, you can have direct access to all the dependencies parameters.

If you run it through a script, you can call the REST API that returns all transitive dependencies for a build, then retrieve all the "properties(property)" fields for all the builds, which will contain their parameters:
https://confluence.jetbrains.com/display/TCD10/REST+API#RESTAPI-Snapshotdependencies

0
Comment actions Permalink

Denis,
This does not work for artifact dependencies and there is no way to retrieve that information without statically defining the replacements within the custom script.

curl https://teamcity:8543/app/rest/builds?locator=snapshotDependency:(to:(id:123),includeInitial:true),defaultFilter:false
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<builds count="1" href="/app/rest/builds?locator=snapshotDependency:(to:(id:123),includeInitial:true),defaultFilter:false">
<build id="123" buildTypeId="BUILD_Type" number="17" status="SUCCESS" state="finished" href="/app/rest/builds/id:123" webUrl="https://teamcity:8543/viewLog.html?buildId=123&amp;buildTypeId=BUILD_Type"/></builds>

This makes it very hard to produce lists of all the resolved dependencies within a build.

0
Comment actions Permalink

Hi Dave,

For artifact dependencies, the paragraph below snapshot dependencies in the docs explains how to use it: https://confluence.jetbrains.com/display/TCD10/REST+API#RESTAPI-Artifactdependencies

Be mindful that while snapshot dependencies are a Directed Acyclic Graph, artifact dependencies allow for cycles, so if you have a cycle configured, it might be problematic.

I don't know what you mean with "defining the replacements". Replacements for what?

0

Please sign in to leave a comment.