简体   繁体   English

建立失败…使用ant脚本在jenkins中创建War文件时

[英]BUILD FAILED …while creating War file in jenkins using ant script

I have added build.xml in root directory of java project checkedin in svn successfully. 我已经在svn中检入的Java项目的根目录中成功添加了build.xml

Now, Following is Console output of jenkin build 现在,以下是jenkin build的控制台输出

  1. Copying 复制中
    /var/lib/jenkins/workspace/FinalWar/WebContent/WEB-INF/web.xml to /var/lib/jenkins/workspace/FinalWar/WebContent/WEB-INF/web.xml到
    /var/lib/jenkins/workspace/FinalWar/build/WebContent/WEB-INF/web.xml /var/lib/jenkins/workspace/FinalWar/build/WebContent/WEB-INF/web.xml
  2. File copy complete. 文件复制完成。 war:Creating WAR file ... Then war:正在创建WAR文件... 然后
  3. BUILD FAILED /var/lib/jenkins/workspace/FinalWar/build.xml:39: 失败/var/lib/jenkins/workspace/FinalWar/build.xml:39:
  4. Deployment descriptor: 部署描述符:
    /var/lib/jenkins/workspace/FinalWar/build/WEB-INF/web.xml does not /var/lib/jenkins/workspace/FinalWar/build/WEB-INF/web.xml不
    exist.* 存在。*

My question is while copying[step 1] web.xml it is getting copied to build/WebContent/WEB-INF/web.xml 我的问题是在复制[步骤1] web.xml时,它正在复制到build / WebContent / WEB-INF / web.xml

But while creating War why it is searching[step 4] for /build/WEB-INF/web.xml 但是在创建战争时为什么要搜索[步骤4] /build/WEB-INF/web.xml

检查路径..您正在将其复制到build / WebContent / WEB-INF并尝试从build / WEB-INF中读取...通过包括WebContent来更正读取路径。

First, you need to decide if this is a Jenkins issue or an issue with the build itself. 首先,您需要确定这是Jenkins问题还是内部版本问题。

  1. Does it build on your machine. 它是否在您的计算机上构建。 If it doesn't, your build itself has a problem. 如果没有,您的构建本身就有问题。
  2. If it builds on your machine, do the following: 如果它在您的计算机上构建,请执行以下操作:
    1. Disable the project that's building. 禁用正在构建的项目。 You don't want Jenkins to suddenly start building while you're playing around. 您不希望詹金斯在玩耍时突然开始构建。
    2. In Jenkins, there's a workspace folder in that project. 在Jenkins中,该项目中有一个工作区文件夹。 Go into that folder and see if FinalWar/build/WebContent/WEB-INF/web.xml actually exists. 进入该文件夹,查看FinalWar/build/WebContent/WEB-INF/web.xml实际存在。 If not, you may have an error in your build.xml itself. 如果没有,您的build.xml本身可能有错误。 If it does... 如果可以...
    3. Log into the Jenkins server. 登录到Jenkins服务器。
    4. Go into the Jenkins Home directory, then jobs , then the project name, then workspace . 进入詹金斯主目录,然后jobs ,然后将项目名称,然后workspace This is where Jenkins is running the build. 这是Jenkins运行构建的地方。
    5. Try doing the build here. 尝试在此处进行构建。 You may have to set your $PATH to pick up the correct version of Ant and the JDK you want to use. 您可能需要设置$PATH来选择要使用的正确版本的Ant和JDK。

Jenkins doesn't do anything unusual with the build. Jenkins对该版本没有做任何异常。 It run Ant just like you would from the command line. 它就像在命令行中一样运行Ant。 In fact, if you look at the Console output, you'll even see the command line Jenkins used. 实际上,如果您查看Console输出,您甚至会看到Jenkins使用的命令行。

There can be issues with builds failing in Jenkins, but not on your command line. 在Jenkins中,构建可能会失败,但在命令行中却不会。 Normally, you'll see Jenkins declare a BUILD SUCCESSFUL only to declare it failed a few lines later. 通常,您会看到Jenkins声明BUILD SUCCESSFUL只是在几行之后声明它失败。 This is usually due to a misconfigured post build process -- for example, you attempt to archive an artifact that doesn't exist, or display a test result from a XML file that doesn't exist. 这通常是由于配置错误的后期构建过程引起的-例如,您尝试归档不存在的工件,或显示不存在的XML文件中的测试结果。

Most of the time, failed Jenkins builds are due to the build itself having problems, and not doing exactly what you want. 大多数情况下,Jenkins构建失败的原因是构建本身存在问题,而不是完全按照自己的意愿进行。 The first thing when a build fails is to do a CLEAN checkout on your local machine, and try a build. 构建失败时的第一件事是在本地计算机上进行CLEAN签出,然后尝试构建。 If that works, try running the build from the workspace on the Jenkins build server itself. 如果可行,请尝试从Jenkins构建服务器本身的workspace运行构建。

And, before you play around with the workspace on the build server, disable the Jenkins project (and don't forget to reenable it after you finished). 并且,在构建服务器上使用工作区之前,请禁用Jenkins项目(并且不要忘了在完成后重新启用它)。 This way, Jenkins isn't messing up the workspace while you're analyzing what went wrong. 这样,Jenkins不会在分析出问题时弄乱了工作区。

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

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