Jenkins Maven Release with GIT - java

I got Jenkins set up with SSH connection to Git, using SSH agent and trying to set up a job, which would do Maven Release build. The job is executing following commands
-Dresume=false release:prepare release:perform
-Dresume=false -DdryRun=true release:prepare
During deployment with maven-deploy-plugin I run into error,
[INFO] [INFO]
[INFO] [INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) # uaiContacts ---
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD FAILURE
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 4.151 s
[INFO] [INFO] Finished at: 2015-09-23T11:35:32+01:00
[INFO] [INFO] Final Memory: 27M/265M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project uaiContacts: Failed to deploy artifacts/metadata: Cannot access git#giturl:repo with type default using the available connector factories: BasicRepositoryConnectorFactory: Cannot access git#giturl:repo using the registered transporter factories: WagonTransporterFactory: java.util.NoSuchElementException
[INFO] [ERROR] role: org.apache.maven.wagon.Wagon
[INFO] [ERROR] roleHint: git#giturl
[INFO] [ERROR] -> [Help 1]
[INFO] [ERROR]
[INFO] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[INFO] [ERROR] Re-run Maven using the -X switch to enable full debug logging.
[INFO] [ERROR]
[INFO] [ERROR] For more information about the errors and possible solutions, please read the following articles:
[INFO] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
I am not sure why is it saying cannot access and how is it trying to access. As I am aware wagon will be using ssh, so there should not be a problem.
My pom.xml
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.4</version>
</extension>
</extensions>
</build>
<scm>
<connection>scm:git:git#giturl:repo</connection>
<developerConnection>scm:git:git#giturl:repo</developerConnection>
<url>git#giturl:repo</url>
<tag>HEAD</tag>
</scm>
<distributionManagement>
<repository>
<id>release</id>
<url>git#giturl:repo</url>
</repository>
</distributionManagement>

You are trying to deploy the released artifact to a GIT repository. Artifacts are deployed to a central repository such as Artifactory or Nexus, usually by means of HTTP (POST) unless you specify something else.
If you want to deploy using SSH, this link will explain how it's done.

Related

maven unable to run test

I have been trying to use mvn clean test, but I keep getting the following.
bash-3.2$ mvn clean test
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< >----------------------
[INFO] Building son 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/3.1.0/maven-clean-plugin-3.1.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:15 min
[INFO] Finished at: 2020-06-24T16:57:32-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:3.1.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:3.1.0: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:3.1.0 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/3.1.0/maven-clean-plugin-3.1.0.pom: Connect to repo.maven.apache.org:443 [repo.maven.apache.org/199.232.64.215] failed: Operation timed out (Connection 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
I've research and read that I need to use mvn clean:istall first, but everything keeps on failing. I have the following information on Apache Maven version 3.6.3 and java
version jdk1.8.0_231.jdk

Unable to download groovy.jar

Any help appreciated.
I'm new to Maven. I got the below command from tutorials point
mvn archetype:generate -DgroupId=com.tutorialpoint.app -DartifactId=camel-first-app -DarchetypeGroupId=org.apache.camel.archetypes -DarchetypeArtifactId=camel-archetype-spring -DinteractiveMode=false
it is failing with below error:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) # standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) # standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) # standalone-pom ---
Downloading:
http://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy/1.8.3/groovy-1.8.3.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.981s
[INFO] Finished at: Tue Nov 14 23:11:42 IST 2017
[INFO] Final Memory: 10M/184M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate (default-cli) on project standalone-pom: Execution default-cli of goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate failed: Plugin org.apache.maven.plugins:maven-archetype-plugin:3.0.1 or one of its dependencies could not be resolved: Could not transfer artifact org.codehaus.groovy:groovy:jar:1.8.3 from/to central (http://repo.maven.apache.org/maven2): GET request of: org/codehaus/groovy/groovy/1.8.3/groovy-1.8.3.jar from central failed: Connection reset -> [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
Can someone please help.
The relevant error is pointing to a connection problem:
Could not transfer artifact org.codehaus.groovy:groovy:jar:1.8.3
from/to central (http://repo.maven.apache.org/maven2): GET request
of: org/codehaus/groovy/groovy/1.8.3/groovy-1.8.3.jar from central
failed: Connection reset
The command which you posted actually runs fine on my machine. If you execute this maven command and you do not have the Groovy libraries yet, you will see that it actually downloads the following files:
https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy/1.8.3/groovy-1.8.3.pom
https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy/1.8.3/groovy-1.8.3.jar
It might be that you have only access to the internet via a proxy. In this case you will need to setup a proxy in the Maven configuration.
This blog here contains a fairly good description on how to setup a proxy for Maven, so that Maven can access the repository libraries.
Another option to tackle your problem would be to manually download this file using your browser:
https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy/1.8.3/groovy-1.8.3.jar
And then install it in your repository manually using:
mvn install:install-file -Dfile=<path-to-file> -DgroupId=org.codehaus.groovy \
-DartifactId=groovy -Dversion=1.8.3 -Dpackaging=jar
But normally you should not have to do this manual download + installation. Maven should be doing this for you.

Failed to read artifact descriptor for org.springframework:spring-core:jar

I'm trying to download maven dependencies to my netbeans build maven web application. ince I couldn't update dependencies through IDE I tried to do it using
mvn clean install
Command trough cmd.
But I still got the same error.
Please help. I'm trying to figure this out for days. (Internet connection is working pretty fine.)
THank you
EDIT
This is the output.
C:\Users\Dilini\Documents\NetBeansProjects\NewSpring>mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building NewSpring 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.springframework:spring-core:jar:5.0.0.RC3 is missing, no dependency information available
[WARNING] The POM for org.springframework:spring-beans:jar:5.0.0.RC3 is missing, no dependency information available
[WARNING] The POM for org.springframework:spring-context:jar:5.0.0.RC3 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.552 s
[INFO] Finished at: 2017-08-24T15:24:58+05:30
[INFO] Final Memory: 8M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project NewSpring: Could not resolve dependencies for project com.dilini:NewSpring:war:1.0-SNAPSHOT: The following artifacts could not be resolved: org.springframework:spring-core:jar:5.0.0.RC3, org.springframework:spring-beans:jar:5.0.0.RC3, org.springframework:spring-context:jar:5.0.0.RC3: Failure to find org.springframework:spring-core:jar:5.0.0.RC3 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
C:\Users\Dilini\Documents\NetBeansProjects\NewSpring>
You need to add this repo to your pom file:
<repositories>
<repository>
<id>repository.spring.milestone</id>
<name>Spring Milestone Repository</name>
<url>http://repo.spring.io/milestone</url>
</repository>
</repositories>

Maven dependency is downloading only pom not jar for newer version

I have a dependency on JBoss's teiid framwork. If I add the dependency on older version it downloads the jar file while if I add dependency on newer version it only downloads pom file. below is my pom config
repository:
<repository>
<id>jboss-public-repository-group</id>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
This will download jar
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client</artifactId>
<version>8.5.0.Final</version>
</dependency>
This will download only pom file
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client</artifactId>
<version>8.9.1</version>
</dependency>
Update:
Maven log
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building hello-teiid 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: http://repository.jboss.org/nexus/content/groups/public/org/jboss/teiid/teiid-client/8.9.1/teiid-client-8.9.1.pom
[INFO] Downloaded: http://repository.jboss.org/nexus/content/groups/public/org/jboss/teiid/teiid-client/8.9.1/teiid-client-8.9.1.pom (2 KB at 1.4 KB/sec)
[INFO] Downloading: http://repository.jboss.org/nexus/content/groups/public/org/jboss/as/jboss-as-parent/7.4.0.Final-redhat-4/jboss-as-parent-7.4.0.Final-redhat-4.pom
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/jboss/as/jboss-as-parent/7.4.0.Final-redhat-4/jboss-as-parent-7.4.0.Final-redhat-4.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.047 s
[INFO] Finished at: 2015-01-28T09:41:17-05:00
[INFO] Final Memory: 6M/123M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project hello-teiid: Could not resolve dependencies for project hello:hello-teiid:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at org.jboss.teiid:teiid-client:jar:8.9.1: Failed to read artifact descriptor for org.jboss.teiid:teiid-client:jar:8.9.1: Could not find artifact org.jboss.as:jboss-as-parent:pom:7.4.0.Final-redhat-4 in jboss-public-repository-group (http://repository.jboss.org/nexus/content/groups/public/) -> [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
If you search for this artifact in the jboss repo, you can see that in version 8.9.1 its packaging is "bundle", while in version 8.5.0 it was defaulted to "jar".
Now that we have noticed this, we can relate to the comment of #AlexandrM, OSGI Bundle vs jar dependency,
or to be even more specific, Why can't maven find an osgi bundle dependency? (note the 2nd answer, not the accepted one. Basically, you need to add a plugin that defines it, namely the maven-bundle-plugin).

Missing JUNIT Jar Exception while building project using Maven

I am in the beginning phase of Maven. I created a project and was trying to use the command. what is missing at my end? I am trying to compile and run a TestSuite File:
mvn clean package
POM.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.myProject</groupId>
<artifactId>myTest</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>egdsvTest</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
but i get the below exception after using it.
Exception
D:\MVN_Shirish_Project\Test>mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethrea
ded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Test 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # Test ---
[INFO] Deleting D:\MVN_Shirish_Project\Test\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # Test
---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\MVN_Shirish_Project\Test\src\
main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # Test ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. b
uild is platform dependent!
[INFO] Compiling 1 source file to D:\MVN_Shirish_Project\Test\target\classe
s
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # eg
dsvTest ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\MVN_Shirish_Project\Test\src\
test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) #
Test ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. b
uild is platform dependent!
[INFO] Compiling 1 source file to D:\MVN_Shirish_Project\Test\target\test-c
lasses
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # Test ---
[INFO] Surefire report directory: D:\MVN_Shirish_Project\Test\target\surefi
re-reports
[WARNING] Missing POM for org.apache.maven.surefire:surefire-junit3:jar:2.12.4
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.968 s
[INFO] Finished at: 2014-10-14T12:28:09+05:30
[INFO] Final Memory: 7M/247M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
12.4:test (default-test) on project Test: Unable to generate classpath: org
.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException: Missing:
[ERROR] ----------
[ERROR] 1) org.apache.maven.surefire:surefire-junit3:jar:2.12.4
[ERROR]
[ERROR] Try downloading the file manually from the project website.
[ERROR]
[ERROR] Then, install it using the command:
[ERROR] mvn install:install-file -DgroupId=org.apache.maven.surefire -DartifactI
d=surefire-junit3 -Dversion=2.12.4 -Dpackaging=jar -Dfile=/path/to/file
[ERROR]
[ERROR] Alternatively, if you host your own repository you can deploy the file t
here:
[ERROR] mvn deploy:deploy-file -DgroupId=org.apache.maven.surefire -DartifactId=
surefire-junit3 -Dversion=2.12.4 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url
] -DrepositoryId=[id]
[ERROR]
[ERROR] Path to dependency:
[ERROR] 1) dummy:dummy:jar:1.0
[ERROR] 2) org.apache.maven.surefire:surefire-junit3:jar:2.12.4
[ERROR]
[ERROR] ----------
[ERROR] 1 required artifact is missing.
[ERROR]
[ERROR] for artifact:
[ERROR] dummy:dummy:jar:1.0
[ERROR]
[ERROR] from the specified remote repositories:
[ERROR] m1 (http://repo1.maven.org/maven2, releases=true, snapshots=false)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[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 rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception
Maven works by creating a local repository in your desktop or the machine you have installed maven and running this goal.
In the process of maven running the goal, it first tries to get all the dependent jar files from Central repository as you have listed in your comments M1 or M2 and then stores them under C:/Users/yourname/.m2/repository folder (assuming you are using a windows machine) or the corresponding user folder in other OS systems.
Then it uses the jars to run the build as required per the goals given.
Now in your case, you got to figure out a way to connect to the repositories (check your settings.xml located in the .m2 folder in your User directory) and check if you can connect to the internet central maven repositories. If not you can get the jar file and manually install them as advised in the error you have got. Once you do that I think you should get past this issue. Let me know if you still have the issues.
In my case, it was caused by me doing an offline build (i.e. mvn -o install) and me not having that jar installed in my local Maven repository yet. Doing an online build (mvn install) fixed it.

Categories