Jenkins 没有构建我的 ant 项目

发布于 2024-12-19 20:42:16 字数 2224 浏览 0 评论 0原文

我刚刚开始使用 Jenkins,我只是想用它来执行 phpunit 测试。

我的步骤是:创建文件 build.xml,如这里所说:

<project name="mbp2" default="build">
 <target name="clean">
  <delete dir="${basedir}/build"/>
 </target>

 <target name="prepare">
  <mkdir dir="${basedir}/build/logs"/>
 </target>

 <target name="phpunit">
  <exec dir="${basedir}" executable="phpunit">
   <arg line="-c app --log-junit ${basedir}/build/logs/phpunit.xml src/MyFirm/FrontendBundle/Tests" />
  </exec>
 </target>

 <target name="build" depends="clean,prepare,phpunit"/>
</project>

所以,我执行了 ant 并得到了这个:

javier@javier-mbp:~/programacion/mbp/myfirm$ ant 构建文件: /home/javier/programacion/mbp/myfirm/build.xml

clean: [删除] 删除目录 /home/哈维尔/programacion/mbp/myfirm/build

准备: [mkdir] 创建目录:/home/javier/programacion/mbp/myfirm/build/logs

php单元: [执行] PHPUnit 3.6.4 由 Sebastian Bergmann 编写。 [执行] [exec] 从 /home/javier/programacion/mbp/myfirm/app/phpunit.xml 读取配置 [执行] [执行]............ [执行] [exec] 时间:6 秒,内存:157.50Mb [执行] 好的(15 个测试,18 个断言)

构建:

构建成功总时间:6 秒

然后我在 Jenkins 中创建了一个新作业,选择 git 存储库,如下所示:

文件:///home/javier/programacion/mbp/myfirm/

最后我构建了该项目,所以我希望看到与在没有 Jenkins 的情况下执行 ant 时相同的输出,但什么也没有。

在“Console Output”部分显示如下:

由用户匿名 Checkout 启动:workspace / /var/lib/jenkins/jobs/mbp2/workspace - hudson.remoting.LocalChannel@76996f0c 使用策略:默认最后 内置修订版:修订版 9aafeea09cdb23317f2426f8209c75341565c070 (原点/HEAD,原点/master)签出:工作区/ /var/lib/jenkins/jobs/mbp2/workspace - hudson.remoting.LocalChannel@76996f0c 从 1 个远程获取更改 Git 存储库从以下位置获取上游更改 file:///home/javier/programacion/mbp/myfirm 在存储库中看到分支 origin/HEAD 在存储库 origin/master 中看到分支开始构建修订版 9aafeea09cdb23317f2426f8209c75341565c070 (来源/HEAD,来源/主)检查修订 9aafeea09cdb23317f2426f8209c75341565c070(来源/HEAD,来源/主) 警告:这里有多个分支变更集已完成:成功

哈维尔

I've just started with Jenkins and I'm just trying to use it to execute phpunit tests.

My steps are: create the file build.xml as here says:

<project name="mbp2" default="build">
 <target name="clean">
  <delete dir="${basedir}/build"/>
 </target>

 <target name="prepare">
  <mkdir dir="${basedir}/build/logs"/>
 </target>

 <target name="phpunit">
  <exec dir="${basedir}" executable="phpunit">
   <arg line="-c app --log-junit ${basedir}/build/logs/phpunit.xml src/MyFirm/FrontendBundle/Tests" />
  </exec>
 </target>

 <target name="build" depends="clean,prepare,phpunit"/>
</project>

So, I executed ant and I got this:

javier@javier-mbp:~/programacion/mbp/myfirm$ ant Buildfile:
/home/javier/programacion/mbp/myfirm/build.xml

clean: [delete] Deleting directory
/home/javier/programacion/mbp/myfirm/build

prepare:
[mkdir] Created dir: /home/javier/programacion/mbp/myfirm/build/logs

phpunit:
[exec] PHPUnit 3.6.4 by Sebastian Bergmann.
[exec]
[exec] Configuration read from /home/javier/programacion/mbp/myfirm/app/phpunit.xml
[exec]
[exec] ...............
[exec]
[exec] Time: 6 seconds, Memory: 157.50Mb
[exec]
OK (15 tests, 18 assertions)

build:

BUILD SUCCESSFUL Total time: 6 seconds

Then I created a new job in Jenkins choosing as git repository as below:

file:///home/javier/programacion/mbp/myfirm/

Finally I built the project, so I expected to see the same output as when I executed ant without Jenkins, but nothing about that..

In the "Console Output" section showed as below:

Started by user anonymous Checkout:workspace /
/var/lib/jenkins/jobs/mbp2/workspace -
hudson.remoting.LocalChannel@76996f0c Using strategy: Default Last
Built Revision: Revision 9aafeea09cdb23317f2426f8209c75341565c070
(origin/HEAD, origin/master) Checkout:workspace /
/var/lib/jenkins/jobs/mbp2/workspace -
hudson.remoting.LocalChannel@76996f0c Fetching changes from 1 remote
Git repository Fetching upstream changes from
file:///home/javier/programacion/mbp/myfirm Seen branch in repository
origin/HEAD Seen branch in repository origin/master Commencing build of Revision 9aafeea09cdb23317f2426f8209c75341565c070
(origin/HEAD, origin/master) Checking out Revision
9aafeea09cdb23317f2426f8209c75341565c070 (origin/HEAD, origin/master)
Warning : There are multiple branch changesets here Finished: SUCCESS

Javier

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

泅人 2024-12-26 20:42:16

您需要添加 Ant 构建步骤。 Jenkins 不会做任何你不告诉它的事情。

You need to add an Ant build step. Jenkins doesn't do anything you don't tell it to.

冷了相思 2024-12-26 20:42:16

Jenkins 中的 Ant 配置:

  1. 运行 Jenkins 并浏览它
  2. 单击您的项目/作业名称的链接 -->单击左侧的配置链接
  3. 单击“添加构建步骤”组合,然后从组合中选择“调用 Ant”
  4. 填写 Ant 配置的必要字段并保存,

或者,您可以在 Windows 中执行 ant.bat,如下所示,而不是“调用 Ant”:

  1. 运行 Jenkins 并浏览它
  2. 单击您的项目/作业名称的链接 -->单击左侧的“配置”链接
  3. 单击“添加构建步骤”组合,然后从组合中选择“执行 Windows 批处理命令”
  4. 编写正确的命令(在我的例子中是:C:\apache-ant-1.8.4\bin\ant.bat )并保存

Ant configuration in Jenkins:

  1. Run Jenkins and browse it
  2. Click the link of your project/job name --> Click Configure link at the left
  3. Click "Add build step" combo and select "Invoke Ant" from combo
  4. Fill up necessary fields for Ant configuration and save it

OR, You can execute ant.bat in Windows as below instead of "Invoke Ant":

  1. Run Jenkins and browse it
  2. Click the link of your project/job name --> Click Configure link at the left
  3. Click "Add build step" combo and select "Execute Windows batch command" from combo
  4. Write the proper command (In my case it was: C:\apache-ant-1.8.4\bin\ant.bat) and save it
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文