Jenkins使用
Jenkins布置软件集成编译环境
1. 安装Jenkins服务
2. 安装所有推荐插件
3. 安装git
- 系统管理中,设置git路径
4. 安装ftp插件
- 选择安装
Publish Over FTP
插件,FTP publisher
插件没找到怎么调用Jenkins服务的环境变量
。 - 系统管理中,设置ftp相关信息:服务器地址,用户名,密码,根目录
5. Job配置
- 设置“自定义工作空间”
- 配置Git
- 设置Repository URL(版本库地址)
- 设置Credentials, 使用ssh
- 设置名称
- 设置private key, 选择“Enter directly”
配置Ftp
- 添加构建后操作,选择
Send build artifacts over FTP
- 选择Ftp服务器
- 设置需要上传的文件路径
Source files
,使用workspace的相对径, 如:
Source files: build/win_qt510_x64/${JOB_NAME}_build${GIT_COMMIT}.7z
- 移除路径前缀,只保留文件名
Remove prefix
,如:
Remove prefix: build/win_qt510_x64/
- 设置上传目录
Remote directory
,如:
Remote directory: /publish/client_framework/win_qt510_x64/
- 添加构建后操作,选择
添加构建指令
build Release
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
@echo on
SET PATH=C:\Qt\Qt5.10.1\5.10.1\msvc2015_64\bin;%PATH%
SET projdir=%WORKSPACE%\
SET buildtype=release
CD /D %projdir%
CD ..
MKDIR build_%JOB_NAME%_%buildtype%
CD build_%JOB_NAME%_%buildtype%
qmake.exe %projdir%Framework.pro -r -spec win32-msvc "CONFIG+=%buildtype%"
C:\Qt\Qt5.10.1\Tools\QtCreator\bin\jom.exe -j8
C:\Qt\Qt5.10.1\Tools\QtCreator\bin\jom.exe install
:END
CD ..
RMDIR /S /Q .\build_%JOB_NAME%_%buildtype%\
CD /D %projdir%
build Debug
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
@echo on
SET PATH=C:\Qt\Qt5.10.1\5.10.1\msvc2015_64\bin;%PATH%
SET projdir=%WORKSPACE%\
SET buildtype=debug
CD /D %projdir%
CD ..
MKDIR build_%JOB_NAME%_%buildtype%
CD build_%JOB_NAME%_%buildtype%
qmake.exe %projdir%Framework.pro -r -spec win32-msvc "CONFIG+=%buildtype%"
C:\Qt\Qt5.10.1\Tools\QtCreator\bin\jom.exe -j8
C:\Qt\Qt5.10.1\Tools\QtCreator\bin\jom.exe install
:END
CD ..
RMDIR /S /Q .\build_%JOB_NAME%_%buildtype%\
CD /D %projdir%
生成发布打包
@ECHO on
SET projdir=%WORKSPACE%\
SET targetdir=%projdir%..\win_qt510_x64
ECHO projdir: %projdir%
ECHO targetdir: %projdir%
CD /D %projdir%
REM Remove old dir
RMDIR /S /Q %targetdir%
REM Make new dir
MKDIR %targetdir%
REM Make and copy Doc dir
MKDIR %targetdir%\Doc
XCOPY %projdir%Doc /E /Y /J %targetdir%\Doc\ /EXCLUDE:%projdir%uncopy.list
REM Make and copy Include dir
MKDIR %targetdir%\Include
XCOPY %projdir%Include /E /Y /J %targetdir%\Include\
REM Make and copy Test dir
MKDIR %targetdir%\Test
XCOPY %projdir%Test /E /Y /J %targetdir%\Test\ /EXCLUDE:%projdir%uncopy.list
REM Make and copy Tools dir
MKDIR %targetdir%\Tools
MKDIR %targetdir%\Tools\3rdParty
MKDIR %targetdir%\Tools\Python3
MKDIR %targetdir%\Tools\QJson
MKDIR %targetdir%\Tools\QtCreatorProjectTemplate
MKDIR %targetdir%\Tools\Redis
COPY %projdir%Tools\Tools.pri %targetdir%\Tools\
XCOPY %projdir%Tools\3rdParty /E /Y /J %targetdir%\Tools\3rdParty\ /EXCLUDE:%projdir%uncopy.list
XCOPY %projdir%Tools\Python3 /E /Y /J %targetdir%\Tools\Python3
XCOPY %projdir%Tools\QJson /E /Y /J %targetdir%\Tools\QJson
XCOPY %projdir%Tools\QtCreatorProjectTemplate /E /Y /J %targetdir%\Tools\QtCreatorProjectTemplate
XCOPY %projdir%Tools\Redis /E /Y /J %targetdir%\Tools\Redis
REM Copy build file
MKDIR %targetdir%\Tools\3rdParty\Framework\windows\qt510x64\Debug
MKDIR %targetdir%\Tools\3rdParty\Framework\windows\qt510x64\Release
XCOPY %projdir%Debug /E /Y /J %targetdir%\Tools\3rdParty\Framework\windows\qt510x64\Debug\
XCOPY %projdir%Release /E /Y /J %targetdir%\Tools\3rdParty\Framework\windows\qt510x64\Release\
REM Copy root files
CD /D %projdir%
COPY astyle-project.sh %targetdir%\
COPY Common.py %targetdir%\
COPY CompileHelper.py %targetdir%\
COPY CopyIncludeFile.py %targetdir%\
COPY killall.bat %targetdir%\
COPY killall.sh %targetdir%\
COPY README.md %targetdir%\
CD /D %targetdir%
C:\dev\7-Zip\7z.exe a -mx=9 .\%JOB_NAME%_build%GIT_COMMIT%.7z .\
CD /D %projdir%
MKDIR %projdir%\build
MOVE /Y %targetdir% %projdir%\build\
echo 'copy client framework sdk finished.'