jenkinsci / publish-over-ssh-plugin

https://plugins.jenkins.io/publish-over-ssh/
115 stars 150 forks source link

[JENKINS-33455] Option to disable echo of executed commands #143

Open jira-importer opened 8 years ago

jira-importer commented 8 years ago

Please add an option to disable echo of the command being executed (echo to log).

Most of the time the commands only make the log less clear to read and harder to inspect.

Current workaround is to put commands in a script and just execute the script. This however is not a viable workaround in all cases.


Originally reported by nux, imported from: Option to disable echo of executed commands
  • status: Reopened
  • priority: Minor
  • resolution: Unresolved
  • imported: 2022/01/10
jira-importer commented 8 years ago

nux:

BTW for standard "Execute shell" step there is a better workaround - you can simply add `set +x` command to disable echo. However this doesn't work for the SSH plugin.

jira-importer commented 7 years ago

rachel:

I got it with:

#!/bin/bash +x
jira-importer commented 6 years ago

slide_o_mix:

It looks like there is already a workaround for this, I would recommend using that workaround.

jira-importer commented 5 years ago

davidducker:

I agree this makes logs so much harder to read with no added value.
Unless I'm mistaken you would have to set +x for every single shell, some of my scripts have 100's. This is not an adequate workaround.

jira-importer commented 5 years ago

nux:

Rachel M. are you sure you are using SSH plugin? That is are you using "Send files or execute commands over SSH"? I tried your workaround and it doesn't work for SSH step. It only works for "Execute shell" step which is not what the task is about.

jira-importer commented 5 years ago

rachel:

Hi Maciej Jaros, which Operating System is Jenkins running on?

jira-importer commented 5 years ago

rachel:

Sorry Maciej Jaros, which Operating System are you sending the commands to?

jira-importer commented 5 years ago

nux:

I'm using Debian 9, but I used much older linux before and it also didn't work...

On which system and/or plugin version does it suppose to work?

jira-importer commented 5 years ago

rachel:

I was wondering if /bin/bash made sense on the machine you are sending the commands.

It was a long time ago, but I remember that I finally managed not to need to disable echo of executed commands, when removing all the sensitive data in the commands.

I've seen you reported this issue because of a log less clear to read and harder to inspect. In that case, please, check that /bin/bash makes sense on the machine you are sending the commands.

I think that only:

set +x

works on the machine where Jenkins is running (Execute shell step), because the use of Unix Shell is implicit. When sending commands (Publish over SSH step), I had to make explicit the use of Unix Shell.

In other words:

#!/bin/bash +x

is the same as:

#!/bin/bash

set +x

I hope this information is useful for you in order to find out the solution. Otherwise, so sorry if my comment/workaround made this issue to be resolved. Just Reopen Issue in order to get a solution for you.

jira-importer commented 5 years ago

nux:

Problem is that Jenkins displays the information. Not really echo from console.

Actual workaround is not to use Publish over SSH step and use ssh command... But then you have to mess with MoTD and some tty warnings.
https://serverfault.com/questions/36421/stop-ssh-login-from-printing-motd-from-the-client/764403#764403

That also kind of defeats the purpose of setting up ssh connections in Jenkins. So would be better to simply fix SSH in Jenkins.

jira-importer commented 5 years ago

slide_o_mix:

To be clear, do you just not want the commands echo'd, or the full stdout/stderr from the execution of the commands?

jira-importer commented 5 years ago

nux:

I don't want the commands from Publish over SSH step to be shown in Jenkins job log.

Commands which should not be shown because they can contain passwords or because they are simply long and confusing.

jira-importer commented 5 years ago

slide_o_mix:

What I decided to do was wrap the command output in a check for verbose output. I am not sure this is the best way to go, so I am soliciting feedback.

https://github.com/jenkinsci/publish-over-ssh-plugin/commit/6df164a8aa191650497c4416d2364c72682e364d