多人协同过程中,避免不了多人提交,但没及时构建代码,导致代码被复盖。。。。

然后有了现在的自动构建【GitBlit配置groovy进行关联即可 ,或GitHub使用WebHook实现】

【笔者反复上面的操作,还是无法实现Git Push后触发钩子进行job构建】遇到此问题,直接拉到底部看解决方法!!!

一、 安装Jenkins【Git Plugin】 + GitBlit ,且可以正常运行【遇到问题找度娘,哈哈】

二、配置GitBlit - groovy文件

GitBlit目录下【gitblit-1.9.3\data\groovy】,复制一份jenkins.groovy,并重新命名为 myjenkins.groovy【等会儿GitBlit-接收-post-receive 脚本会使用到

编辑myjenkins.groovy的jenkins主页面

找到【def jenkinsUrl】,修改为jenkins访问地址即可

修改完成后,重启GitBlit

修改完成后,重启GitBlit

修改完成后,重启GitBlit

三、添加接收的Jenkins

版本库为本地进行commit&push的仓库【实例使用的版本库就为Jenkins】

点击版本库-编辑,弹出一个List,点击【接收】,post-receive 脚本【把刚才复制并命令的myjenkins选择并保存】

到这里GitBlit已经没什么事了,可以建Jenkins项目,尝试本地commit&push文件,看看jenkins是否正确构建

四、建jenkins项目【这里之前的文章也提及到了,所以这里贴图处理】

本地commit&push到GitBlit,Jenkins就会自动构建

笔者反复上面的操作,还是无法实现Git Push后触发钩子进行job构建。。。。

问题WebHook触发不了并提示权限有误,如下截图:

按提示链接最终找到解决方法:

https://plugins.jenkins.io/git/#plugin-content-push-notification-from-repository

解决方法:

1.在Jenkins添加一个Git Access token并保存,把token复制出来备注:

2.再次编辑GitBlit的【myjenkins.groovy】文件,加上刚才生成token信息 并且保存,重启GitBlit

以下为完整修改后的代码内容:

/** Copyright 2011 gitblit.com.** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at**     http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/
import com.gitblit.GitBlit
import com.gitblit.Keys
import com.gitblit.models.RepositoryModel
import com.gitblit.models.UserModel
import com.gitblit.utils.JGitUtils
import org.eclipse.jgit.lib.Repository
import org.eclipse.jgit.revwalk.RevCommit
import org.eclipse.jgit.transport.ReceiveCommand
import org.eclipse.jgit.transport.ReceiveCommand.Result
import org.slf4j.Logger/*** Sample Gitblit Post-Receive Hook: jenkins** The Post-Receive hook is executed AFTER the pushed commits have been applied* to the Git repository.  This is the appropriate point to trigger an* integration build or to send a notification.* * This script is only executed when pushing to *Gitblit*, not to other Git* tooling you may be using.* * If this script is specified in *groovy.postReceiveScripts* of gitblit.properties* or web.xml then it will be executed by any repository when it receives a* push.  If you choose to share your script then you may have to consider* tailoring control-flow based on repository access restrictions.** Scripts may also be specified per-repository in the repository settings page.* Shared scripts will be excluded from this list of available scripts.* * This script is dynamically reloaded and it is executed within it's own* exception handler so it will not crash another script nor crash Gitblit.* * Bound Variables:*  gitblit         Gitblit Server              com.gitblit.GitBlit*  repository        Gitblit Repository          com.gitblit.models.RepositoryModel*  receivePack        JGit Receive Pack           org.eclipse.jgit.transport.ReceivePack*  user           Gitblit User                com.gitblit.models.UserModel*  commands     JGit commands               Collection<org.eclipse.jgit.transport.ReceiveCommand>*    url             Base url for Gitblit        String*  logger         Logs messages to Gitblit    org.slf4j.Logger*  clientLogger Logs messages to Git client com.gitblit.utils.ClientLogger** Accessing Gitblit Custom Fields:*   def myCustomField = repository.customFields.myCustomField*  */
// Indicate we have started the script
logger.info("jenkins hook triggered by ${user.username} for ${repository.name}")// This script requires Jenkins Git plugin 1.1.14 or later
// http://kohsuke.org/2011/12/01/polling-must-die-triggering-jenkins-builds-from-a-git-hook/// define your jenkins url here or set groovy.jenkinsServer in
// gitblit.properties or web.xml
// def jenkinsUrl = gitblit.getString('groovy.jenkinsServer', 'http://yourserver/jenkins')
def jenkinsUrl = gitblit.getString('groovy.jenkinsServer', 'http://192.168.24.74:9999')// define the repository base url
def jenkinsGitbaseurl = gitblit.getString('groovy.jenkinsGitbaseurl', "${url}/r")// define the trigger url
def triggerUrl = jenkinsUrl + "/git/notifyCommit?url=" + jenkinsGitbaseurl + "/${repository.name}" + "&token=f57bc27f16d3e8e0a8783a1caef7d888"// trigger the build
new URL(triggerUrl).getContent()

重启后,可以进行测试一下;本地Git Push一下,滴滴滴。。。构建成功

其他工程构建后触发
Build after other projects are build

某些环境的构建,相互之间彼此依赖,所以,有些环境必须先安装。对于大型项目而言,会有多个工程需要构建,此时,就可以编排工程的构建顺序,我们可以安排环境工程先构建。

