jenkins windows slave 构建c/c++代码
关于如何再centos系统上的jenkins master下搭建windows系统的jenkins slave节点,本篇博客中不做介绍,如果有需要的话,请参考我的另外一篇博客,在其中介绍了不同系统的jenkins slave的搭建,包含ios的,centos的,windows的,都是以我自己的实际搭建写的,并且有某些特殊情况的说明以及处理,非常适合做Jenkins的分布式构建的搭建链接是https://www.cnblogs.com/zndxall/p/8297356.html。
本篇主要介绍如何在jenkins master上设置jenkins slave 构建c/c++的包。
1.在‘系统管理’--> "Global Tool Configuration"设置msbuild 配置,如下:

其中Name可以随意写,后面在任务设置中会使用到,最后设置和版本相关的,路径为你的jenkins slave上的msbuild.exe所在的目录,我的填写:
Name: MSBuild 14.0
Path to MSBuild:C:\Program Files (x86)\MSBuild\14.0\Bin
这时你可以会问,你的jenkins master是centos的系统啊,这个路径明显就是windows的路径啊,你不是应该去jenkins 的节点管理那里设置windows 节点吗?这个时候,上面截图中的黄色的提示语就很好的告诉了我们:
C:\Program Files (x86)\MSBuild\14.0\Bin is not a directory on the Jenkins master (but perhaps it exists on some agents)
他告诉我们这个地址master上不存在,可能在某个slave 节点上。所以,相信我,这样配置msbuild是没问题的。
一种方法是:用插件构建
在任务设置的时候,设置构建在节点上进行,节点的设置如下:

在添加构建步骤时选择msbuild,如下:

设置如下:

