每次我试图从命令行调用Ant构建文件时,我都会收到一个错误:
无法写入日志文件
我是不是遗漏了什么?请告诉我,因为我正在尝试使用Ant从命令提示符运行Junit批处理文件。
<?xml version="1.0" encoding="UTF-8"?>
<project name="AntTest" basedir=".">
<description>
AntTest project build file.
</description>
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="bin"/>
<property name="ExternalLibraries" location="ExternalLibraries"/>
<property name="JenkinsResults" location="Results/JenkinsResults"/>
<property name="TestSuiteName" location="${src}/AntTest.testsuite"/>
<!--Set the classpath for compiling the source files-->
<path id="AntTest.classpath">
<fileset dir="${ExternalLibraries}">
<include name="**/*.jar"/>
</fileset>
<pathelement location="${build}"/>
<pathelement location="${Results}"/>
</path>
<!--Set the framework properties required for the run-->
<target name="setFrameworkProperties">
<propertyfile file="framework.properties" >
<entry key="browser" operation="=" value="${Browser}" />
<entry key="url" operation="=" value="${Url}" />
<entry key="Environment" operation="=" value="${Environment}" />
</propertyfile>
</target>
<!--Creates the directory for the classes-->
<target name="createBuildFolder" depends="setFrameworkProperties">
<mkdir dir="${build}"/>
</target>
<!--Creates the Jenkins results folder-->
<target name="createResultsFolder" depends="createBuildFolder">
<mkdir dir="${JenkinsResults}"/>
</target>
<!--Deletes the old build jenkins results files-->
<target name="DeleteContentsOldResultsFolder" depends="createResultsFolder">
<delete>
<fileset dir="${JenkinsResults}">
<include name="**/*.*"/>
</fileset>
</delete>
</target>
<!--Compile the source code from the source folder to the build folder-->
<target name="compile" depends="DeleteContentsOldResultsFolder" description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}" includeantruntime="false">
<classpath refid="AntTest.classpath" />
</javac>
</target>
<target name="runtestsuite" description="runs a junit testsuite" >
<antcall id="compileTargetCall" description="Call to target compile" target="compile"/>
<!-- runs a testsuite -->
<junit printsummary="yes" haltonfailure="no">
<classpath refid="AntTest.classpath" />
<test name="${TestSuiteName}" haltonfailure="no" todir="${JenkinsResults}">
<formatter type="xml"/>
</test>
</junit>
<antcall id="deleteBuildFolderCall" description="Call to delete build folder" target="deleteBuildFolder" />
</target>
<!--Deletes the directory for the classes after the current run-->
<target name="deleteBuildFolder">
<delete dir="${build}"/>
</target>
</project>
异常上似乎没有打印太多信息。在浏览时,我现在想到了这个,它可以帮助你获得更多关于异常的详细信息。
还有一件事是你是否使用了log4j或任何对它的引用。你可以检查这个来摆脱对log4j 的引用
谢谢,Murali
我已经通过一些尝试和错误解决了上述错误,但不确定这是否对其他人100%有效,但我所做的是分享我的经验。
步骤
- 服务jenkins stop或sudo/etc/init.d/jenkins stop
- 确保所有服务都已停止。即使你也不应该从浏览器访问jenkinsurl
- 检查rpm-qa|grep-jenkins。它会显示你的詹金斯转速包装
-
运行find/name jenkins以检查在何处使用了所有jenkins。
[root@localhost]#查找/-name"jenkins"
/etc/rc.d/init.d/jenkins
/etc/logrotate.d/jenkins
/etc/sysconfig/jenkins
/usr/lib/jenkins
/var/lib/jenkins
/var/cache/jenkins
/var/cache/yum/jenkins
/var/log/jenkins
[root@localhost]#
-
将/var/lib/jenkins/文件夹备份到/var/lib/jenkins.old
-
现在运行"rpm-e--nodeps jenkins-1.651.3-1.1"以删除包裹
-
再次重复步骤4,并确保/var/cache/jenkins和/var/cache/yum/jenkins是保留的两个目录
-
现在运行"rpm-ivh/etc/yum.repos.d/jenkins-1.651.3-1.1.noarch.rpm"安装詹金斯软件包
-
运行"service jenkins start",以便它在8080 端口上侦听
-
打开带有IP和Port.的詹金斯url
-
创建一个具有某些名称的自由样式项目,并确保项目应在/var/lib/jenkins/jobs/project_name中创建
-
配置必要的步骤,如JDK安装、Ant安装等,在管理詹金斯选项。
-
现在,在不配置build.xml的情况下运行项目的构建路径,以便它将在/var/lib/jenkins/workspace/project_name
-
现在,从现有项目中复制build.xml文件,并放置该文件在/var/lib/jenkins/workspace/project_name中
-
从Jenkins构建项目。
-
尝试解决脚本标签错误,例如它会抱怨找不到lib、src文件夹,并复制/创建要解决的文件夹编译错误。
-
一旦完成所有错误,请尝试再次运行构建,以便将获得生成成功。
-
确保您复制/创建src和lib文件夹,而不是复制/创建目标文件夹。
-
确保目标文件夹必须由Jenkins自动创建拥有詹金斯的所有权和詹金斯的文件权限。休息所有可能根所有者和根文件权限。
-
现在配置junit报告和电子邮件通知以获取在电子邮件中生成报告。