詹金斯始终把构建成功使用批处理/蝙蝠 [英] Jenkins always considers a build successful using batch/bat

查看:186
本文介绍了詹金斯始终把构建成功使用批处理/蝙蝠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚加入使用批处理文件来构建一个C ++项目的公司。批量做各种各样的事情(更新SVN,现在由詹金斯完成),创建文件夹的建立,建成后删除不必要的文件,拷贝库文件到build文件夹等。

I just joined a company that uses batch files to build a C++ project. The batch does all sorts of things (updates svn, which is now done by jenkins), creates build folders, deletes unnecessary files after building, copies library files to the build folder, etc.

我的问题是詹金斯始终把构建成功,即使没有汇入作业。 .bat文件创建一个名为errormake.txt出问题的时候文件。怎样使詹金斯阅读和标记构建是失败的?

My problem is Jenkins always considers the build successful, even when it´s not. The .bat file creates a file called errormake.txt when something goes wrong. How do I make jenkins read that and mark the build as a failure?

此外,有没有什么办法,我可以找出詹金斯从.bat文件中创建的build文件夹(也许发送一个变量,当我打电话批处理文件)?

Also, is there any way I can find out the build folder Jenkins created from inside the .bat file (maybe send a variable when I call the batch file)?

这是我目前使用调用.bat文件的单行:

This is the single line I'm currently using to call the .bat file:

call "C:\Source\BuildVersion\AppName\build_version.bat"

编辑:另外,该项目分成几个SVN仓库。 %SVN_REVISION%是空白。我怎样才能得到正确的%SVN_REVISION%从第一个存储库(主要的)?

Also, this project is split up into several SVN repositories. %SVN_REVISION% is blank. How can I get the correct %SVN_REVISION% from the first repository (the main one)?

推荐答案

要回答你的每一个问题 -

To answer each of your questions -


  • 詹金斯总是返回SUCCESS,即使工作实际上是失败

詹金斯设置工作状态的基础上,的最后一个命令的结果的报税表中code
跑在每一个的执行Windows批处理命令的块。结果
如果你的最后一个命令是复制some.log D:,结果
詹金斯认为一切都OK结果
(如果复制命令都很好...)

Jenkins sets the status of the Job, based on the return-code of the last command
that ran in each "Execute windows batch command" block.
If your last command is copy some.log D:,
Jenkins thinks everything is OK
(If the 'copy' command went fine...)

使用退出XX EXIT / B XX ,根据您的操作系统,结果
其中'xx'是一些大于零的整数。

Use EXIT xx or EXIT /B xx, depending on your OS,
where 'xx' is some integer greater than zero.

如何让詹金斯标记构建是失败的基础上,日志文件

使用 文本取景器插件 ,如通过提到的 sdmythos_gr

Use the Text-finder Plugin, as mentioned by sdmythos_gr .

有什么办法,我可以找出詹金斯创建build文件夹

有可用作为环境变量几个参数搜索
对于詹金斯下运行的每个脚本 - 在这里看到这些参数的列表:结果
<一href=\"https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project#Buildingasoftwareproject-JenkinsSetEnvironmentVariables\">Jenkins环境变量

There are a few parameters that are available as environment-variables
for each script that runs under Jenkins - see here for the list of those parameters:
Jenkins Environment Variables.

要你的问题:结果


  • %WORKSPACE% - 工作区的绝对路径

  • %BUILD_NUMBER% - 当前版本号,如153

  • %BUILD_ID% - 当前版本ID,如2005-08-22_23-59-59结果
    (YYYY-MM-DD_hh-MM-SS)搜索结果

  • %WORKSPACE% - The absolute path of the workspace
  • %BUILD_NUMBER% - The current build number, such as "153"
  • %BUILD_ID% - The current build id, such as "2005-08-22_23-59-59"
    (YYYY-MM-DD_hh-mm-ss)

如何从第一个存储库中获得正确%SVN_REVISION%

这个答案是从相同的链接:

This answer is from the same link:


  • %SVN_REVISION% - 对于基于Subversion的项目,结果
    此变量包含模块的版本号。结果
    如果您有多个模块指定的,这将不会被设置即可。

  • %SVN_REVISION% - For Subversion-based projects,
    this variable contains the revision number of the module.
    If you have more than one module specified, this won't be set.

希望帮助

这篇关于詹金斯始终把构建成功使用批处理/蝙蝠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