其中:
MSBuild Version: 就是上一步骤中设置的MSbuild的Name。
MSBuild File:是要构建的工程的sln的文件的路径。
Command Line Arguments: 是要执行的命令,/t:Rebuild /p:Configuration=Release;Platform=x86,其中Configuration 接的是构建类型,可是是Debug,也可以是Release;而Platfom指的是对应的平台,可以是x86,也可以是x64(但是遇到了一个问题,把x86换成Win32,一直报命令错误,不清楚怎么回事,大家可以试试,如果有明白的,可以在评论里给大家解释下)
其他的设置,比如代码下载之类的,就不细说了,和jenkins master上配置是一样的。接下来就可以构建啦~~~
另一种方法:脚本实现
此外,一般情况,除了单纯的构建,我们还需要指定分支,并切换到对应分支,构建结束后回收对应的文件到ftp上,这时你就可以用脚本实现了,脚本win_build.bat中的代码如下,供参考:
@echo off
echo vs_home=%VS2015_HOME%
set devenv="%VS2015_HOME%\Common7\IDE\devenv.com"
set msbuild="C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe"
set vcvars="%VS2015_HOME%\VC/vcvarsall.bat"
set ftp_dir=\\192.168.8.2\ftp\output\Test
set cur_path=%cd%
set datevar=%date:~0,4%%date:~5,2%%date:~8,2%
set mytime=%time:~0,2%%time:~3,2%
set result_dir=%datevar%%mytime%
:: build type, debug or release
set type=%1
::build platform, x86 or x64
set platform=%2
::project sln name
set proj=%3
::build branch
set b_branch=%4
set sln_file=%cur_path%\build\win32\lesdk.sln
echo "++++++++++++input config:type=%type%,platform=%platform%,proj=%proj%,b_branch=%b_branch%+++++"
git checkout %b_branch%
git pull
echo "check branch:"
git branch
echo "=====================set %platform% env========================"
if "%platform%"=="x86" call %vcvars% x86
if "%platform%"=="x64" call %vcvars% x86_amd64
echo "==============starting build %platform% %type%================="
%msbuild% %sln_file% /t:Rebuild /p:Configuration=%type%;Platform=%platform%
::devenv 的 /projectconfig 必须和/project 参数一起使用
::%devenv% /Rebuild %type% %proj%.sln /project "%proj%/%proj%.vcxproj" /projectconfig "%type%|%platform%"
echo "===================copy result to ftp =========================="
echo result_dir=%result_dir%_%b_branch%_%platform%_%type%_lesdk
md target\%result_dir%_%b_branch%_%platform%_%type%_lesdk
move bin\win32\%type%\*.dll target\%result_dir%_%b_branch%_%platform%_%type%_lesdk\
move framecore\poco\bin\*.dll target\%result_dir%_%b_branch%_%platform%_%type%_lesdk\
xcopy /S /E /Y %cur_path%\target %ftp_dir%\
echo ftp_path=%ftp_dir%\%result_dir%_%b_branch%_%platform%_%type%_lesdk
然后在jenkins上设置bat脚本构建,构建命令为: call win_build.bat Debug x86 master
(参数Debug是构建类型,x86是平台,master是分支)
(这个插一句,以我的实际操作证明在jenkins 节点管理处设置msbuild 是没用的:
我也去jenkins 节点管理出查找看能否设置,尽管我设置了msbuild.exe的路径,如下:

这样你会发现在使用第一种方式构建(即插件构建)时,没有MSBuild Version可以选择)
jenkins windows slave 构建c/c++代码的更多相关文章
- jenkins windows slave 报错ERROR: Error cloning remote repo 'origin'
在slave上是git clone ssh是可以成功的,但是jenkins调用slave节点就报如下错误: ERROR: Error cloning remote repo 'origin' huds ...
- jenkins 'cordova' command not recognised on Jenkins Windows slave
在jenkins里构建ionic项目.在构建Execute Windows bath command 执行 cordova 跟ionic 命令失败.但是运行cmd却能够执行成功. 惊不惊喜 意不意外, ...
- jenkins配置slave节点 构建项目并执行操作
1.新建与配置结点 [系统管理]-> [管理结点]-> [新建结点] 2.配置slave 说明: Name: 定义slave的唯一名称标识,可以是任意字符串,通常设置为slave主机名.i ...
- Jenkins 六: 构建中执行shell或者 windows的批处理程序
Shell/ bat Jenkins 可以在构建中执行shell命令或者windows的batch 命令. 1. 选择一个项目,点击“配置”. 2. 找到“构建” –> “增加构建步骤”.选择 ...
- Jenkins 为Jenkins添加Windows Slave远程执行python项目脚本
为Jenkins添加Windows Slave远程执行python项目脚本 by:授客 QQ:1033553122 测试环境 JAVA JDK 1.7.0_13 (jdk-7u13-windows ...
- jenkins持续集成(windows slave+svn+.net)
一.Windows slave配置 1.系统管理->节点管理->新建节点 2.节点列表中点击新增的节点名称按提示下载agent.jar, 在windows slave机器执行(copy页面 ...
- 基于Kubernetes构建企业Jenkins master/slave CI/CD平台
搭建平台目的: k8s中搭建jenkins master/slave架构,解决单jenkins执行效率低,资源不足等问题(jenkins master 调度任务到 slave上,并发执行任务,提升任务 ...
- Jenkins的Windows Slave的配置
原文:http://www.cnblogs.com/itech/archive/2011/11/09/2243025.html 参考: https://wiki.jenkins-ci.org/disp ...
- 配置Jenkins的slave节点的详细步骤适合windows等其他平台(转)
@ 新建一个slave节点在Jenkins服务器上 1,进入Jenkins的主界面,进入“Manage Jenkins” 页面: 2,点击如下图中的“Manage Nodes”: 3,进入页面后点 ...
随机推荐
- url自动补全index.php
location / { index index.html index.htm index.php l.php; autoindex on; if (!-e $request_filename) { ...
- xml文件以及解析
1.创建一个xml文件 <?xml version="1.0" encoding="UTF-8"?> <!-- xml:是一个可扩展的标记语言 ...
- GIAC深圳站 | 2018年不可错过的全球互联网架构大会!
2018年6月1~2日,GIAC 全球互联网架构大会将于深圳华侨城洲际酒店举行!GIAC全球互联网架构大会是由msup和高可用架构技术社区联合举办的面向架构师.技术负责人及高端技术从业人员的技术架构大 ...
- .NET Core开发日志——Entity Framework与PostgreSQL
Entity Framework在.NET Core中被命名为Entity Framework Core.虽然一般会用于对SQL Server数据库进行数据操作,但其实它还支持其它数据库,这里就以Po ...
- 关于Java程序流程控制的整理(已完善)
- jdbc实现分页,需要前端传当前页码
1.封装一个公共实体类用于返回:实体数据,当前页,总页数,总条数,每页多少条 public class PageInfo<T> { //一页显示的记录数 private int numPe ...
- Signing for "XXXX" requires a development team.
[iOS]Signing for requires a development team. Select a development team in the project editor. Code ...
- [web][nginx] 初识nginx -- 使用nginx搭建https DPI解码测试环境
环境 CentOS 7 X86 文档: https://nginx.org/en/docs/ 安装: [root@dpdk ~]# cat /etc/yum.repos.d/nginx.repo [n ...
- LeetCode 566 Reshape the Matrix 解题报告
题目要求 In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a ...
- LeetCode 804 Unique Morse Code Words 解题报告
题目要求 International Morse Code defines a standard encoding where each letter is mapped to a series of ...