小编典典

我该如何解决:尝试在Jenkins上构建Java Web应用程序时,Ant无法“查找文件”?

jenkins

我正在尝试使用Jenkins
CI为NetBeans多层Web应用程序项目建立一个自动构建系统。这个NetBeans项目包含一个EJB项目(用于Web应用程序的业务层)和一个WAR项目(用于应用程序的Web层)。我目前坚持让Ant来编译项目。

我正在使用Windows 8在NetBeans IDE 8.0中进行开发。Jenkins也可以在Windows 8上运行。

我目前正在寻找一个了解如何使用Jenkins和Ant构建EJB项目的人。

到目前为止,我所做的是:

  • 我已经建立了一个NetBeans项目(如上所述)
  • 我已经为项目建立了一个git仓库
  • 我已经建立了詹金斯CI
  • 我可以使用Jenkins CI从git存储库中获取项目
  • 我能够让Jenkins使用Ant清理从git存储库中检索到的项目

我卡住的地方:

成功使用Ant 执行 clean 命令后,我想使 debug 命令起作用。为此,需要编译项目。这是哪里出错了。

我在Jenkins中的Ant调用的“属性”字段中输入了以下属性:

libs.CopyLibs.classpath=C:/Program Files/NetBeans 8.0/java/ant/extra/org-netbeans-modules-java-j2seproject-copylibstask.jar
j2ee.server.home=C:/Program Files/wildfly-8.1.0.Final

在我的Jenkins版本的输出中,我看到以下命令:

[PGB Web应用程序] $ cmd.exe / C’“” C:\ Program Files(x86)\ Jenkins \ tools \
hudson.tasks.Ant_AntInstallation \ Apache_Ant \ bin \ ant.bat“”
-Dlibs.CopyLibs.classpath = C: / Program Files / NetBeans 8.0 / java / ant /
extra / org-netbeans-modules-java-j2seproject-copylibstask.jar“”
-Dj2ee.server.home = C:/ Program Files / wildfly-8.1.0.Final“干净调试 &&退出%%
ERRORLEVEL %%“”

这是我输出的最后一部分:(对我来说似乎最重要的部分)

init:

-init-cos:

-deps-module-jar:

-deps-ear-jar:

deps-jar:

-pre-pre-compile:
    [mkdir] Created dir: C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\build\classes

-pre-compile:

-copy-meta-inf:
     [copy] Copying 2 files to C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\build\classes\META-INF

-do-compile:
    [mkdir] Created dir: C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\build\empty
    [mkdir] Created dir: C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\build\generated-sources\ap-source-output
    [javac] Compiling 5 source files to C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\build\classes

-post-compile:

compile:

-pre-dist:

library-inclusion-in-manifest:

BUILD FAILED
C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\nbproject\build-impl.xml:204: The following error occurred while executing this line:
C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\nbproject\build-impl.xml:806: Warning: Could not find file C:\Program Files (x86)\Jenkins\workspace\PGB Webapp\pgb-ejb\${libs.MySQLDriver.classpath} to copy.

Total time: 1 second
Build step 'Start Ant' marked build as failure
Finished: FAILURE

因此,在此输出中,我看到以下警告:

警告:找不到要复制的文件C:\ Program Files(x86)\ Jenkins \ workspace \ PGB Webapp \ pgb-
ejb \ $ {libs.MySQLDriver.classpath}。

现在,对我来说,这似乎是一个罕见的问题,因为我在互联网上几乎找不到任何东西(或者我使用了错误的搜索字词?)我已经在Google,SO和DuckDuckGo上进行了搜索,我可以只能找到以下有关我的问题的线索:(相当无用,因为此处提到了我得到的警告,但是上下文有所不同..)

https://netbeans.org/bugzilla/show_bug.cgi?id=128505javafx
DataApp演示中的数据库错误

感谢您提供任何帮助,因为我对持续集成系统,开发Web应用程序和构建工具还是很陌生。

另外,我还没有对Maven或Gradle进行过多研究。因此,也许解决该问题的方法也可能是切换到另一个构建工具。


阅读 354

收藏
2020-07-25

共1个答案

小编典典

在我看来,好像没有定义libs.MySQLDriver.classpath属性。当Ant无法解析属性时,它将在输出中使用属性名称。

尝试定义

libs.MySQLDriver.classpath

在詹金斯的属性字段中,您还定义了其他两个属性。

您需要将其指向您的MySQL JDBC驱动程序。

2020-07-25