0

How to print the Servername in beginning of each line using shell script on Jenkins Console Output. I am getting the Servernames as parameter like sd009.domain.com, sw009.domain.com from Active Choices parameter plugin

Actual Output:

 ssh -o stricthostkeychecking = no domain@server 'ls -lrt'
    ssh -o stricthostkeychecking = no domain@server 'pwd'
    ssh -o stricthostkeychecking = no domain@server 'hostname'
    PS_EXE="/cygdrive/windows/powershell.exe"

My expected output:

sd09.domain.com ssh -o stricthostkeychecking = no domain@server 'ls -lrt'
sd09.domain.com ssh -o stricthostkeychecking = no domain@server 'pwd'
sd09.domain.com ssh -o stricthostkeychecking = no domain@server 'hostname'
sd09.domain.com PS_EXE="/cygdrive/windows/powershell.exe"

See i need to show my selected servername in all line of output like the above using shell script code in execute shell block. Please help me in achieving this at the earliest.

Inian
  • 80,270
  • 14
  • 142
  • 161
  • I don't understand the question, as you don't show the script which produces the actual output. Do you want to ask how to prepend a fixed string to each line of a file? – user1934428 Sep 23 '16 at 06:41
  • Do you mean you want to change your prompt? – Mark Setchell Sep 23 '16 at 08:23
  • I have written this code in execute shell block in jenkins. I am getting the servers at run time for deployment, my requirement is to display the servername which is worked in currently in starting of each line in jenkins output console. – Manigandan Thanigai Arasu Sep 23 '16 at 13:08

1 Answers1

0

I think you mean this - if not, please try and better explain the context:

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

Output

...
vm3072.isp.com perl
vm3072.isp.com perl5
vm3072.isp.com php
vm3072.isp.com public_ftp
vm3072.isp.com public_html
...
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432