当前位置:网站首页>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.
边栏推荐
- 宝塔搭建DM企业建站系统源码实测
- 函数式接口&Lambda表达式——简单应用笔记
- Network/Information Security Top Journal and Related Journals Conference
- 反射技巧让你的性能提升 N 倍
- LeetCode二叉树系列——94.二叉树的中序遍历
- 信号完整性测试
- Use the R language to read the csv file into a data frame, and then view the properties of each column.
- One article to understand twenty kinds of switching power supply topologies
- Access to display the data
- 详解JVM垃圾回收
猜你喜欢
如何使用 Jmeter 进行抢购、秒杀等场景下,进行高并发?
仿牛客网项目第一章:开发社区首页(详细步骤和思路)
HashSet and LinkedHashSet
An article to understand service governance in distributed development
分布式系统大势所趋,银行运维如何与时俱进?
一文读懂二十种开关电源拓扑结构
电源完整性的去耦和层间耦合电容
[Yugong Series] July 2022 Go Teaching Course 021-Slicing Operation of Go Containers
都说FPGA高端,它到底能干啥?
转行软件测试,报培训班3个月出来就是高薪工作,靠谱吗?
随机推荐
leetcode-990:等式方程的可满足性
2022/07/29 学习笔记 (day19)异常处理
研发转至FAE(现场应用工程师),是否远离技术了?有前途吗?
An article to understand service governance in distributed development
Liunx服务器安装SVN(安装包版)
C语言经典练习题(3)——“汉诺塔(Hanoi)“
MySQL数据库题库
XP电源维修fleXPower电源X7-2J2J2P-120018系列详解
0729放假自习
LeetCode二叉树系列——94.二叉树的中序遍历
Scala
EMC过不了?都是PCB工程师的锅?
How to avoid CMDB becoming a data island?
无法定位程序输入点ucrtbase.abort于动态链接库api-ms-win-crt-runtime-|1-1-0.dll上
Is R&D moving to FAE (Field Application Engineer), is it moving away from technology?Is there a future?
知识图谱之Cypher语言的使用
2022 Hangzhou Electric Multi-School 2nd Game
网络/信息安全顶刊及相关期刊会议
One article to understand twenty kinds of switching power supply topologies
Jetpack Compose 从入门到入门(八)