Closed pedropombeiro closed 10 years ago
I'm investigating this right now, I'm trying to see how to access a 'resolved' parameter. There must be some class in TeamCity that lets you do this, but their documentation is really hard to dig through. I'm sure it's there - they wouldn't want plugin developers doing the %STRING% replacement themselves, surely.
Thanks, I know exactly what you mean. JetBrains writes awesome tools, but unfortunately they don't always take the time to document the APIs. Maybe you could try to get hold of one of the developers or product owner on Twitter. They are normally responsive.
By the way, thanks a lot for writing such a useful plugin!
I've posted a thread here
I've also found a method that seems to work, but not entirely sure if it is the right way to do it. For now, I've put that into branch issue14
.
Here is a zip, can you test it out?
If the thread is updated with the proper way to do it, I'll probably redo the zip as well.
I tested it with both URL and username as variables and it didn't work. Did your fix address both fields, or only URL?
What version of TeamCity do you use? I tried this with 8. Also, you need to stop TeamCity before copying the new plugin zip over, then restart TeamCity.
A bit of my setup:
Build Params:
Build Feature screen:
I used http://%stash.hostname%:%stash.port%/
just to be awkward and ensure that multiple values would get resolved if necessary.
And the result in catalina.out:
Edit: Just tried in TeamCity 7.1.5 as well, seems to work fine
I'm using 8.0.5. I didn't restart though, since I noticed it extracted the zip immediately. I will try that then. Le 10 janv. 2014 08:41, "mendhak" notifications@github.com a écrit :
What version of TeamCity do you use? I tried this with 8. Also, you need to stop TeamCity before copying the new plugin zip over, then restart TeamCity.
A bit of my setup:
Build Params:
[image: image]https://f.cloud.github.com/assets/746276/1885353/344fe6c6-79ca-11e3-8e18-5cf813165d67.png
Build Feature screen:
[image: image]https://f.cloud.github.com/assets/746276/1885358/51c4cf28-79ca-11e3-976f-5a736d7f8ef8.png
And the result in catalina.out:
[image: image]https://f.cloud.github.com/assets/746276/1885362/64366b9e-79ca-11e3-9f0b-febb4e94f0d5.png
— Reply to this email directly or view it on GitHubhttps://github.com/mendhak/teamcity-stash/issues/14#issuecomment-32008583 .
I guess I'll merge this one then, I guess it's working? It worked in the testing I did so I'll do this shortly unless you say there are other problems but I could do another fix for that.
Yes, I'm only unsure if the user name too can be replaced by a variable (I would also like to have it as a variable). Le 16 janv. 2014 19:45, "mendhak" notifications@github.com a écrit :
I guess I'll merge this one then, I guess it's working?
— Reply to this email directly or view it on GitHubhttps://github.com/mendhak/teamcity-stash/issues/14#issuecomment-32504247 .
You should be able to replace username as well as server with parameters.
Is this meant to work with the password too? I tried the latest zip from http://code.mendhak.com/teamcity-stash/ with teamcity 8.1.4 and it didn't appear to work :-(
TBH I would prefer to set all these settings at the project parent level - do the build feature APIs provide any way to supply defaults at that level?
It's looking a lot like it's not supported for passwords? Is that deliberate?
if (feature.getBuildFeature().getType().equals(StashBuildFeature.FEATURE_TYPE)){
ValueResolver resolver = build.getValueResolver();
parameters.put(keyNames.getServerKey(), resolver.resolve(feature.getParameters().get(keyNames.getServerKey())).getResult());
parameters.put(keyNames.getUserNameKey(), resolver.resolve(feature.getParameters().get(keyNames.getUserNameKey())).getResult());
}
Looks like I forgot to press 'comment' yesterday. :grin:
Indeed that is the correct part of the code you're looking at; only the URL and the username are resolved there.
I haven't tried it with passwords so I don't know if that would work. I am not in front of a development machine right now so I'm not sure when I can try it. If you're willing you could give it a go, that would be very helpful too.
To answer your other question, as long as the top level param appears in %
autosuggest, it should work.
I've just parameterized the password field; I set a root level username and password param and it was read by the resolver. Try the latest zip:
https://github.com/mendhak/teamcity-stash/blob/master/teamcity.stash.zip
Cool Did you consider using the simpler JetBrains suggestion that they mentioned on that thread?
Or even better you can acquire BuildFeatureDescriptors like this:
buildType.getResolvedSettings().getBuildFeatures()
in this case all the parameters in the descriptors will be resolved.
?
I've submitted a pull request to this end BTW https://github.com/mendhak/teamcity-stash/pull/23/files
@bacar's pull request has been merged, latest zip is at the same link
https://github.com/mendhak/teamcity-stash/blob/master/teamcity.stash.zip
Please test, let us know in this thread if it's working as expected
Awesome, should be able to try this week.
On 28 September 2014 17:07:56 BST, mendhak notifications@github.com wrote:@bacar's pull request has been merged, latest zip is at the same link https://github.com/mendhak/teamcity-stash/blob/master/teamcity.stash.zip Please test! —Reply to this email directly or view it on GitHub. {"@context":"http://schema.org","@type":"EmailMessage","description":"View this Issue on GitHub","action":{"@type":"ViewAction","url":"https://github.com/mendhak/teamcity-stash/issues/14#issuecomment-57090102","name":"View Issue"}}
I'll also be looking to use the password feature, thanks for that :+1:
Uploaded to server. Do you know if I need to bounce? (don't want to do it during the working day) And, do you know if I need to clear out the <TeamCity Data Directory>\.unpacked\teamcity.stash
directory first? (This appear to be where teamcity unzips the plugin).
You'll need to restart the TeamCity service. When it restarts, TeamCity automatically unzips and overwrites the directory you mentioned.
I tried changing the Stash URL to use a variable called %stash.url% which points to the real URL, but the integration stopped working. My best guess is that this variable is not expanded before being passed to teamcity-stash, and therefore the Stash server is not reached. Unfortunately there is no output on the build log to determine what is going on.
If I use the URL instead of a variable, the integration works fine.