【GitBlit_pull】为前置工程

Jenkins + GitBlit自动构建相关推荐

  1. 怎么把项目推到gitlab上_Gitlab利用Webhook+jenkins实现自动构建与部署

    之前部署了Gitlab的代码托管平台和Jenkins的代码发布平台.通常是开发后的代码先推到Gitlab上管理,然后在Jenkins里通过脚本构建代码发布. 这种方式每次在发版的时候,需要人工去执行j ...

  2. gitlab 自动推送代码到gitee_Gitlab 利用 Webhook+jenkins 实现自动构建与部署

    之前部署了Gitlab的代码托管平台和Jenkins的代码发布平台.通常是开发后的代码先推到Gitlab上管理,然后在Jenkins里通过脚本构建代码发布. 这种方式每次在发版的时候,需要人工去执行j ...

  3. .net 基于Jenkins的自动构建系统开发

    先让我给描述一下怎么叫一个自动构建或者说是持续集成 : 就拿一个B/S系统的合作开发来说,在用SVN版本控制的情况下,每个人完成自己代码的编写,阶段性提交代码,然后测试-修改,最后到所有代码完工,进行 ...

  4. CC00388.CloudKubernetes——|KuberNetesCI/CD.V26|——|Jenkins.v06|自动构建Java应用.v06|报错处理|

    附录一:报错处理一: ### --- 报错现象+ echo Building Project... Building Project... + mvn clean package-Dskip Test ...

  5. jenkins 下自动构建 生成二维码(不使用蒲公英 fir)

    最近蒲公英每个版本只能下载10次了. 我感觉未来免费的东西会越来越不好,所以准备利用Tengine或者tomcat搭建自己 的下载平台. 先说下如何实现吧: 首先jenkins自动打包apk后, 把a ...

  6. CC00384.CloudKubernetes——|KuberNetesCI/CD.V22|——|Jenkins.v02|自动构建Java应用.v02|

    一.Jenkins.job编译生成spring-cloud-demo的镜像文件 ### --- Jenkins.job编译生成spring-cloud-demo的镜像文件~~~ # 创建完成之后会在k ...

  7. CC00389.CloudKubernetes——|KuberNetesCI/CD.V27|——|Jenkins.v07|自动构建NodeJs应用.v01|

    一.创建nodejs-Jenkinsfile ### --- 新建分支:node-pipeline~~~ 新建分支:node-pipeline:+号-->New branch-->Bran ...

  8. CC00385.CloudKubernetes——|KuberNetesCI/CD.V23|——|Jenkins.v03|自动构建Java应用.v03|

    一.创建spring-cloud-demo的资源文件 ### --- 创建spring-cloud-demo的namespace:java-test ~~~ 创建namespace[root@k8s- ...

  9. 实战:向GitHub提交代码时触发Jenkins自动构建

    当我们提交代码到GitHub后,可以在Jenkins上执行构建,但是每次都要动手去执行略显麻烦,今天我们就来实战Jenkins的自动构建功能,每次提交代码到GitHub后,Jenkins会进行自动构建 ...

最新文章

  1. 股价相对于转股价溢价的时候,可转债就是折价状态。这就意味着只要正股保持目前的价格,赚钱的概率较高。...
  2. SpringBoot 2.0 pom.xml 配置(热启动)
  3. 通达信版弘历软件指标_中线公式指标(副图 通达信 贴图)明确文字提示,辅助判断中线走势下载_通达信公式...
  4. 超值爆赞丨Java 程序员推荐的学习教程,刷爆了朋友圈...
  5. 专题导读:新基建环境下的数据资产价值评估与定价
  6. 3 FI配置-企业结构-分配-给公司分配公司代码
  7. 【转】【Java/Android】Toast使用方法大全
  8. python名片管理系统_Python名片管理系统
  9. inline-block,inline,block,table-cell,float
  10. python解析excel函数
  11. 计算机没有无线网卡驱动程序,win10系统的无线网卡驱动没了的解决方法
  12. JAVA Swing主题 简洁扁平化苹果风格主题
  13. 送给天天对着电脑或者已经脖子痛的朋友,超实用颈椎保养法
  14. FileOperatorWSInstaller.zip——上海一网通登录社保下载提示,却无法下载
  15. Linux 使用docker搭建MySQL服务的一些细节问题
  16. python unpacking_Python解包(Unpacking)
  17. 转】用Mahout构建职位推荐引擎
  18. 雷军演讲刷屏,我对项目经理人的发展又有了2点想法……
  19. tableau计算之(三)表计算——分区/寻址——手动计算/快速计算
  20. 51nod1298 圆与三角形

热门文章

  1. windows系统中pyyaml_关于python:如何在Windows 10上安装pyYAML
  2. 动态(gif)、静态图片转换成DataURL(base64编码)格式
  3. php过滤所有中英文标点符号
  4. SMMU架构手册之stream编号(译)
  5. 智能手环功能模块设计_智能手环、功能模块以及智能手表的制作方法
  6. vba 邮件body html,求助VBA发送邮件宏中的Emailbody
  7. RK3399平台开发系列讲解(内核驱动外设篇)6.10、CAN转SPI 控制芯片MCP2515设备树配置
  8. GD32E303ZET6下载提示错误
  9. 音频重采样的基本(我的学习笔记)
  10. Linux 的魅力:访问 Nokia N800 摄像机