【问题标题】:jenkins ant invocation and ivy tasksjenkins ant 调用和常春藤任务
【发布时间】:2012-07-08 17:56:27
【问题描述】:

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

安装有一个专用用户“jenkins”,如果我从 ssh 实例登录他,我可以成功运行编译任务(使用 ivy 的任务):

jenkins>ant compile

Web 界面调用 ant 时出现问题,出现此错误:

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

原因:ant 没有从库中正确加载 ivy 的 resolve 任务。我真的无法理解修复。我确信 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

【问题讨论】:

  • 请发布完整的堆栈跟踪,看起来常春藤库可能不在 ants 类路径中
  • 你在哪里安装了 ivy 的 jars?
  • 通过自制软件,which ivy 输出 /usr/local/bin/ivy

标签: ant jenkins ivy


【解决方案1】:

看起来 Jenkins 作业使用的 ANT 安装无法获取 ivy jar。

选项 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>

注意事项:

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

选项 2

如果 ivy jar 位于以下目录中:

  • /usr/local/bin/ivy

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

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2012-01-08
      • 2015-12-04
      • 2023-04-03
      • 2015-01-25
      • 2018-07-07
      • 2013-12-19
      • 2010-12-30
      • 2018-01-06
      • 2012-01-13
      相关资源
      最近更新 更多