Different maven build result from Jenkins than directly - maven

I'm setting up Jenkins for an existing maven project. When a build runs, the Jenkins console shows the following error (filenames/URLs changed):
[ERROR] Failed to execute goal on project: Could not resolve dependencies for project: Failure to find (file jar) in http://example.com:8081/nexus/content/repositories/snapshots was cached in the local repository, resolution will not be reattempted until the update interval of repo has elapsed or updates are forced -> [Help 1]
[ERROR]
When I cd /var/lib/jenkins/jobs/Project/workspace and run mvn package myself, the build completes successfully.
I've tried forcing/cleaning, I've tried deleting the Jenkins project and re-adding.
How can I force the build through Jenkins, or what could be causing the cache error?

Related

Maven not picking locally installed dependency

I downloaded and imported a multi-module maven project say Project-A. In installed one of its modules say moduleA1 into my local repository and I can see it in the repository directory.
I created another Project-B which has moduleA1 as a dependency. But when I try to package Project-B, I notice that maven is searching for moduleA1 in the online central repository and it fails.
This is the error I get:
[ERROR] Failed to execute goal on project <project-B>: Could not resolve dependencies for project <Project-B>:war:1.0: Failed to collect dependencies at <moduleA1>:jar:<version>: Failed to read artifact descriptor for <moduleA1>:jar:<version>: Failure to find <moduleA1-groupId>:<moduleA1>:pom:<version> in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
How can I make maven to resolve this moduelA1 dependency from my local repository.
This problem can occur if you have some child projects that refer to a parent pom (moduleA1 in your case) and you have not installed from the parent pom directory (run mvn install from the parent directory (i.e. Project-A in your case)). If one of the child projects (moduleA1 in your case) may depend on a sibling project (let's assume you have another module moduleA2) and when it goes to read the pom of the sibling, it will fail with the error mentioned in the question unless you have installed from the parent pom directory at least once. So just try running:
mvn -U clean install
from your Project-A directory
Maven automatically resolves dependencies from the local repository.
Without the exact error message, it is difficult to give a more precise answer.

Maven Build Failure releated to com.sap.cloud.s4hana.plugins:s4sdk-maven-plugin

I am facing an issue during the Maven build. The issue on my
terminal is: [ERROR] Failed to execute goal
com.sap.cloud.s4hana.plugins:s4sdk-maven-plugin:2.12.0:usage-analytics
(default) on project demo-generator-application: Execution default
of goal
com.sap.cloud.s4hana.plugins:s4sdk-maven-plugin:2.12.0:usage-analytics
failed: Plugin
com.sap.cloud.s4hana.plugins:s4sdk-maven-plugin:2.12.0 or one of its
dependencies could not be resolved: Failed to collect dependencies
at com.sap.cloud.s4hana.plugins:s4sdk-maven-plugin:jar:2.12.0 ->
com.sap.cloud.s4hana.plugins:usage-analytics:jar:2.12.1-M1: Failed
to read artifact descriptor for
com.sap.cloud.s4hana.plugins:usage-analytics:jar:2.12.1-M1: Failure
to find com.sap.cloud.s4hana:sdk-modules-bom:pom:2.12.1-M1 in
https://repo.maven.apache.org/maven2 was cached in the local
repository, resolution will not be reattempted until the update
interval of central has elapsed or updates are forced -> [Help 1]
The maven project I used can be found here:
https://github.com/SAP/cloud-s4-sdk-examples/blob/master/VDMGenerator/application
The document can be found:
https://blogs.sap.com/2018/04/30/deep-dive-10-with-sap-s4hana-cloud-sdk-generating-java-vdm-for-s4hana-custom-odata-service/
Please try to run mvn clean install -U to force an update of dependencies.

Error: Failed to execute goal on project xxxx inside jenkins build

when i run the build in jenkins i got below error when i am trying to run in local its building fine.
[ERROR] Failed to execute goal on project xxx: Could not resolve dependencies for project xxx:xxx-bin:pom:10-2.1.0-test: The following artifacts could not be resolved: xxx-alerts:alerts-loader:jar:xxx:3-95210ce313-2.1.0-test, xxx-alerts:alerts-loader:zip:resources:3-95210ce313-2.1.0-test: Failure to find xxx-alerts:alerts-loader:jar:deps:3-95210ce313-2.1.0-test in http://xxx:8080/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced -> [Help 1]
[ERROR]
Delete ~.m2\repository and this should work for you.
Also, make sure u run the mvn command with clean before install

Spring MVC issues in STS 3.7.3

I am getting this error on importing https://github.com/spring-projects/spring-mvc-showcase in STS 3.7.3:---
Description Resource Path Location Type
Failure to transfer org.codehaus.mojo:aspectj-maven-plugin:pom:1.2 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.codehaus.mojo:aspectj-maven-plugin:pom:1.2 from/to central: connect timed out pom.xml /spring-mvc-showcase line 1 Maven pom Loading Problem
Edit
Mvn is ok now but pom.xml error still persists if I remove the errors and do maven clean I get errors as:
[INFO] https://repo.maven.apache.org/maven2/org/codehaus/mojo/aspectj-maven-plugin/1.2/aspectj-maven-plugin-1.2.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [ERROR] Plugin org.codehaus.mojo:aspectj-maven-plugin:1.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:aspectj-maven-plugin:jar:1.2: Could not transfer artifact org.codehaus.mojo:aspectj-maven-plugin:pom:1.2 from/to central: connect timed out -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
First of all STS is build on Eclipse. So you can easily install the IDE Integration Eclipse IDE - M2Eclipse for STS. You can see how here. If you want to use it with this integration plugin you dont need to have a local maven repository.
Resolving Maven dependencies from the Eclipse workspace without installing to local Maven repository
But its also possible to use maven as a local system repository. Download is here and follow the steps for the installation and configuration here.
To see if you have a valid maven installation done, you can test it by typing mvn -v in a cmd shell or using STS -> right click on your project -> run as -> maven build or maven install.
Update:
I would say delete the project from your workspace and try it again. Download the project from gitHub as a zip file and import it again to your workspace. Right Click -> import -> existing maven project.
If you need to use a proxy for your connection you have to create a settings.xml in your .m2 folder. Look here for more info

Update interval of Maven Central Repo

Having zero experience with Maven, I am running a mvn clean install on a project and this is the error I get:
[ERROR] Failed to execute goal on project dnasequencing.CompaNY.com: Could not resolve dependencies for project com.CompaNY.dnasequencing:dnasequencing.
CompaNY.com:war:1.0-SNAPSHOT: The following artifacts could not be resolved: dsr-kepler:dsr-kepler:jar:0.0.1-SNAPSHOT, dsr-parser:dsr-parser:jar:0.0.1-
SNAPSHOT: Failure to find dsr-kepler:dsr-kepler:jar:0.0.1-SNAPSHOT in http://repo1.maven.org/maven2/ was cached in the local repository, resolution
will not be reattempted until the update interval of Maven_Central_Repo has elapsed or updates are forced -> [Help 1]
Based on these error messages, what is an startingpoint I should take a look for finding what is going wrong?
You can force Maven to update snapshots with the -U flag.
As far as what is going wrong, you can always check out the actual Maven website with your browser and see if the dependency actually exists.
http://search.maven.org/
If the dependency is not hosted in Maven central, then it seems it is a local dependency that you have to install in your local cache (run mvn clean install from that project).

Resources