简体   繁体   English

使用带有Jenkins Job DSL插件错误的Grape下载依赖项

[英]Downloading dependencies using grape with Jenkins Job DSL plugin error

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). 我使用Jenkins Job DSL插件完成了一项工作,以使用SVNKit库获取SVN分支,但是使用Grape(使用Ivy)设置de jar库时遇到了一个问题。

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. 很好奇,因为如果我转到%USERPROFILE%\\。groovy \\ grapes \\ org.tmatesoft.svnkit \\ svnkit \\ jars,则SVNKIT的jars在那里,但是由于某些奇怪的原因,Grapes无法下载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. 我在葡萄路径中下载JNA jar时遇到了这个问题,但它可以解决问题,但是我想知道发生了什么以及如何以正确的方式进行操作。

I'm using: 我正在使用:

  • Windows 7 64 bits Windows 7 64位
  • Oracle JDK 1.6.0_45 Oracle JDK 1.6.0_45
  • Apache Tomcat 5.5.26 Apache Tomcat 5.5.26
  • Jenkins 1.553 詹金斯1.553
  • Job DSL Jenkins plugin 1.21 Job DSL Jenkins插件1.21

UPDATE: I don't know why, but now after delete de .groovy folder, seems that is working ok. 更新:我不知道为什么,但是现在删除de .groovy文件夹后,似乎工作正常。

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. 我想我第一次尝试获取JNA时遇到了网络问题,Ivy决定将JNA设置为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. 现在可以工作的原因可能是因为删除了.groovy文件夹后,Grape尝试下载并且这次网络正常。

It would be nice if someone can clarify this :) 如果有人可以澄清这一点将是很好的:)

Have you tried to configure a grab resolver ( http://docs.groovy-lang.org/latest/html/api/groovy/lang/GrabResolver.html ) ? 您是否尝试过配置抓斗解析器( 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. 我不知道葡萄的默认解析器,但是默认解析器可能没有用。

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. 我认为有时候,当使用Grapes(以及其他类似的技术)解决依赖关系时,在完全下载或正确配置依赖关系之前会切换一些标志。 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. 我也曾在Maven和Gradle中发生过这种情况,通常可以通过吹掉.m2或.gradle中的缓存工件并强制再次获取它们来解决问题。

We use our nexus as a host in the grapeConfig.xml. 我们将nexus用作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: Jenkins的groovy库中使用以下示例代码:

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 " 设置Java选项以启用调试信息: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 上面的信息来自这里: http : //docs.groovy-lang.org/latest/html/documentation/grape.html

After all new configuration I also: - deleted .groovy/grapes/* - restarted jenkins 完成所有新配置后,我还:-删除了.groovy / grapes / *-重新启动了jenkins

Mike 麦克风

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM