当前位置:网站首页>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.
边栏推荐
猜你喜欢

Unreal Engine Graphic Notes: could not be compiled. Try rebuilding from source manually. Problem solving

使用 Neuron 接入 Modbus TCP 及 Modbus RTU 协议设备

深入浅出零钱兑换问题——背包问题的套壳

微软 SQL 服务器被黑,带宽遭到破坏

Apache DolphinScheduler新一代分布式工作流任务调度平台实战-上

日志导致线程Block的这些坑,你不得不防

How to use Jmeter to carry out high concurrency in scenarios such as panic buying and seckill?

详解JVM垃圾回收
![[Yugong Series] July 2022 Go Teaching Course 021-Slicing Operation of Go Containers](/img/ff/f3de4952d64afe36c515a2220bfe9d.png)
[Yugong Series] July 2022 Go Teaching Course 021-Slicing Operation of Go Containers

C# 之 $ – 字符串内插
随机推荐
积分专题笔记-积分的定义
一文理解分布式开发中的服务治理
怎么在本地电脑上运行dist文件
MySQL Explain usage and parameter detailed explanation
Detailed description of iperf3 parameter options
0729放假自习
MySQL Explain 使用及参数详解
一个低级错误导致的诡异现象——走近科学能拍三集,(C语言)最简单的数组元素读取,不正确!?
Is R&D moving to FAE (Field Application Engineer), is it moving away from technology?Is there a future?
详解JVM垃圾回收
初识Apifox——如何使用Apifox做一个简单的接口测试
新手必备!最全电路基础知识讲解
Network/Information Security Top Journal and Related Journals Conference
Only after such a stage of development can digital retail have a new evolution
One article to understand twenty kinds of switching power supply topologies
Integral Special Notes - Definition of Integral
日志导致线程Block的这些坑,你不得不防
Activating data potential Amazon cloud technology reshapes cloud storage "family bucket"
Two solutions for Excel xlsx file not supported
一文读懂二十种开关电源拓扑结构