2017-04-20 66 views
0

嗨即使我的ant構建失敗,TFS顯示該步驟仍然成功並進一步進行。我嘗試過使用failonerror,但似乎很少有failonerror工作的任務。是否有解決方法,以便在ANT構建失敗時TFS實際上失敗。TFS顯示失敗的ANT構建成功

回答

0

您可以使用logging commands從powershell腳本中返回警告和錯誤。首先趕上ant構建日誌並確定ant構建是否失敗。然後在PowerShell構建任務中使用task.logissue type=error,您可能會失敗構建任務,然後構建失敗。

更多的細節你可以看看這個類似的問題:Is it possible to raise and display build warnings from build steps using TFS 2015

+0

請你詳細說明一下嗎?我如何使用task.logissue類型錯誤,一旦我運行批處理腳本來發現構建失敗。我該如何構建任務和構建失敗? –

+0

@uttarabhosale你可以在PowerShell腳本中編寫這個腳本,比如''Write-Host「## vso [task.logissue type = error;] Test error」然後powershell任務失敗,整個構建失敗。更多細節請參閱* mattbrooks2010 *的評論在上面的鏈接:https://github.com/Microsoft/vsts-tasks/issues/573 –

+0

嗨帕特里克,我得到錯誤日誌下的問題。但是我的powershell腳本不能識別日誌中的Build Failed字符串。這是我寫的代碼:$ printCode = [int] $ res.StatusCode Write-Host「Result Status Code:」$ res.StatusCode「(」$ printCode「)」If([int] $ res.StatusCode - eq 0){Write-Host「## vso [task.complete result = Succeeded;] Success」} Else {Write-Error「## vso [task.logissue type = error;] Test error」}。日誌中顯示的狀態代碼爲0,但「生成」爲「生成失敗」。你能給些建議麼? –