Question

I did a job using Jenkins Job DSL plugin to get SVN branches with SVNKit libraries, but I have one problem setting de jar libraries using Grape (which uses Ivy).

If I set this in my script:

@Grapes( 
    @Grab(group='org.tmatesoft.svnkit', module='svnkit', version='1.8.3') 
)
import org.tmatesoft.svn.core.SVNDirEntry
import org.tmatesoft.svn.core.SVNNodeKind
...
...

I get the following error:

FATAL: startup failed:
General error during conversion: Error grabbing Grapes -- [download failed: net.java.dev.jna#jna;3.5.2!jna.jar]

java.lang.RuntimeException: Error grabbing Grapes -- [download failed: net.java.dev.jna#jna;3.5.2!jna.jar]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    ...

It's quite curious because if I go to %USERPROFILE%\.groovy\grapes\org.tmatesoft.svnkit\svnkit\jars the jars of SVNKIT are there but for some strange reason Grapes can't download JNA jars.

I workaround this problem downloading JNA jar in the grapes path, and it worked, but I would like what is happening and how to do this in the right way.

I'm using:

  • Windows 7 64 bits
  • Oracle JDK 1.6.0_45
  • Apache Tomcat 5.5.26
  • Jenkins 1.553
  • Job DSL Jenkins plugin 1.21

UPDATE: I don't know why, but now after delete de .groovy folder, seems that is working ok.

I guess that I had a network problem while I try to get JNA for the first time and Ivy decided to set JNA as broken link on Maven Central. The reason why now works could be because after I delete the .groovy folder, Grape tried to download and this time network was ok.

It would be nice if someone can clarify this :)

Was it helpful?

Solution 3

I think sometimes when dependencies are being resolved with Grapes (and perhaps other similar technologies), some flag is toggled before the dependency gets fully downloaded or configured properly. I have had this happen with Maven and Gradle as well and the problem is usually resolved by blowing away cached artifacts in .m2 or .gradle and force them to be fetched again.

OTHER TIPS

We use our nexus as a host in the grapeConfig.xml.

<?xml version="1.0" encoding="UTF-8"?>
<ivy-settings>
  <settings defaultResolver="downloadGrapes" />
    <property name="repo.host" value="ourhost.on.network" override="false"/>
    <property name="repo.realm" value="Sonatype Nexus Repository Manager" override="false"/>
    <property name="repo.user" value="xxx"  override="false"/>
    <property name="repo.pass" value="xxx"  override="false"/>

  <credentials host="nexus.evdssz.admin.ch" realm="${repo.realm}" username="${repo.user}" passwd="${repo.pass}"/>
  <resolvers>
      <chain name="downloadGrapes" returnFirst="true">
      <ibiblio name="nexus" root="https://ourhost.on.network:8443/nexus/content/groups/public/" m2compatible="true"/>
      <ibiblio name="nexusreleases" root="https://ourhost.on.network:8443/nexus/content/repositories/releases/" m2compatible="true"/>
      <ibiblio name="localm2" root="file:/opt/jenkins_home/.m2/repository/" checkmodified="true" changingPattern=".*" changingMatcher="regexp" m2compatible="true"/>
    </chain>
  </resolvers>
</ivy-settings>

The following example code is used in the groovy library in Jenkins:

import com.google.common.collect.HashBiMap
@Grab(group='com.google.code.google-collections', module='google-collect', version='snapshot-20080530')
def getFruit() { [grape:'purple', lemon:'yellow', orange:'orange'] as HashBiMap }
assert fruit.lemon == 'yellow'
assert fruit.inverse().yellow == 'lemon'

Enable debugging on what grape is doing. Install the grape tool on your Jenkins. Set the java options to enable debugging information: JAVA_OPTS="-Dgroovy.grape.report.downloads=true -Divy.message.logger.level=4 "

The info above comes from here: http://docs.groovy-lang.org/latest/html/documentation/grape.html

After all new configuration I also: - deleted .groovy/grapes/* - restarted jenkins

Mike

Have you tried to configure a grab resolver (http://docs.groovy-lang.org/latest/html/api/groovy/lang/GrabResolver.html) ? I don't know the default resolver for grape, but maybe the default resolver does no work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top