Jenkins 解决Git插件不兼容问题的方案
简介
Jenkins 解决Git插件不兼容问题的方案,很多时候由于项目打包需求的插件版本不同,导致jenkins加载插件失败或者配置经常丢失。今天我们主要解决Git插件不兼容或者版本问题。当然方案很多种,这里我们使用的是不依赖Git插件的方式。
服务器环境
主机系统:CentOS 7 i5 4核心 4GB内存
服务器:Tomcat + Jenkins
项目:Android打包
解决原理
jenkins参数化构建过程是有顺序的,我们在build的项目之前选择Execute Shell来git clone 或者更新代码。以下整个配置都是关于【构建选项】模块的配置。
步骤1:验证用户名和密码
在linux bash中通过git clone 项目输入自己的用户名和密码,这一步可以让linux系统将用户名和密码保存在本地。
步骤2:使用脚本下载或者更新代码
更新代码的脚本如下:
#!/bin/bash echo 'Start GitClient for using git to update the project to '`pwd` declare GITURL='http://[你的项目地址]' #如https://gitee.com/cn_lyjuan/BaseUtil-Android.git declare git_cmd='/usr/local/git/bin/git' echo 'GitServer Address : ' ${GITURL} echo 'git rev-parse --is-inside-work-tree' declare needUpdate=false $git_cmd rev-parse --is-inside-work-tree >/dev/null 2>&1 if [ $? -eq 0 ] then needUpdate=true else needUpdate=false fi echo 'needUpdate is ' ${needUpdate} if [ $needUpdate != true ] then echo 'git clone the remote project from '${GITURL} rm -rf .git echo 'git init '`pwd` $git_cmd init `pwd` echo '------------start fetching--------------------' echo 'git --version' $git_cmd --version echo 'git -c core.askpass=true fetch --tags --progress' ${GITURL} '+refs/heads/*:refs/remotes/origin/*' $git_cmd -c core.askpass=true fetch --tags --progress ${GITURL} +refs/heads/*:refs/remotes/origin/* echo 'git config remote.origin.url' ${GITURL} $git_cmd config remote.origin.url $GITUR echo 'git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/*' $git_cmd config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* echo 'git config remote.origin.url' ${GITURL} $git_cmd config remote.origin.url ${GITURL} echo '--------fetching upstream changes from '${GITURL} '----------' echo 'git -c core.askpass=true fetch --tags --progress' ${GITURL} '+refs/heads/*:refs/remotes/origin/*' $git_cmd -c core.askpass=true fetch --tags --progress ${GITURL} +refs/heads/*:refs/remotes/origin/* echo 'git rev-parse refs/remotes/origin/master^{commit}' declare commitId=$( $git_cmd rev-parse refs/remotes/origin/master^{commit} ) echo $commitId $git_cmd rev-parse refs/remotes/origin/origin/master^{commit} >/dev/null 2>&1 if [ $? -eq 0 ] then commitId=$( $git_cmd rev-parse refs/remotes/origin/origin/master^{commit} ) fi echo '---------Checkout out Revision ' ${commitId}'--------' echo 'git config core.sparsecheckout' $git_cmd config core.sparsecheckout echo 'git checkout -f ' ${commitId} $git_cmd checkout -f ${commitId} echo 'unset varibiant' unset commitId else echo 'git config remote.origin.url' ${GITURL} $git_cmd config remote.origin.url $GITURL echo 'git --version' $git_cmd --version echo 'git fetch --tags --progress' ${GITURL} '+refs/heads/*:refs/remotes/origin/*' $git_cmd fetch --tags --progress ${GITURL} +refs/heads/*:refs/remotes/origin/* echo 'git rev-parse origin/master^{commit}' declare commitId=$( $git_cmd rev-parse origin/master^{commit} ) echo '-------fetching upstream of Revision is ' ${commitId} '-----' echo 'git config core.sparsecheckout' $git_cmd config core.sparsecheckout echo 'git checkout -f' ${commitId} $git_cmd checkout -f $commitId echo 'git rev-list '${commitId} $git_cmd rev-list $commitId -1 unset commitId fi $git_cmd log -1 unset GITURL unset git_cmd echo 'finishly execute this script'
步骤3:配置打包参数
综上:我们可以解决Git插件不兼容的问题。本人对shell语法掌握不够熟练,以上脚本还有改造的潜能,如果有需要您可以自行改造。
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
python通过web3py链接以太坊区块链节点的几种方式
通信服务提供接口是web3如何与区块链交互的关键。接口接受JSON-RPC请求并返回响应。这通常通过将请求提交给基于HTTP或IPC套接字的服务器来完成。 如果你已经愉快地连接到你的以太坊节点,那么你可以跳过这部分内容。 选择如何连接到你的节点 大多数节点都有多种连接方式。如果你尚未确定要使用哪种节点,请转到如何选择要使用的节点? 连接节点的最常用方法是: 1.IPC(使用本地文件系统:最快,最安全) 2.Websockets(远程工作,比HTTP更快) 3.HTTP(更多节点支持它) 如果你不确定如何决定,请选择以下方式: 如果你可以选择在与节点相同的计算机上运行Web3.py,请选择IPC。 如果必须连接到其他计算机上的节点,请使用Websockets。 如果你的节点不支持Websockets,请使用HTTP。 大多数节点都有“关闭”连接选项的方法。我们建议你关闭所有未使用的连接选项。这提供了更安全的设置:它减少了恶意黑客可以试图窃取你的以太币的方式。 确定连接后,可以使用通信服务提供接口Provider指定详细信息。通信服务提供接口Provider程序是为所需类型的连接配置的We...
- 下一篇
MySQL之SQL优化实战记录
MySQL之SQL优化实战记录 背景 本次SQL优化是针对javaweb中的表格查询做的。 部分网络架构图 业务简单说明 N个机台将业务数据发送至服务器,服务器程序将数据入库至MySQL数据库。服务器中的javaweb程序将数据展示到网页上供用户查看。 原数据库设计 windows单机主从分离 已分表分库,按年分库,按天分表 每张表大概20w左右的数据 原查询效率 3天数据查询70-80s 目标 3-5s 业务缺陷 无法使用sql分页,只能用java做分页。 问题排查 前台慢 or 后台慢 如果你配置了druid,可在druid页面中直接查看sql执行时间和uri请求时间 在后台代码中用System.currentTimeMillis计算时间差。 结论 : 后台慢,且查询sql慢 sql有什么问题 sql拼接过长,达到了3000行,有的甚至到8000行,大多都是union all的操作,且有不必要的嵌套查询和查询了不必要的字段 利用explain查看执行计划,where条件中除时间外只有一个字段用到了索引 备注 : 因优化完了,之前的sql实在找不到了,这里只能YY了。 查询优化 去除...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- SpringBoot2配置默认Tomcat设置,开启更多高级功能
- MySQL8.0.19开启GTID主从同步CentOS8
- Red5直播服务器,属于Java语言的直播服务器
- SpringBoot2初体验,简单认识spring boot2并且搭建基础工程
- SpringBoot2更换Tomcat为Jetty,小型站点的福音
- SpringBoot2整合Redis,开启缓存,提高访问速度
- SpringBoot2整合Thymeleaf,官方推荐html解决方案
- CentOS7,CentOS8安装Elasticsearch6.8.6
- Hadoop3单机部署,实现最简伪集群
- CentOS8编译安装MySQL8.0.19