2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Jenkinsでgitのエラーで失敗してしまう時に確認すること

Posted at

初めに

Jenkinsでgitを使っているジョブがあるときに
例えば、そのジョブの実行中にをgitのプロセス中に強制終了すると次のビルドがgitエラーを出して失敗するようになるかもしれません。

例)

ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://github.com/hogehoge/fugaaa.git
	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java)
	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java)
	at hudson.plugins.git.GitSCM.checkout(GitSCM.java)
	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java)
	at 
(略)

そういうときのいくつかの対処法

ちなみにコンフリクト起こしているときとかはうまくマージしたりcheckoutとかreset --hardとかすれば直る多分きっと。
ジョブ上でgit落としてくる前に何かそういう対策したければpre-scm-buildstepなんてのもある。

1.lockファイルを削除する

たいていこれでいける
エラーログに次のようなログがあったらそのファイルを削除してあげればOK
スクリプトコンソールとかで消してあげれば楽

fatal: Unable to create 'C:/path/to/.git/index.lock': File exists.

2.gitのプロセスを殺す

上記ファイルが消せない場合は恐らくgitのプロセスがゾンビ化してlockファイルをつかんじゃってる可能性がある

なので例えば

powershell

ps git | kill

とかしてgitのプロセスを殺してあげると1の操作ができるようになる。
(なお上記コマンドはほかのgitプロセスも皆殺しにするのでそこだけ注意)

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?