mendhak / teamcity-stash

TeamCity - Stash integration. Plugin for TeamCity which updates Stash with build statuses
https://code.mendhak.com/teamcity-stash/
54 stars 17 forks source link

Plugin does not seem to work with TeamCity parameters #14

Closed pedropombeiro closed 10 years ago

pedropombeiro commented 10 years ago

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.

capture

mendhak commented 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.

pedropombeiro commented 10 years ago

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!

mendhak commented 10 years ago

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.

pedropombeiro commented 10 years ago

I tested it with both URL and username as variables and it didn't work. Did your fix address both fields, or only URL?

mendhak commented 10 years ago

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

Build Feature screen: I used http://%stash.hostname%:%stash.port%/ just to be awkward and ensure that multiple values would get resolved if necessary.

image

And the result in catalina.out:

image

Edit: Just tried in TeamCity 7.1.5 as well, seems to work fine

pedropombeiro commented 10 years ago

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 .

mendhak commented 10 years ago

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.

pedropombeiro commented 10 years ago

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 .

mendhak commented 10 years ago

You should be able to replace username as well as server with parameters.

bacar commented 9 years ago

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?

bacar commented 9 years ago

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());
            }
mendhak commented 9 years ago

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.

mendhak commented 9 years ago

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

bacar commented 9 years ago

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.

?

bacar commented 9 years ago

I've submitted a pull request to this end BTW https://github.com/mendhak/teamcity-stash/pull/23/files

mendhak commented 9 years ago

@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

bacar commented 9 years ago

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"}}

johnhilberts commented 9 years ago

I'll also be looking to use the password feature, thanks for that :+1:

bacar commented 9 years ago

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).

mendhak commented 9 years ago

You'll need to restart the TeamCity service. When it restarts, TeamCity automatically unzips and overwrites the directory you mentioned.