I'm trying to replicate a Jenkins production need in my lab, and it involves fetching/pulling files from Github & Nexus 2, building with ant/gradle, then publishing to Nexus. The Github part is working fine in my Jenkins pipeline, but I'm having some issues with the syntax/reqs for Nexus. I installed Nexus OSS in my lab to duplicate Nexus 2's functionality. I am able to upload files manually to the repo using curl, and I'm sure I can use it to download as well. This doesn't seem like the best or most efficient option however, if there will be multiple files.
I keep seeing references to Maven/pom.xml on all my searches for this topic, but I can't find a good primer on how to use them in this context. Would a pom.xml file be the best option for
this Jenkins/Nexus configuration and the requirements? Also, how close are Nexus 2/3 in functionality to Nexus OSS? Will I be able to port over the code for use with nexus 2 fairly easily?
Related
I've seen Building and deploying native code using Maven - but can't get this (very similar) deployment working as I'd like..
I have a C++ project that builds with Maven, and the Maven CMake Plugin. This involves several Maven profiles, to select the correct settings for the various C++ compilers I use on the platforms I'm building on. (Windows 10, Ubuntu 16.04, Ubuntu 18.04, CentOS 7, Raspbian, macOS High Sierra). I use Jenkins to run this build on the various VMs/Raspberry Pi - yielding a .tar.gz or .zip via the Maven Assembly Plugin. The final result is six archive files, that vary in their classifier/type. They all have the same groupId/artifactId.
I wanted each of these jobs to deploy its archive to Sonatype's OSSRH Nexus system, using the nexus-staging-maven-plugin.
I had this plugin configured to not automatically close the repository, so that the multiple builds could run via Jenkins (sequentially), and deploy to the same repo. I would then review this in the web UI, then Release or Drop it appropriately.
This worked fine, when the project had a version number of 0.0.1-SNAPSHOT. However, when I decided to (manually) release this, by setting the version to 0.0.1, and run my Jenkins builds... the deployment behaviour was different to what I'd seen when it was a SNAPSHOT.
Each platform-specific deployment created its own staging repository in the OSSRH Snapshots repo.
After reading https://github.com/sonatype/nexus-maven-plugins/tree/master/staging/maven-plugin, I have tried a variety of these settings, but nothing seems to work:
<skipStagingRepositoryClose>true</skipStagingRepositoryClose>
<skipStaging>true</skipStaging>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
<stagingRepositoryId>${project.artifactId}-${project.version}-repo</stagingRepositoryId>
The nexus-staging:rc-open goal looks like it might help, allowing me to open a named staging repository (as I tried to do with stagingRepositoryId, above) - but it requires a staging profile id - I've used the rc-list-profiles goal to find mine - but when I give this to rc-open, it's reported as "missing or invalid".
It looks like this should be possible: https://github.com/sonatype/nexus-maven-plugins/blob/master/staging/maven-plugin/WORKFLOWS.md - this suggests that you can't create a new staging profile id; that they're allocated by Nexus.
Why is this mechanism different between SNAPSHOT and non-SNAPSHOT deployments?
Kind regards, Matt
I've updated https://stackoverflow.com/a/40954957/14731. Per point 6.6, SNAPSHOTs cannot be released atomically. There is no known workaround.
We run a Nexus 2.14 with a site repository. At the moment, we deploy the sites using DAV, which is at times quite a burden for the server because a lot of small files are transferred separately.
SCP would probably be a better alternative, but I found no information whether this is supported by Nexus and if so, what I need to do to use it.
The Sonatype support told that this is not possible.
We are developing offline due to limited internet resources and would like to run once every several months a whole grab of an external repository (e.g repo1.maven.org/maven2 - Disk space isn't an issue).
Today I'm using a simple POM that contains a lot of common dependencies that we are using, I've set my local maven to use a mirror to proxy thru a local nexus repository to cache locally and this is how I'm grabbing for offline use - but that isn't very effective.
I'm now looking for a command line tool that allow me to run searches on maven repositories so that I can write a script that grab them all to my local nexus installation and would like to hear if there is any or if there is another way to achieve that.
Thanks
Not a whole solution (yet) but I'm using httrack to grab the whole content of repo1.maven.org/maven2 - That is already better than nothing :)
In general, there is a goal in Maven dependency plugin called "go-offline"
So it allows to grab all the project dependencies and to store them in local .m2 repo.
You can find more information here.
If you want to run Maven and tell it to behave like the network does not exist you can run it with "-o" option (offline mode). So that if there is no dependency installed locally, Maven won't even try to go to network and bring it - but will fail the build.
On the opposite, if you want to force Maven to check and bring new versions (otherwise they already should be in your repo), you can use "-U" option.
I'm not really sure I've got the point about general search-and-download use case. Usually people install Nexus or Artifactory once in a network so that each dependency will be downloaded only once. In local development machines people usually just work with filesystem and don't maintain tools like this.
Now if you want to copy the whole repository from internet (for copying it later to some other network or something) you can just use crawlers like Apache Nutch for example or craft your own script that will recursively download all the files.
I have Jenkins version 2.7.1 running on a Windows 7 machine. It is successfully pulling code from a subversion repository and running tests. I have the test jobs set up for the development branch of each project only.
We periodically make stable releases of the projects in jar files with version numbers. I would like to have Jenkins be the repository manager for those stable releases. These are made by hand - There is no Jenkins job making or testing stable releases. The projects do use Maven.
Each stable build is tagged in the subversion repository, so it could be made again on demand if needed.
I downloaded the Maven repository server hoping to make this fit the purpose. I read the documentation that's provided, but it's pretty terse. As I understand it and have it configured now, this appears to have a couple of issues:
If I go to jenkins-ip/plugin/repository/project, it has made directories there that expose the names of all of my projects, which seems undesirable. (Here jenkins-ip is the IP where I access Jenkins on my local network.)
On the other hand, there's nothing but empty directories under these projects, so they're currently useless.
These projects all correspond to the continuous testing of the development branch. There's no apparent way to get the stable builds into the hierarchy. (It doesn't seem efficient to create a job for each stable release...)
Is there anyway to get Jenkins (with this plugin or through another method) to be the repository manager just for the stable builds? I know that I can start a different repository manager like archiva, but it would be ideal to use Jenkins since it's already running and it seems to claim capability for this function now.
To use Maven repository server you have to build the project on Jenkins.
Then the plugin will expose all archived artifacts as maven repo.
Note you need to use a "Maven project" type for it to work (freestyle is not supported)
There are several plugins that will help you manage building from multiple tags, however not all of them work with "Maven project" type.
You could also try Jenkins pipeline (previously "Workflow") or the Job-DSL plugin.
A simplest solution would be to have a build parameter specify the tag name (then checkout e.g. ^/tags/projectname/${tagParam}), but you have to figure out how to trigger the job then.
I have a Sonatype Nexus repository on an older machine, and I have purchased a newer server which will become my new repository host. In the installation of Nexus on the older machine I have an extensive collection of artifacts, the vast majority of which are now obsolete and can be safely removed from Nexus.
I know it is possible for me to move all of the artifacts from the old installation into the new installation by simply copying the sonatype-work directory to the new box. My question is this: If I want to prune the artifacts in that directory down to only what I need right now (probably about 20% of the repository contents) what steps would I have to take other than deleting the unwanted artifacts? For example, would I need to force Nexus to rebuild indexes? Thanks for the help!
You could just install the new Nexus and proxy off the old one via one proxy repo in addition to Central and other repos. Then you run this for a while and only things not found in other public repositories you configure will be proxied from the old Nexus instance.
At a later stage you could run scheduled task on the old repo that removed old items.
When you are satisfied you got everything you need, you do one last backup and then take the old Nexus instance offline.
Of course the other option is to just not worry and migrate it all. In the end you really only have to migrate what you actually deployed (so probably releases and 3rd party repos).
The easiest option btw. is to just copy the whole sonatype-work folder over to the new machine and fire it up with a new Nexus install there and flick the switch.