当前位置:   article > 正文

Jenkins 自动创建Git tag遇到的坑_jenkins git tag 提交获取不到动态

jenkins git tag 提交获取不到动态

自动创建Git标签

需求 想要jenkins每次构建项目成功后给Git仓库打一个tag,以便下次构建出现问题可以及时通过tag恢复到上一个版本

  1. 创建一个Jenkins任务
  2. 配置《源码管理》,这里配置比较特殊的地方需要在高级选项中配置仓库的名字,后面创建tag的时候需要使用;
    在这里插入图片描述
  3. 在《构建后操作》操作中选择"Git Publisher",来配置发布后执行的任务。
    在这里插入图片描述
  4. 配置完成,保存配置信息,点击立即构建进行项目编译;
  5. 从控制台打印的log我们可以看到我们的tag已经生成 在这里插入图片描述

我遇到的坑

在刚开始研究使用Jenkins自动打tag时候一直不成功,查了好久也没找到原因,报如下错误:

using credential 640821c9-e50e-43f3-9747-773408bff018
 > git.exe tag -l v1.0.1 # timeout=10
 > git.exe tag -a -f -m Jenkins自动化生成Tag v1.0.1 # timeout=10
ERROR: Failed to push tag v1.0.1 to pig
hudson.plugins.git.GitException: Could not apply tag v1.0.1
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.tag(CliGitAPIImpl.java:1531)
	at hudson.plugins.git.GitAPI.tag(GitAPI.java:274)
	at hudson.plugins.git.GitPublisher.perform(GitPublisher.java:277)
	at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
	at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1073)
	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
	at hudson.model.Run.execute(Run.java:1841)
	at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)
Caused by: hudson.plugins.git.GitException: Command "git.exe tag -a -f -m Jenkins自动化生成Tag v1.0.1" returned status code 128:
stdout: 
stderr: 
*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'SYSTEM@*********.(none)')

	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2042)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2010)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2006)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1638)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1650)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.tag(CliGitAPIImpl.java:1529)
	... 11 more
Build step 'Git Publisher' marked build as failure
Finished: FAILURE
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41

之前遇到过Jenkins执行scp命令报 scp 不是内部或外部命令,也不是可运行的程序,或批处理文件。 的错误,但是打开Dos窗口执行scp命令就可以正常执行,经过一些文章查找,有看到过是账户权限问题,对于上面的错误,我也怀疑是这个问题所致,所以做如下操作:

注:本人Jenkins是放在自己开发机上,是Windows环境

  1. 打开系统服务,找到Jenkins服务 在这里插入图片描述
  2. 右单击Jenkins服务->属性->登入 选择此账户->浏览->高级->立即查找,选择具有管理员权限的账户,输入正确的密码,点击确定,回到服务列表页面,重启Jenkins服务
    在这里插入图片描述
  3. 至此问题解决!
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/神奇cpp/article/detail/969513
推荐阅读
相关标签
  

闽ICP备14008679号