Java Jenkins 和 Ant - 无法识别 ant.bat 但环境变量设置良好
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19622677/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jenkins and Ant - ant.bat not recognized but env vars are set well
提问by Blue
I'm trying to set Jenkins to work with Ant but I get the following error:
我正在尝试将 Jenkins 设置为与 Ant 一起使用,但出现以下错误:
Started by user anonymous Building in workspace C:.jenkins\workspace\CI Demo Checking out a fresh workspace because there's no workspace at C:.jenkins\workspace\CI Demo Cleaning local Directory . Checking out https:///svn/CI_Demo/trunk at revision '2013-10-27T19:34:31.549 +0000'
由匿名用户启动 构建在工作区 C:.jenkins\workspace\CI Demo 签出一个新的工作区,因为 C:.jenkins\workspace\CI Demo 没有工作区 清理本地目录。在修订版“2013-10-27T19:34:31.549 +0000”中查看 https:///svn/CI_Demo/trunk
At revision 6 [CI Demo] $ cmd.exe /C '"ant.bat jar && exit %%ERRORLEVEL%%"' 'ant.bat' is not recognized as an internal or external command, operable program or batch file. Build step 'Invoke Ant' marked build as failure Finished: FAILURE
在修订版 6 [CI 演示] $ cmd.exe /C '"ant.bat jar && exit %%ERRORLEVEL%%"' 'ant.bat' 不是内部或外部命令,也不是可运行的程序或批处理文件。构建步骤“调用 Ant”将构建标记为失败完成:失败
however, JAVA_HOME, ANT_HOME and I added the following to "Path": %ANT_HOME%\bin;%JAVA_HOME%\bin
但是,JAVA_HOME、ANT_HOME 和我在“路径”中添加了以下内容:%ANT_HOME%\bin;%JAVA_HOME%\bin
And as you can see the command is recognizable when executed in CMD:
正如您所看到的,在 CMD 中执行时,该命令是可识别的:
C:\Users\Administrator>java -version java version "1.7.0_45" Java(TM) SE Runtime Environment (build 1.7.0_45-b18) Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
C:\Users\Administrator>java -version java version "1.7.0_45" Java(TM) SE Runtime Environment (build 1.7.0_45-b18) Java HotSpot(TM) 64-Bit Server VM(build 24.45-b08,混合模式)
C:\Users\Administrator>ant -version Apache Ant(TM) version 1.9.2 compiled on July 8 2013
C:\Users\Administrator>ant -version Apache Ant(TM) version 1.9.2 2013 年 7 月 8 日编译
C:\Users\Administrator>ant.bat Buildfile: build.xml does not exist! Build failed
C:\Users\Administrator>ant.bat Buildfile: build.xml 不存在!构建失败
I would appreciate our help.
我很感激我们的帮助。
Thank you, N
谢谢你,N
回答by Blue
Changing the service of the Tomcat that was the Jenkins container from localhost to Administrator solved the problem
将作为 Jenkins 容器的 Tomcat 的服务从 localhost 更改为 Administrator 解决了问题
回答by cL83
Please set the JAVA_HOME, ANT_HOME, PATH at the Test Node Configuration page as below. While in your JOB Configuration page, make sure you restrict the job run in the correct Test Node and choose "DEFAULT" for your JDK and ANT VERSION. it shall working :D
请在测试节点配置页面如下设置JAVA_HOME、ANT_HOME、PATH。在 JOB Configuration 页面中,确保限制在正确的测试节点中运行的作业,并为 JDK 和 ANT VERSION 选择“DEFAULT”。它应该工作:D
回答by Gangnus
You should make settings:
您应该进行设置:
- In windows
- In Jenkins configuration
- In Jenkins project
- 在窗口中
- 在詹金斯配置
- 在詹金斯项目中
For concrete settings look at https://stackoverflow.com/a/23015039/715269