Jenkins+Git子模块自动拉取代码

jenkins+Git子模块自动拉取代码 添加Git子模块 先克隆想要添加子模块的仓库git clone ssh://git@ip:port/user/project.git,这个是主目录。 进入仓库,添加子模块git submodule add ssh://git@ip:port/user/project.git,和主仓库不同。 ls查看,会有.gitmodules和子模块的项目名。 将生成的文件和目录push到主仓库中。 克隆有子模块的仓库 添加过子模块的仓库,如果想重新克隆,和普通克隆一样,不过克隆后需要在仓库目录下执行 git submodule init和git submodule update,如果不执行,子模块中会没有文件。 更改子模块的分支 切换到子模块目录,默认子模块是master分支,git submodule foreach git checkout dev, 然后使用git submodule foreach git pull切换分支。 需要在jenkins任务的构建步骤中添加git submodule init和git submodule update,以及上述操作(写在这两个命令后面), jenkins才能拉取到代码。 submodule可以进行tag和merge git submodule foreach可以分别对子模块进行操作, 所以对所有子模块进行tag和merge操作, 就相当于对总项目进行相应的操作.

2019-06-01 · 1 分钟

Jenkins Email Extension插件模板

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>${ENV, var="JOB_NAME"}-第${BUILD_NUMBER}次构建日志</title> </head> <body leftmargin="8" marginwidth="0" topmargin="8" marginheight="4" offset="0"> <table width="95%" cellpadding="0" cellspacing="0" style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif"> <tr> <td>(本邮件由程序自动下发,请勿回复!)</td> </tr> <tr> <td> <h2><font color="#FF0000">构建结果 - ${BUILD_STATUS}</font></h2> </td> </tr> <tr> <td> <br /> <b><font color="#0B610B">构建信息</font></b> <hr size="2" width="100%" align="center" /> </td> </tr> <tr> SVN_URL <td> <ul> <li>项目名称:${PROJECT_NAME}</li> <li>GIT路径:${GIT_URL}</li> <li>构建编号:${BUILD_NUMBER}</li> <li>GIT分支:${GIT_BRANCH}</li> <li>触发原因:${CAUSE}</li> <li>构建日志:<a href="${BUILD_URL}console">${BUILD_URL}console</a></li> </ul> </td> </tr> <tr> <td> <b><font color="#0B610B">变更信息:</font></b> <hr size="2" width="100%" align="center" /> </td> </tr> <tr> <td> <ul> <li>上次构建成功后变化 : ${CHANGES_SINCE_LAST_SUCCESS}</a> </li> </ul> </td> </tr> <tr> <td> <ul> <li>上次构建不稳定后变化 : ${CHANGES_SINCE_LAST_UNSTABLE}</a> </li> </ul> </td> </tr> <tr> <td> <ul> <li>历史变更记录 : <a href="${PROJECT_URL}changes">${PROJECT_URL}changes</a></li> </ul> </td> </tr> <tr> <td> <ul> <li>变更集:${JELLY_SCRIPT,template="html"}</a> </li> </ul> </td> </tr> <!-- <tr> <td> <b><font color="#0B610B">Failed Test Results</font></b> <hr size="2" width="100%" align="center" /> </td> </tr> <tr> <td> <pre style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif">$FAILED_TESTS</pre> <br /> </td> </tr> <tr> <td> <b><font color="#0B610B">构建日志 (最后 100行):</font></b> <hr size="2" width="100%" align="center" /> </td> </tr>--> <!-- <tr> <td>Test Logs (if test has ran): <a href="${PROJECT_URL}ws/TestResult/archive_logs/Log-Build-${BUILD_NUMBER}.zip">${PROJECT_URL}/ws/TestResult/archive_logs/Log-Build-${BUILD_NUMBER}.zip</a> <br /> <br /> </td> </tr> --> <!-- <tr> <td> <textarea cols="80" rows="30" readonly="readonly" style="font-family: Courier New">${BUILD_LOG, maxLines=100,escapeHtml=true}</textarea> </td> </tr>--> <hr size="2" width="100%" align="center" /> </table> </body> </html>

2019-06-01 · 2 分钟

Git使用

Git换行符 Git会自动处理换行符的问题, 但是这个在实际开发中会出现问题, 所以, 在Windows上使用提交时转换为LF,检出时不转换功能, 统一使用Unix换行符(也可以在类Unix上启用这个功能, 将拉取的没有改变的换行符更换). Windows打开安装好的Git Bash, 类Unix直接输入: 1 2 git config --global core.autocrlf input git config --global core.safecrlf warn 含义: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 AutoCRLF # 提交时转换为LF,检出时转换为CRLF git config --global core.autocrlf true # 提交时转换为LF,检出时不转换 git config --global core.autocrlf input # 提交检出均不转换 git config --global core.autocrlf false SafeCRLF # 拒绝提交包含混合换行符的文件 git config --global core.safecrlf true # 允许提交包含混合换行符的文件 git config --global core.safecrlf false # 提交包含混合换行符的文件时给出警告 git config --global core.safecrlf warn Git创建分支、 删除本地和远程分支、 创建tag、 修改tag名称 创建分支: git checkout -b develop ...

2019-06-01 · 1 分钟

Docker安装GitLab Runner

docker pull gitlab/gitlab-runner:latest安装gitlab-runner 打开自己搭建的GitLab网站,点击顶栏的Snippets后面的小扳手,再点击左侧列表中Overview中的Runners,在打开的网页下面,可以看到How to setup a shared Runner for a new project行,2是Runners设置时需要指定的URL,3是在设置是的Runners。 运行镜像 docker run -d --name gitlab-runner --restart always -v /var/run/docker.sock:/var/run/docker.sock -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner:latest 注册gitlab-runner docker exec -it gitlab-runner gitlab-runner register, Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):输入域名或者服务器ip地址,格式为https://gitlab.com。和token Please enter the gitlab-ci token for this runner:。 Please enter the gitlab-ci description for this runner:输入runner描述。 Please enter the gitlab-ci tags for this runner (comma separated):给这个Runner指定tags,稍后也可以在GitLab's UI中修改。 Whether to run untagged builds [true/false]:选择Runner是否接受未指定tags的任务,稍后可修改。默认值为false。 ...

2019-06-01 · 2 分钟