Is there a way to force artifactoryPublish task to publish the jar file first and then the pom file ? Or make pom file visible to others only when jar file is available.
We have multiple Git repositories where the jars are shared across the repositories. The Hudson build for them is triggered almost at the same time. So we have hit this case of gradle finding the pom but not the jar; But when we try to look into artifactory we see both. Just that we see jar gets uploaded couple of seconds later than the pom.
What is the best way to solve this (other than changing the time when Hudson build triggers).
Related
I'm new to Gradle, and have inherited a project. We have a project that takes a .proto file and builds a .java file out of it, it then publishes the generated .jar it to a remote maven repo. The .proto generation is all working fine, but there are issues with the .jar versioning.
The publishing code in build.gradle is basically the same as this example from the docs.
When I run ./gradlew clean build it generates the .jar file under build/libs. the file name is myname-1.1. But when I pulled the file that was published to the maven repo it has the name myname-1.1-20210xxx.065xxx-xx. (x's for redaction). I can't find any details in the docs on this, but I assume when it publishes the .jar it appends the filename with a timestamp and possibly more.
I've been told they want the .jar file in the gradle project to have the same name as the one in the maven repo. Is this an unusual scenario? Is there a way to make these versions line up?
Quite sure you are deploying a SNAPSHOT version to your repository.
This is the expected behavior. When you publish a SNAPSHOT version, a timestamp is appended at the end of file.
I want to use a project called projectA that I have in a maven repository as dependency of a projectB.
The mvn deploy of projectA is successful (I can see in the repository the projectA-0.0.1-20190902.072951-1.jar, projectA-0.0.1-20190902.072951-1.pom and maven-metadata.xml files), but when I specify the dependency in the pom.xml file of projectB, the project works but it downloads two JARs of projectA from the repository:
- projectA-0.0.1-20190902.072951-1.jar
- projectA-0.0.1-SNAPSHOT.jar and the same issue for every file downloaded by the dependency to this project.
I think that only one JAR is necessary, and I don't know what I need to put maybe in settings.xml or in the pom.xml file of any project to get only one JAR when the dependency is downloaded.
Thank you so much for your help!
In the past it was possible to tell Maven to deploy Non-unique Snapshot Deployments but in Maven 3
... snapshot artifacts will always be deployed using a timestamped version
So:
the files with the timestamps are the one you have deployed to your remote repo (mvn deploy ...) and then downloaded from there as dependencies
the ones with -SNAPSHOT are the result of the local builds (install goal)
If your concern is download traffic - that is not an issue. The -SNAPSHOT ones are not downloaded.
If your concern is disk space then you can have a cron job or use something like Build Helper Maven Plugin to remove old version artifacts from the local repository.
Currently we have a number of maven projects (specifically Apache Camel) that reside in isolation. We also have one Jenkins job per project because we need to specify the pom.xml file in the maven build and since the projects are independent then we require one job per project.
However, we also know most of the projects share a lot of dependencies and we want to turn them into a maven multi-module project with a parent pom file where the dependencies and versions are stated. We also want to have fewer Jenkins jobs to maintain and allow more projects to be added without having to create new Jenkins job.
My question is, in the Jenkins job for the maven build I still need to specify a single pom file. Does this mean that I need to point to the parent pom file and then add theparent directory as the directory to for Jenkins to receive the git trigger? In a sense, whenever a code is committed to any of the child projects, the job gets triggered and it uses the parent pom file to build only that project where the code was committed?
Situation
I have a multi-module Maven project. In it, I have several JAR artefacts, it then gets assembled as a WAR file. Thus, the WAR artefact depends on all kinds of JAR artefacts (it also has a WAR overlay), most of them with scope "compile".
Build and deployment to a repository are fine. But when I try to retrieve the WAR artefact, I have issues. previously, I used a simple wget to retrieve it from the Nexus API, but I wanted to try the Jenkins Repository Connector - not the least reason being that it actually shows a list of available versions.
I configure a repository in
Manage Jenkins -> Configure System -> Artifact Resolver
with the URL for our repo:
http://$NEXUS/nexus/content/repositories/releases/
then in the job, i add a parameter:
Maven Repository Artifact
and use the repository configured above, then i add
Artifact Resolver
as a build step and set it up.
Problem
I am not even sure on which side this should be solved: When I run the job to try to get the WAR file from the nexus, it also starts trying to retrieve all kinds of transitive dependencies (some of which are unaccessible to this user) and fails. What I need is just the WAR file. No transitive dependencies (since they're already packaged in the WAR).
The Repository Connector plugin doesn't seem to have a switch for this, and the Maven side it's probably perfectly OK to include those dependencies in the output POM.
Question
What can I do to either stop the repository connector from retrieving transitive dependencies or retrieve the WAR artefact in a different way? Also interesting for me (but a bit broad as a question) would be general ideas about doing this kind of workflow. E.g., does anyone use other ways of deploying the WAR into their Nexus?
i submitted a patch to the repository connector plugin.
my fork:
https://github.com/rmalchow/repository-connector-plugin
working on getting it to be merged:
https://github.com/jenkinsci/repository-connector-plugin/pull/10
Are there any plugins or ways to download the dependencies for a maven project from Jenkins? I am using Jenkins for a multi-module desktop application. Although I know I could just archive all dependencies, I don't see why there isn't the ability to download dependencies using maven which installed on the same machine as Jenkins. Preferably one would specify the location of a pom and then have the ability with one click to download all the dependencies for that pom. Can you do this? I do not need or want an entire binary repository for this feature.
Edit: I will try and rephrase this as I don't think people are understanding.
In Jenkins one has the ability to archive artifacts at the end of a build. Also in jenkins you have integration with maven. When building a jar in maven you have arguablly 2 options:
You can either use the assembly plugin which zips all .class files
together with those produced from your source code resulting in 1 jar
You can create a jar just source code which references all
dependency jars which are located in a separate folder.
In Jenkins one also has the ability to download the latest artifact. Now if I am using Option 2, I can either archieve just the jar which my sources produced, which I would say is more desirable for space and is the whole purpose of the archive functionality, or you can also archive the libraries too.
Here is the PROBLEM!! If I don't archive the libraries then I cannot easily run this jar, as it is a desktop application and its dependencies cannot be obtained in the same mannor as clicking on a link from jenkins. So lets say my question is what is the easiest way to obtain them? Extra info: assume jenkins is running as a server and you can't use artifactory or another server application, that seems to me to be massive over kill.
Use the maven plugin and create a maven job for your project. Jenkins will then use the maven command you provide in the job configuration to build the project. This means maven will download the projects dependencies and store them on the machine jenkins is running. Normally this would be <JENKINS_HOME>/.m2/repository. This way you get a local repository that only contains the dependencies of the projects you created maven jobs for.