2012-09-20 4 views
6

W jaki sposób mogę przekonać TeamCity do wysyłania wiadomości w dzienniku budowy za pomocą Powershell?Uzyskiwanie TeamCity w celu rozpoznawania komunikatów Powershell

Używam TeamCity 7.1.

Oto moja PowerShell Budowa krok: enter image description here

Skrypt jest:

write-host "##teamcity[message 'Getting production info']" 

if ($LASTEXITCODE -ne 0) { 
    write-host "##teamcity[message 'Production Remote Not Found: Creating Remote']" 

    write-host "##teamcity[message 'Pushing to Remote']" 
    #git push production 

} else { 
    write-host "##teamcity[message 'write-output: Production Remote Found: Pushing to Remote']" 
    #git push production 
} 

I jedyną rzeczą, jaką otrzymuję w dzienniku budowy jest:

[17:02:58]Skip checking for changes - changes are already collected 
[17:02:59]Publishing internal artifacts (1s) 
[17:03:00][Publishing internal artifacts] Sending build.start.properties.gz file 
[17:02:59]Clearing temporary directory: C:\BuildAgent2\temp\buildTmp 
[17:02:59]Checkout directory: C:\BuildAgent2\work\7669b6a04f96908d 
[17:02:59]Updating sources: agent side checkout 
[17:02:59][Updating sources] VCS Root: Portal Master 
[17:02:59][VCS Root: Portal Master] revision: c5c6a9a0d491ee2c64ce98e48b0d67c422237698 
[17:02:59][VCS Root: Portal Master] Resetting Portal Master in C:\BuildAgent2\work\7669b6a04f96908d to revision c5c6a9a0d491ee2c64ce98e48b0d67c422237698 
[17:02:59]Starting: C:\Windows\sysnative\cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -File C:\BuildAgent2\temp\buildTmp\powershell1349912883332714566.ps1 
[17:02:59]in directory: C:\BuildAgent2\work\7669b6a04f96908d 
[17:03:00] 
[17:03:00] 
[17:03:00] 
[17:03:00]Process exited with code 0 
[17:03:00]Publishing internal artifacts 
[17:03:00][Publishing internal artifacts] Sending build.finish.properties.gz file 
[17:03:00]Build finished 

Odpowiedz

14

Jak opisano w documentation Wiadomość serwisowa "wiadomość" może mieć wiele argumentów, więc musisz podać przynajmniej argument "tekst": "##teamcity[message text='Getting production info']"

Twój skrypt będzie

write-host "##teamcity[message text='Getting production info']" 

if ($LASTEXITCODE -ne 0) { 
    write-host "##teamcity[message text='Production Remote Not Found: Creating Remote']" 

    write-host "##teamcity[message text='Pushing to Remote']" 
    #git push production 

} else { 
    write-host "##teamcity[message text='write-output: Production Remote Found: Pushing to Remote']" 
    #git push production 
} 
+1

+1 @JoeYoung Właśnie ugryziona z tego jednak, zgodnie z [DOCS] (http://confluence.jetbrains.com/display/TCD8/Build + Skrypt + interakcja + z + TeamCity # BuildScriptInteractionwithTeamCity-ServiceMessages) nie powinieneś jawnie definiować atrybutu "text"; jest to traktowane jako * wiadomość o pojedynczym atrybucie * i powinno działać. Jednak tak się nie dzieje i użycie 'text' działa. – James