Maven 3.6 How to resolve the latest artifact for a deployment job? - maven

I've got a deployment module with its own pom.xml. I use the module to deploy a 'module' and its version.
Modules are built by bamboo and pushed into the local repository of the agent (we haven't got nexus or artifactory yet so currently using the local repo).
When it's time to deploy, I would want to pass the module name and something to fetch me the latest version in the repo.
In ivy, I can use latest.integration or latest.release. However, I am not sure why maven does not allow it or at least not anymore.
So the plan is to use the LATEST version if we don't explicitly request any version.
How would we do this?

Actually, using LATEST as version would fetch the latest one.

Related

How to download the latest artifact from artifactory repository using teamcity via artifactory plugin

I'm trying to download the latest version of an artifact from JFROG Artifactory repository present in a common folder using the artifactory plugin in Teamcity.
Following is how the artifcatory repository looks like
My_Repo/my_tool
1.0/too1.zip
2.0/tool.zip
3.0/tool.zip
4.0/tool.zip
5.0/tool.zip
I tried using the following syntax in the artifactory plugin of teamcity but neither of them work in downloading the latest artifact.
Under "Custom build dependencies:"
My_Repo:my_tool/#LATEST
My_Repo:my_tool/LATEST
Currently I should download version 5.0 of the tool but if there is a new version 6.0, that should get automatically downloaded as soon as it is available and I do not want to hard-code the version number in my Teamicty jobs.
Can any of the experienced users of teamcity shed some light on how to achieve this.

Maven ssh deployment overrides artifacts in nexus - Can this be prevented?

we are using the Maven Wagon SSH and Wagon SSH External plugins to deploy to our nexus repository. This way artifacts in the nexus can be overridden.
Is there a way to prevent this on the maven side? Or do we have to change either the wagon or the file system permissions for the artifacts?
I would suggest you to use the deploy command or use maven-release-plugin. With the plugin you can prepare your pom.xml to next version and it will commit these changes to your version control (git,svn). Then you can run perform command to build prepared version and deploy it into the nexus.
The point is you can re-deploy your working snapshot version (that ends with -SNAPSHOT) as much as you want. But you can deploy version WITHOUT snapshot only once. That ensures you the release version wont be overridden this way!
The problem is you have to update your version manually or you will use that mentioned plugin.

Jenkins - get latest artifact version from remote repository

I'm trying to create a deploy job in Jenkins. Up until now I was building my artifact via the maven install goal and then deploying it on the application server with a shell script. However, I'd now like to skip the install part and just get the artifact from my nexus repository.
I know there is the maven dependency:get which I can use to retrieve the artifact from the repository but is there any way I can make sure I'll get the latest version without passing it as a build parameter?
You have different options:
1) Use the Repository Connector Plugin. With this plugin, you get an additional "Artifact Resolver" build step, where you can download an artifact from a centrally configured (Manage Jenkins) repository to the workspace of your deploy job (with different options like renaming etc).
If you use the version LATEST, you always get the latest version. Likewise, you can use RELEASE for the latest release version or ranges like [1.0,1.1).
There are two caveats however:
In the newest version of the plugin, LATEST is broken (see https://issues.jenkins-ci.org/browse/JENKINS-20263), so you need to use version 0.8.2 for now).
You should manually fingerprint the downloaded artifact, since this is not automatically done right now.
2) Use dependency:get as suggested, but use LATEST or RELEASE as above. However, I do not think this is a really elegant solution. (if you simply use SNAPSHOTs with the same base version, follow khmarbaise's advice and simply add -U to the commandline)
3) Use the Maven Deployment Linker Plugin plugin, which is a rather elegant alternative, since you can copy artifacts from other jobs like Copy-Artifact, but they are still retrieved from your Artifact repository (thus you do not waste diskspace and time). The largest problem with that plugin is that it currently does not support authentification.

Importing a snapshot version of a dependency into Maven repository

I am having trouble importing dependencies for my Grails project into the company Nexus repository. The Grails plugin I would like to use is events-push (https://github.com/smaldini/grails-events-push). The latest released version of the plugin is 1.0.M7. It uses a very old version of Atmosphere library. The GutHub repository contains a more up-to-date version of events-push plugin, 1.0.0.BUILD-SNAPSHOT. I built the Grails plugin from the local clone of the repository and got it to work in my dev environment.
To deploy it on the intranet (in the production environment) I need to import all the plugin dependencies into the company Nexus repository. This is where I run into trouble. The project depends on a SNAPSHOT version of events-push plugin, which in turn depends on SNAPSHOT version of other Grails plugins and Java libraries (according to dependency report).
Nexus supports two types of repositories, Release and Snapshot. I can add artifacts to a Release repository (through the browser UI or in a batch mode using curl), but the artifact must not be a snapshot. I can change the repository to be a Snapshot repository, but then I lose the ability to add artifact to it through the browser or curl command.
How do I make these SNAPSHOT artifacts available to the Grails project through Maven?
Change them to a release version and deploy them to the release repository.

How do I get my Nexus repo to download a more recent artifact?

We have a Nexus repository on my local network that is managed by a different team and I use it as a local mirror of Maven-central . My Gradle 1.7 build script is trying to download a set of "Selenium 2.35.0" artifacts from the Nexus server (which is setup as a mirror in my .m2/settings.xml file) but it times out and fails. There are 2.33.0 artifacts on the server though.
Is there a command I can issue from the command line to trigger the Nexus server to cache the latest version of Selenium? OR , is this something the Nexus admin has to do?
Gradle doesn't work with .m2/settings.xml.
You need to define your Nexus in gradle script itself (using repositories{} closure).
Nexus is a caching proxy. It won't download the newer version unless someone asks for the newer version.

Resources