1、创建账号文件
2、添加脚本
echo "执行脚本" pwd git config --global credential.helper "store --file=/root/jenkins/credential_file" echo "获取提交信息" msg=$(git log -n 1 --grep=ci --pretty=format:"%s") echo "获取日期" dd=$(date +"%Y%m%d") echo "获取合并分支名" merges=$(git log --merges -n 1 --pretty=format:"%s") match=$(echo "$merges" | grep -oE "Merge branch '([^']+)") extracted="${match//Merge branch '/}" echo "自动创建tag" git tag -a tag-$dd-$extracted-${BUILD_ID} -m "$msg" git push origin --tags echo "自动执行tag"
标签:脚本,git,--,merges,echo,tag,jenkins From: https://www.cnblogs.com/raorao1994/p/17869737.html