簡體   English   中英

如何在我的Jenkins控制台日志中查看git命令的輸出以進行構建?

[英]How can I see the git command command output in my Jenkins Console Log for a build?

我已經設置並構建了Jenkins,並由git commit和所有這些觸發。 示例日志如下所示:

00:00:00.016 Building in workspace D:\SomeWorkspace
00:00:00.016  > C:\Program Files (x86)\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10
00:00:00.047 Fetching changes from the remote Git repository
00:00:00.047  > C:\Program Files (x86)\Git\bin\git.exe config remote.origin.url http://usr:pwd@gitRepoAddress.git/git/Repo.git # timeout=10
00:00:00.063 Fetching upstream changes from http://usr@gitRepoAddress.git/git/Repo.git
00:00:00.063  > C:\Program Files (x86)\Git\bin\git.exe --version # timeout=10
00:00:00.234 using .gitcredentials to set credentials
00:00:00.234  > C:\Program Files (x86)\Git\bin\git.exe config --local credential.helper store --file=\"C:\Path\To\Temp\git2724877017172338447.credentials\" # timeout=10
00:00:00.250  > C:\Program Files (x86)\Git\bin\git.exe fetch --tags --progress http://usr@gitRepoAddress.git/git/Repo.git +refs/heads/*:refs/remotes/origin/*

我想做的是查看這些git命令的輸出,以便執行雙重檢查git使用的版本,為什么git fetch速度慢等原因,但是我不知道如何顯示它額外的輸出。 有任何想法嗎? 當我從安裝在此Windows框上的git-bash運行這些命令時, git fetch運行得更快,並且我不確定如何調試Jenkins中發生的事情。

Jenkins提供了兩種git實現,一種使用命令行“ git.exe”工具,另一種使用Java稱為JGit實現。 根據示例輸出,它使用前一個。

如果我們查看該實現,例如“ fetch”命令,則似乎只是在成功時丟棄輸出。

fetch命令的實現從此處開始(在回答時鏈接到“ master”的快照):

https://github.com/jenkinsci/git-client-plugin/blob/1a450a5ee993209cc9f27f2a4bfb31bc08a33257/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java#L242

在execute()中稍微向下一點,在第313行,它調用launchCommandWithCredentials(...); 返回命令的輸出。 但是,它沒有存儲在任何地方,因此被丟棄。

跟蹤如何返回輸出:從1337行開始實現launchCommandWithCredentials方法。在1441行,它調用launchCommandIn(...); 依次從1672行開始實施。最后在1689行運行實際命令,並在1691收集命令輸出。 如果返回碼不為0,即存在錯誤,它將在1693行上引發異常(還包含命令輸出),否則返回命令輸出。 這又由launchCommandWithCredentials 1441返回。現在我們回到第313行,在該行中放棄了返回值。

查看checkout命令,似乎在成功時也會丟棄輸出。

如此看來,如果您確實需要輸出,則必須

  1. 更改代碼並運行其修改版本,或者
  2. https://github.com/jenkinsci/git-client-plugin中打開一個問題,並要求他們添加配置設置以啟用輸出的調試日志記錄

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM