jfrog / teamcity-artifactory-plugin

TeamCity plugin that enables traceable build artifacts with Artifactory
https://www.jfrog.com/confluence/display/JFROG/TeamCity+Artifactory+Plug-in
Apache License 2.0
42 stars 47 forks source link

Difficulty correlating TeamCity build with artifact #30

Closed lionbee closed 6 years ago

lionbee commented 7 years ago

The build name that is assigned to the artifact is difficult to reproduce in TeamCity and makes build promotion difficult.

The problem is this line of code

runnerContext.addRunnerParameter(BUILD_NAME, build.getFullName());

Should be

runnerContext.addRunnerParameter(BUILD_NAME, build.getBuildTypeId());

That value returned by build.getBuildTypeId() is exposed as a variable in TeamCity %system.teamcity.buildType.id%. As far as I can see there is no way to get the value of build.getFullName() easily.

eyalbe4 commented 7 years ago

@thirty3, Do you have an example for the difference between the two values for a specific build?

lionbee commented 7 years ago

@eyalbe4

With a build configured as: Root -> Level 2 -> build

Where Root and Level 2 are projects: image

build.getFullName() will return Root :: Level 2 :: build. Using this value with the Artifactory API will have to url encode the value and use it as Root%20%3A%3A%20Level%202%20%3A%3A%20build

build.getBuildTypeId() should return the Build configuration ID as configured via the interface. In my case this is now Root_Level2_Build

eyalbe4 commented 7 years ago

Looks good @thirty3. Thanks for reporting this and suggesting this change! Will you be able to submit a pull request?

lionbee commented 7 years ago

@eyalbe4 Happy to do it 👍

It will break some people's integrations. Maybe a better approach is to expose build name as a parameter. If it is left blank carry on using build.getFullName(). Then users can set the name parameter to %system.teamcity.buildType.id% if they want?

eyalbe4 commented 7 years ago

Sounds good @thirty3. We can add to the UI, next to the Build-Info configuration parameters, a an optional text field named "Override deployed build name". What do you think?

lionbee commented 7 years ago

Yup, sounds perfect 👍

pavelsher commented 6 years ago

Just to clarify. Parameter %system.teamcity.buildType.id% contains user visible id of a build configuration (so called external id). But SBuild.getBuildTypeId() returns internal id. There is also SBuild.getBuildTypeExternalId() and this is external id which should be used instead of build.name.

Also, as of 2018.1, getFullName() generates names separated with slashes, instead of :: as it was before. Apparently this causes problems with Artifactory plugin: https://youtrack.jetbrains.com/issue/TW-56014

Unfortunately we can't revert behavior of getFullName(), so maybe it's time to use external id?

TCAgentUser commented 6 years ago

I am the reporter of the issue Pavel Sher links, and currently this functionality is breaking our setup. So all our automated tests are not able to run as they have dependencies that are downloaded via filespec.

Is there a way to get even a nightly build with the suggested changes where builds are linked via the externalid?

Best regards Lars Jakobsen

jetersen commented 6 years ago

@pavelsher thanks for the advice, we implemented use of external id in #47 😅