2016-09-23 60 views
0

如何在Jenkins控制檯輸出上使用shell腳本在每行的開頭處打印Servername。我越來越servernames節點作爲參數一樣sd009.domain.com,sw009.domain.com從主動選擇參數插件如何在控制檯輸出的每行中顯示服務器名稱

實際輸出:

ssh -o stricthostkeychecking = no [email protected] 'ls -lrt' 
    ssh -o stricthostkeychecking = no [email protected] 'pwd' 
    ssh -o stricthostkeychecking = no [email protected] 'hostname' 
    PS_EXE="/cygdrive/windows/powershell.exe" 

我的預期輸出:

sd09.domain.com ssh -o stricthostkeychecking = no [email protected] 'ls -lrt' 
sd09.domain.com ssh -o stricthostkeychecking = no [email protected] 'pwd' 
sd09.domain.com ssh -o stricthostkeychecking = no [email protected] 'hostname' 
sd09.domain.com PS_EXE="/cygdrive/windows/powershell.exe" 

看到我需要顯示我所選擇的服務器名在所有的輸出行中,像上面在執行shell程序段中使用shell腳本代碼。 請儘早幫助我實現此目標。

+0

我不明白的問題,因爲你不顯示產生實際輸出的腳本。你想問如何在文件的每一行上添加一個固定的字符串? – user1934428

+0

你的意思是你想改變你的提示嗎? –

+0

我在jenkins中的執行shell程序塊中寫了這段代碼。我在運行時部署服務器,我的要求是顯示jenkins輸出控制檯中每行開始時在當前工作的servername。 –

回答

0

我想你的意思是這一點 - 如果沒有,請嘗試更好地解釋方面:

ssh someHost 'ls | sed "s/^/"$(uname -n)" /"' 

輸出

... 
vm3072.isp.com perl 
vm3072.isp.com perl5 
vm3072.isp.com php 
vm3072.isp.com public_ftp 
vm3072.isp.com public_html 
... 
+0

我也試過這個命令,但是它沒有工作,但.. –

相關問題