詹金斯蚂蚁调用和ivy任务



我在osx服务器(Lion)上安装了一个jenkins,我希望它调用一个ant脚本来编译一个sigle示例项目。

istallation有一个专门的用户"jenkins",如果我从ssh实例中记录他,我可以成功地使用运行编译任务(使用ivy的任务)

jenkins>ant compile

当网络接口调用ant时,问题就开始了,得到了以下错误:

Problem: failed to create task or type antlib:org.apache.ivy.ant:resolve

原因:ant没有从库中正确加载ivy的解析任务。我真的不明白该怎么办。我确信jenkins是以"jenkins"用户的身份运行命令的。

编辑:更多信息

BUILD FAILED
/Users/Shared/Jenkins/Home/jobs/example-build/workspace/build.xml:19: Problem: failed to create task or type antlib:org.apache.ivy.ant:resolve
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
No types or tasks have been defined in this namespace yet
This appears to be an antlib declaration. 
Action: Check that the implementing library exists in one of:
    -/usr/share/ant/lib
    -/Users/Shared/Jenkins/Home/.ant/lib
    -a directory added on the command line with the -lib argument
Total time: 0 seconds
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE

看起来Jenkins作业使用的ANT安装无法拾取常春藤罐。

选项1

将以下目标添加到您的ANT构建中,并调用它一次,将ivy jar安装到ANT将识别的位置,即$HOME/.ANT/lib

<target name="bootstrap" description="Install ivy">
    <mkdir dir="${user.home}/.ant/lib"/>
    <get src="https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&amp;g=org.apache.ivy&amp;a=ivy&amp;v=LATEST&amp;e=jar"
         dest="${user.home}/.ant/lib/ivy.jar"/>
</target>

注:

  • 该目标使用Sonatrype的Nexus存储库提供的REST API来下载ivy的最新版本

选项2

如果常春藤罐位于以下目录中:

  • /usr/local/bin/ivy

您可以使用lib参数调用ANT,为ANT插件指定替代位置。

ant -lib /usr/local/bin/ivy clean build

运行Ant任务时,在类路径中确保存在ivy.jar。在eclipse->Run As->Ant Build->Edit configuration->Classpath选项卡中。尽管eclipse在Ant Home中有ivy.jar,但由于某些原因,它没有被调用。

最新更新