Friday, October 25, 2013

Jenkins, Maven error: Target repository cannot be empty

After applying the previous three fixes (see my other recent posts) to my Jenkins instance my Maven builds were still failing. I hope these posts can help others.


mavenExecutionResult exceptions not empty
message : Internal error: java.lang.IllegalArgumentException: Target repository cannot be empty
cause : Target repository cannot be empty
Stack trace : 
org.apache.maven.InternalErrorException: Internal error: java.lang.IllegalArgumentException: Target repository cannot be empty

After asking Uncle Google, I only turned up the jfrog code that returns the "Target repository cannot be empty" message.  After a little more prodding of Uncle Google, Uncle finally revealed that the Jenkins Artifactory Plug-in uses jfrog  JENKINS Artifactory Plugin. Now I had somewhere to look.  I looked at my Jenkins instance and attempted to set the Artifactory target repository, but the Artifactory plugin appeared to be corrupt, as I wasn't getting any place to enter the target repository. Thus it appeared that the Artifactory plugin was probably corrupt. This was most likely due to my need to downgrade Jenkins to an older version.

Solution:  I first attempted to use the Manage Plugin feature to uninstall the Artifactory plugin but it didn't actually remove it.  Thus I forcibly removed Artifactory Jenkins plug-in, by removing JENKINS_HOME/plugins/artifactory directory and the artifactory.jpi file. I believe there are still some xml files I need to hack but I'm finally back to building my software.

git: Failed to connect to repository

My Jenkins instance was failing to connect to a git repository using a supplied username and private key. The Credentials plugin appeared to be getting confused. I hope the following can help others avoid a bit of head banging against your desk.


Failed to connect to repository : Command "ls-remote -h ssh://myuser@repo HEAD" returned status code 128:
stderr: Permission denied, please try again. 
Permission denied, please try again. 
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). 
fatal: The remote end hung up unexpectedly


In my situation the Jenkins instances is pointing to several different repositories (svn and git)
The connection to the svn repository uses svn+ssh. The connection to the git repository ,using ssh, was failing. It appears that the Jenkins instance is having trouble figuring out which credentials to use or private key to use.

The solution is to define the private key to use for the user that is failing. I found the solution here at: stackoverflow  then modified for my situation.

Create a JENKINS_HOME/.ssh/config file to point to the correct private key.
Set permissions to 600 ( rw------- )
Set the contents of the file to:

HostName 123.456.789.012
User myuser
IdentityFile /home/jenkins/.ssh/id_rsa

Where: Host:            Can be anything is it just a place holder I generally use the DNS name 
                                 or short name of the server.
            HostName:    IP addresss or fully qualified domain name if you have DNS 
                                 enabled on your network
           User:             The user that will be connecting to the repo
  IdentityFile: The ssh private key that will be used to connect to the repository.
                                      In my case the user  and key are not the jenkins user and id_rsa. 


You must add the public key to your known_hosts file. The easiest way to add this is to execute: ssh   
Then answer yes.

Alternatively if you have the public key you can directly edit your known_hosts file and paste the public key to the bottom of the file.

Jenkins Maven Jobs fail to Parse POMS

I had several recent Issues with Jenkins and Maven I hope this will help someone else out there with the same issue.


Jenkins Maven Jobs fail to Parse POMS
Caused by: java.lang.ClassNotFoundException: org.apache.maven.cli.MavenLoggerManager


It appears that Maven 3.1.0, and 3.1.1 (I tried both) have not been compiled into Jenkins yet.
More can be found here:JENKINS-15935  as of today 10/25/2013 the fix version has not been set. So I'm guessing it will be fixed soon.


Roll back Maven to 3.0.5, This assumes that you installed maven yourself,(ie /usr/local/maven) rather than having Jenkins do it for you which I didn't try.

Jenkins Maven jobs do not log errors

I recently had a few issues with my Jenkins, Maven, Git environment failing builds without displaying any actual errors. To say the least this was very frustrating especially since the Maven builds ran just fine from the command line in the Jenkins work space.

Issue: Jenkins Maven jobs do not log errors.


 Apparently a bug was introduced in Jenkins with the release of 1.526 which caused Jenkins to not display errors generated by maven, Only displaying the build as a failure. This is discussed in the Jenkins Jira instance here:JENKINS=19352 


Roll back Jenkins to version 1.525