当前位置:网站首页>Version management of public Jar packages
Version management of public Jar packages
2022-07-30 09:43:00 【AE86Jag】
背景
There is a common one in the projectjar包,The content is some general processing logic,Different business components introduce thisjar包,Some use the official version,有的使用SNAPSHOT版本(The official version is uploaded to the warehouse and the version must be changed,SNAPSHOTversion does not),No matter which version,存在的问题就是,jarThe version of the package is actually not related to the code,If you encounter problems and need to look at the code,We only know which version was introduced,And can not see the corresponding version of the code(jarThe logic of the package will be continuously modified or added with the business),May have an impact on positioning issues.项目是用gradle进行版本管理的,如果是mavenIf so, you can use the same idea to see if it is feasible.
解决方案
After uploading the version successfully,在当前的Commit上打一个tag,并push到远程,The prerequisite is that the new code must be added firstcommit或者push到远程,为了避免这种情况,在上传jarDo a check before,先pushcode to uploadjar包.如果通过DevOps流水线从GitPull the words remotely,No pre-check is required,Because the code is already up to date.
tagIf the name is the official version, use the version name as it directlytag名字,如果是SNAPSHOTThen add a timestamp after it.
代码
uploadArchives {
repositories {
doFirst {
//It's rather simplistic and rude to write,Readers may consider other more elegant ways
if (artifactoryUser != null && artifactoryUser.length() != 0) {
def status = "git status".execute()
String gitStatus = status.inputStream.text
println gitStatus
if (gitStatus.contains("Changes not staged for commit") || gitStatus.contains("Changes to be committed")
|| gitStatus.contains("Your branch is ahead of")) {
throw new RuntimeException("请先提交代码")
}
}
}
mavenDeployer {
repository(url: "http://central.xx.xxx.cn/artifactory/third-release-local") {
authentication(userName: xxxx, password: xxxxx)
}
snapshotRepository(url: "http://central.xxxx.cn/artifactory/third-snapshot-local") {
authentication(userName: xxxx, password: xxxxx)
}
}
doLast {
println "start tag"
String versionStr = version.toString()
String tagName = versionStr.contains("SNAPSHOT") ? versionStr + "-" + System.currentTimeMillis() : version
("git tag -a " + tagName + " -m \"upload archives auto tag\"").execute()
println "tag local success"
("git push origin " + tagName).execute()
println "tag push success"
}
}
}
效果
May encounter upload success,但是tagdid not hit,I think this can be ignored,There is no need to pay to solve this consistency problem anymore,Can finish playingTag失败的,再重新上传.
Some would say change the order,先打Tag,再上传Jar包,If the upload is successful, no processing is required,如果上传失败,那么再把tag删掉,It may also be deletedTagAlso abnormal,如果打Tag代码没问题,The probability of failure is still relatively small,Even if it does, try again.
边栏推荐
- js currying
- 如何使用 Jmeter 进行抢购、秒杀等场景下,进行高并发?
- 读书笔记:《这才是心理学:看穿伪心理学的本质(第10版)》
- MySQL Explain 使用及参数详解
- 函数式接口&Lambda表达式——简单应用笔记
- SRAM与DRAM的区别
- 2022杭电多校第一场
- Unreal Engine Graphic Notes: could not be compiled. Try rebuilding from source manually. Problem solving
- Circuit analysis: constant current source circuit composed of op amp and triode
- 嘉为鲸翼·多云管理平台荣获信通院可信云技术服务最佳实践
猜你喜欢
Jenkins 如何玩转接口自动化测试?
DDR、GDDR、QDR的区别
2022 Hangzhou Electric Multi-School 2nd Game
Apache DolphinScheduler新一代分布式工作流任务调度平台实战-上
An article to understand service governance in distributed development
Excel xlsx file not supported两种解决办法【杭州多测师】【杭州多测师_王sir】
MySQL Explain 使用及参数详解
Golang DES 加解密如何实现?
HashSet和LinkedHashSet
Leetcode - 990: equations of satisfiability
随机推荐
如何组装一个注册中心
iperf3 参数选项详细说明
日志导致线程Block的这些坑,你不得不防
HashSet和LinkedHashSet
C语言经典练习题(3)——“汉诺塔(Hanoi)“
XP电源维修fleXPower电源X7-2J2J2P-120018系列详解
最远点采样 — D-FPS与F-FPS
Functional Interfaces & Lambda Expressions - Simple Application Notes
342 · Valley Sequence
SRAM与DRAM的区别
PyQt5快速开发与实战 7.4 事件处理机制入门 and 7.5 窗口数据传递
嘉为鲸翼·多云管理平台荣获信通院可信云技术服务最佳实践
How to avoid CMDB becoming a data island?
Network/Information Security Top Journal and Related Journals Conference
20个电路能懂5个以上,足以证明你在电子行业混过!
qsort 函数的使用及其模拟实现
Devops和低代码的故事:螳螂捕蝉,黄雀在后
内卷下的智能投影行业,未来何去何从?
公共Jar包的版本管理
怎么在本地电脑上运行dist文件