How do I clear teamcity's maven dependency repository/cache - maven

I have a teamcity server and I have maven dependencies which have changed but who's versions have not changed. From what I can tell this is causing my build to fail because teamcity is not updating these dependencies.
So I need to know how to clear out teamcity's maven dependency cache for my project. I looked through the documentation and didn't find anything significant.
Thanks!

Rather than trying to manually clear the local Maven repository on the server running Teamcity, it may be easier to force an update of the Maven dependencies in the Teamcity settings.
To do this, edit the settings for the Teamcity project (in the Teamcity frontend select the project and then select the 'Settings' tab). Next click the 'Edit Configuration Settings' link (top right) and then click the 'Build Steps' link on the right hand side. In here, edit the step responsible for compiling the code. On this form, in the 'Goals' field, add the argument -U (that's an uppercase 'U').
Save the settings and kick off a new build. That extra argument will force Maven to go and update its dependencies.
Going forward, if the dependencies are changing but their versions are not, you may be better to have their versions set as SNAPSHOT. See What exactly is a Maven Snapshot and why do we need it?

Found mine at /opt/buildagent/system/jetbrains.maven.runner/maven.repo.local.

I found mine in /opt/TeamCity/buildAgent/system/sbt_ivy/cache/, But if you can SSH to your machine, just run sudo find / -name "sbt_ivy" and you'll see the address of ivy in your machine (if you use SBT as I do)

You can actually go to Version Control Settings and there is a checkbox "Delete all files in the checkout directory before the build".

Related

Intellij IDEA 2019.2: Set the maven home directory "globally" for all projects

Every time I clone a repo I have to manually set the maven home directory under File->Settings->Build, Execution, Deployment->Build Tools-> Maven-> Maven home directory which is very annoying. I searched jetbrains forums and there is only an option to configure the IDE for FUTURE projects which under circumstances can never be a fact. Cloning a repo into idea projects is not creating a new project and therefore the global settings do not get triggered. How can I do this? Btw it not only applies to Maven home dir but also Code Style settings and many other more - see here
IntelliJ IDEA doesn't have a feature to propagate any setting to all the existing projects. A request is welcome.

Getting Maven to Report Which File Has Local Modifications

I have a Jenkins job that builds a simple Maven project. If all I do is build, it works just fine. The problem arises when I try and do a release, dry run or regular. It consistently fails with the Cannot prepare the release because you have local modifications error. I have wiped out the workspace, but the problem persists. Is there any way I can get Maven to tell me which file it thinks has been modified? I would assume that by wiping out the local workspace and immediately running the dry run release that there wouldn't be any opportunity for anything to get modified.
Please note, I do not have access to the Jenkins server or the slave that is running the actual release build, so I can't use any tools there (like SVN) to determine what is supposedly modified.
You can use the Maven SCM plugin to do a diff.
https://maven.apache.org/scm/maven-scm-plugin/diff-mojo.html
Basically, integrate the maven plugin upstream of the failure, and see if anything has been changed. I imagine you might be able to see the output in the log, but if you cannot, you might be able to move your "real" maven pom.xml aside and replace it with one that generates a diff file and with the help of the maven build helper plugin, attaches that file as an additional aritfact (to a pom target).
It turned out the solution to my problem was to not use the "Local to the workspace" strategy for my private Maven repository in the Jenkins job configuration. By changing that to the "Local to the executor" strategy the problem went away. I'm still not sure why it was having the problem in the workspace, but this solution resolved it form me, and might work for others.

Intellij does not displays repos on auto complete drop down

I am new to maven and I wanted to try it out and I decided to choose Intellij IDEA IDE for this task.
I tried to follow few video tutorial to create simple spring project with maven. But I happen to notice that, while creating dependency on pom.xml file I could not get auto complete for packages that are present on .m2 directory inside my user home directory.
But I can see two item in autocomplete dropdown, one being the self project and other maven-clean-plugin for artifactId
I could not come up with any solution for this. May be this will not affect my development, but I got stuck with this issue and wanted to know what really happened.
I am more than happy to clear myself further if what I am asking is unclear :)
When auto-completing maven dependencies, IDEA uses an index it generates to know what dependencies are available. Go into Settings (Ctrl+Alt+S / ⌘,) > Build, Execution, Deployment > Build Tools > Maven > Repositories. Your local repository should be listed. Select it and click Update for IDEA to update the index on it. It will take a bit of time. The progress will show on the center-right of the bottom status bar of the main IDEA window. If you use a repository manager, like Sonatype's Nexus, you should add it in the "Artifactory or Nexus Service URLs" section in the lower pane. Maven central will also likely be shown. You should update its index as well.
Click the Help button on that settings dialog for more information.

How to configure Teamcity to build a project which is a plugin of a different project?

I have a project which is a plugin for an opensource system. In order to run a CI build for the plugin, it needs to be installed into an existing instance of the main opensource system. I have mostly got this working, however, the install procedure for the main system is long and complex, so the build takes forever. It is also awkward to set up as checking out the plugin from git always happens first, whereas it needs to happen after the main system has been put in place so that the right directories are there. The solution I have right now is to use a shell script for the install and then an Ant task for the build, ignoring built-in VCS altogether. Feels hacky, though.
Two solutions come to mind:
Have a persistent install of the main system in the build directory, which the plugin is added to at the start of the build, and removed from at the end. I didi this ith Jenkins and it worked OK, but we are now using TeamCity.
Have some sort of parent-chid relationship between two CI projects, so that the main one is built and then triggers the plugin one, which is built within it. This would allow the main one to be rebuilt whenever it needs to be and avoids the awkwardness of keeping an install of the main system clean between builds.
However, I don't know enough about TeamCity to know if this is possible. Has anyone ever done something like this before?
For your solution number 2 you can try to use the "Build Triggers" configuration, the "Finish Build Trigger" option should resolve your parent-child relationship very well.
In TC, go to your plugin's build configuration, in "Configuration Steps" section select "Build Triggers" (number 5), then select "Add New Build Trigger" and configure "Finish Build Trigger" selecting your main system's build configuration.
To use parent directory in child one, you'll need to use the "Artifact Dependency" (see "Dependencies" section in "Configuration Steps", maybe setting some snapshots between the build configurations too.
Artifact Dependencies:
artifact Dependencies provide you with a convenient means to use the
output (artifacts) of one build in another build. When an artifact
dependency is configured, the necessary artifacts are downloaded to
the agent before the build starts.
Snapshot Dependencies: by setting a dependency of a build (e.g. build B) on other build's (build A's) sources, you can ensure that build B will start only after the one it depends on (build A) is run and finished
Configuring Finish Build Trigger:
finish build trigger triggers a build of current build configuration if a build of selected build configuration is finished

Missing Maven goals when using m2e from Eclipse(Juno)

I am having a problem with selecting Maven goals after a clean install of Eclipse (Juno) and m2Eclipse on a Windows 7 machine. M2Eclipse was installed via the Eclipse marketplace.
I've generated a very simple application via the Eclipse wizards. I have selected the Run as.../Maven build... option from the context menu then clicked on
Select to obtain a list of goals. However, the list is empty.
I then followed the instructions in this post which described my problem exactly:
Empty maven goals list
Unfortunately this does not work for me: the list is still empty.
If anyone has any ideas as to what else I can check I'd be obliged.
Many thanks
That's normal behavior ... just type in the goals you want to run. EX., clean package
According to the m2e developers, it is supposedly a feature that wasn't implemented fully. A lot of users are suggesting the button just be removed. I would just ignore it and enter them manually, pretending the button doesn't exist.
See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=344997

Resources