1、创建账号文件
2、添加脚本
echo "执行脚本"
pwd
git config --global credential.helper "store --file=/root/jenkins/credential_file"
echo "获取提交信息"
commit_hash=$(git log -n 1 '--grep=ci' '--pretty=format:%H')
msg=$(git show -s --format=%B "$commit_hash")
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"