Problem with Maven Artifact Dependency Trigger
Hello,
I'm trying to set up an artifact trigger for Maven project. The artifact is stored in our local Maven repository. Repository is hidden behind https and requires authorization.
At first I was having issues with accessing it during the build process for dependency resolving. I added "-Djavax.net.ssl.trustStore=<path_to_jks>" to the JVM command line parameters of the build configuration.This helped and TeamCity was able to download all the dependencies and complete the build without any issues.
Then, I decided to add "Maven Artifact Dependency Trigger" for one of the dependencies and now I can see the following message "Unable to check for Maven dependency updates: Not authorized." In teamcity-vcs.log I can see the following:
[2011-11-10 15:04:52,100] WARN [prio executor 9] - MavenArtifactDependencyTrigger - unable to check for updates in Maven artifact <groupId>:<artifactId>:<packaging>:<version>[<Maven_Repository_URL>] for build configuration Project :: Build_name {id=bt4}: Not authorized.
Some additional info that may be necessary. $M2_HOME/conf/ directory does not contain settings.xml file. All the settings are set in ~/.m2/settings.xml of user that is running the server. I encounter this problem both on our production server which is running TeamCity Enterprise 6.0.1 (build 15816) and my test server which is running TeamCity Professional 6.5 (build 17795).
Can you please assist me?
Please sign in to leave a comment.
Up
Hello Andrew,
I apologize for the delay.
Can I ask you to add following line to internal.properties (see here http://confluence.jetbrains.net/display/TCD7/Configuring+TeamCity+Server+Startup+Properties):
teamcity.maven.settingsPath=<put the full path to maven settings.xml here>
and restart the server.
After this, please try Maven artifact trigger once again.
This is to make sure TeamCity uses correct settings.xml file while connecting to repository.
Hello Nikita,
Thanks for your reply. I did as you requested:
And as I already mentioned, there is no settings.xml file in the Maven home directory:
I also had to set the following property in order for TC to be able to download artifacts from our repository:
But the error is still there... I turned on 'debug-general' in server settings and in teamcity-server.log I can see the following:
At the same time when I launch the build, TC successfully checks for artifacts' snapshot dependencies (which are located in the local repository) and downloads them (if necessary) without any issues. And that is really confusing...
Hello Andrew,
Thank you for the logs.
Some questions to check, so I can further try to reproduce the issue on our side:
Are you using any type of client SSL authentication with your local repository?
What type of authentication (if any) is used by repository server? where are credentials stored?
Sorry for delay in my reply. We use LDAP authentication and all the credentials are stored on our LDAP server.
Does this help? If no, can you please specify some additional information so I could clarify this question with our sysadmins team.
Andrew,
In the first post you wrote "Repository is hidden behind https and requires authorization.". I'm interested in "authorization" part.
What kind of authorization do you use in your build to access maven repository? A username/password pair? Client-side certificates?
Credentials (username and password) are stored in $HOME/.m2/settings.xml file, <servers> section.
Usually, password is encrypted (http://maven.apache.org/guides/mini/guide-encryption.html), but I've also tried with plain password and result is the same.
Hello Andrew,
I apologize for the delay: I have not yet reproduced the issue - have some problems setting up the environment.
Meanwhile, could you please try using TeamCity 6.5.5 ? It is known to contain fixes relevant to environmental variables availability to Maven instance on TC server.
Hello Nikita,
No worries, I can wait =)
I've already tried 6.5.5. No luck, unfortunately.
Hi Andrew,
The problem doesn't appear to relate to https. We were able to reproduce this with the simple basic authorization. I'm taking over this issue.
Sergey, good to hear that! I'll be awaiting for the news then.
Hi Andrew,
Good news.
The problem is that TeamCity always creates a new repository record with id "_tc_temp_remote_repo" if repository URL is specified in the trigger settings. Obviously you don't have credentials in your settings.xml for this id. That's why requests fail.
To overcome that you have the following options :
1) add credentials for "_tc_temp_remote_repo" in your settings.xml. Not very good options because "_tc_temp_remote_repo" is shared between all triggers. Also this is an internal name that may change in the future.
2) If the trigger is attached to a Maven build configuration, you can leave repository URL empty. Then TeamCity will take the repository list from the project model with all their credentials. If TeamCity is able to read the model, of course. It's easy to check on the Maven 2 tab.
From your previous posts I can conclude you have set up a Maven configuration. So I suggest you the second option.
Please let me know if this helps.
Hello Sergey,
Removing the URL fixed the authorization problem, thank you!
However, the build doesn't trigger after the artifact is updated in repository. Here is the log snippet:
And this is when the artifact gets updated:
Maybe it's connected to the fact that this is a pom artifact? And if the contents haven't changed, hash shouldn't change either (if it's solely based on contents of the file).
Please note that I'm testing 7.0 EAP version. I haven't tried it on 6.5.5 yet.
You're right. Artifact trigger considers an artifact updated when its digest changes. In your case the digest hasn't been changed.
Ok, I see. I wanted to use this trigger instead of Finish Build Trigger, but it won't work this way. Do you have any plans to make triggers customizable via build parameters?
My use case is as follows. We have Core part of the system and several Components that depend on various modules of core part. For each of the pairs Component + Core I want to set up a template that would trigger the build when Core part has been updated (e.g. its snapshot has been deployed to local Maven repository). Since we have many versions of both Core and Components, it would be great to make custom configurations based on a template (that doesn't change) and build parameters (that do change), instead of manually specifying this trigger for each configuration.
Andrew, I think it is possible with the snapshot artifact trigger. When it's enabled it triggers a build each time any of its SNAPSHOT dependencies is updated. Did you try it?
I'm testing it at the moment. But the build doesn't trigger when the snapshot dependency is built.
I assume it may be using some sophisticated algorightm based on pom.xml analysis. Say, if project A has 3 modules A1, A2 and A3, project B depends on A2 module and if I make changes to A1 only and deploy all artifacts of project A to repository, the build won't trigger?
My question though is if you plan to add some customization to these triggers. Because at the present moment I have to manually bind each of "Component + Core" build configurations triggers to the corresponding "Core snapshot" configuration (using finish build trigger).
> Say, if project A has 3 modules A1, A2 and A3, project B depends on A2 module and if I make changes to A1 only and deploy all artifacts of project A to repository, the build won't trigger?
No, it won't. Nothing really sofisticated. As I mentioned before an artifact is considered updated if its content changes. The trigger simply collects all external SNPASHOT dependencies and checks each of them.
> My question though is if you plan to add some customization to these triggers. Because at the present moment I have to manually bind each of "Component + Core" build configurations triggers to the corresponding "Core snapshot" configuration (using finish build trigger).
Actually, the artifact trigger can be customized (to some extent). In the template you can define a trigger that will use config parameters (variables).
For example:
[in the template]
define an artifact trigger for: %groupId%:%artifactId%:%artifactVersion%
[in the build configuration 1 based on the template]
define config parameters:
groupId=someGroup1
artifactId=someArtifact1
artifactVersion=version1
[in the build configuration 2 based on the template]
define config parameters:
groupId=someGroup2
artifactId=someArtifact2
artifactVersion=version2
and so on.
But I think the snapshot artifact trigger suits your goals better.
Forgot to mention one more option - snapshot dependencies (a TeamCity term, not Maven).
The idea is to define snapshot dependencies between components and the core. In the template you can configure the VCS trigger to "Trigger on changes in snapshot dependencies".
This will cause building all dependent components on changes in the core with proper build ordering.
Ok, I see. Thank you for the explanation. Looks like snapshot artifact trigger is going to be the choice.
One last question. In "Build Triggering" I can set "Trigger on changes in shapshot dependencies" in "VCS Trigger" (as you suggested in your last post) and I can also add "Maven Snapshot Dependencies Trigger". My guess is that the first one detects a commit in snapshot dependency and triggers its build and then the dependant build. And the second one waits for snapshot dependency to be updated in the Maven repository and then triggers the dependant build. Is this correct?
In any case, I won't be able to add snapshot dependency to template because for each "Core + Component" version pair its going to be different (based on "Core" version, which is produced by specific build configuration of "Core snapshot").
> One last question. In "Build Triggering" I can set "Trigger on changes in shapshot dependencies" in "VCS Trigger" (as you suggested in your last post) and I can also add "Maven Snapshot Dependencies Trigger". My guess is that the first one detects a commit in snapshot dependency and triggers its build and then the dependant build. And the second one waits for snapshot dependency to be updated in the Maven repository and then triggers the dependant build. Is this correct?
In fact VCS trigger detects a commit in a snapshot dependency and triggers (puts to the queue) all the downstream builds simultaneously. But a dependant build won't go to an agent unless all its dependency builds finish.
You don't need to have both VCS trigger with "Trigger on changes in shapshot dependencies" and Snapshot Artifact Trigger activated since they do essentially the same thing. However VCS trigger in some cases works faster since it queues all the builds at once, while Snapshot Artifact Trigger queues builds one by one only when the upstream build finishes. This also means that Snapshot Artifact Trigger may cause unnesessary builds when you have multiple upstream builds.
> In any case, I won't be able to add snapshot dependency to template because for each "Core + Component" version pair its going to be different (based on "Core" version, which is produced by specific build configuration of "Core snapshot").
OK, I see
Thank you for the clarification. I guess this topic can be closed.
Just for traceability. This is the ticket for this issue - http://youtrack.jetbrains.net/issue/TW-19307