I’ve a jenkins pipeline stage like below
<code>stage("Export schema") {
println("====== Export Schema Stage Starting==========")
remote.name = OriginOnPremSolrNode
remote.host = OriginOnPremSolrNode
remote.user = common_username
remote.password = main_password
remote.allowAnyHosts = true
sshPut remote: remote, from: 'scripts/OnPrem_Azure_Solr_Migration/migration_export.sh', into: '.'
sshCommand remote: remote, command: "chmod 755 migration_export.sh"
sshCommand remote: remote, command: "set +x;./migration_export.sh ${OriginOnPremSolrNode} ${param1} '${param2}';set -x"
sshRemove remote: remote, path: 'migration_export.sh'
println("Error executing migration_export.sh script. We either failed to ssh into ${OriginOnPremSolrNode} or we failed for other reasons")
println("Completed the stage of collecting the schema")
<code>stage("Export schema") {
println("====== Export Schema Stage Starting==========")
try {
remote.name = OriginOnPremSolrNode
remote.host = OriginOnPremSolrNode
remote.user = common_username
remote.password = main_password
remote.allowAnyHosts = true
sshPut remote: remote, from: 'scripts/OnPrem_Azure_Solr_Migration/migration_export.sh', into: '.'
sshCommand remote: remote, command: "chmod 755 migration_export.sh"
sshCommand remote: remote, command: "set +x;./migration_export.sh ${OriginOnPremSolrNode} ${param1} '${param2}';set -x"
sshRemove remote: remote, path: 'migration_export.sh'
} catch (Exception ex) {
println("Error executing migration_export.sh script. We either failed to ssh into ${OriginOnPremSolrNode} or we failed for other reasons")
throw ex
}
println("Completed the stage of collecting the schema")
}
</code>
stage("Export schema") {
println("====== Export Schema Stage Starting==========")
try {
remote.name = OriginOnPremSolrNode
remote.host = OriginOnPremSolrNode
remote.user = common_username
remote.password = main_password
remote.allowAnyHosts = true
sshPut remote: remote, from: 'scripts/OnPrem_Azure_Solr_Migration/migration_export.sh', into: '.'
sshCommand remote: remote, command: "chmod 755 migration_export.sh"
sshCommand remote: remote, command: "set +x;./migration_export.sh ${OriginOnPremSolrNode} ${param1} '${param2}';set -x"
sshRemove remote: remote, path: 'migration_export.sh'
} catch (Exception ex) {
println("Error executing migration_export.sh script. We either failed to ssh into ${OriginOnPremSolrNode} or we failed for other reasons")
throw ex
}
println("Completed the stage of collecting the schema")
}
The command executes in the remote server fine however when I check the console log, I see the command is displayed with all the params values exposed.
<code> Executing command on server1[server1]: chmod 755 migration_export.sh sudo: false
Executing command on server1[server1]: set +x;./migration_export.sh server1 myparamvalue1 'myparamvalue2';set -x sudo: false
<code> Executing command on server1[server1]: chmod 755 migration_export.sh sudo: false
[Pipeline] sshCommand
Executing command on server1[server1]: set +x;./migration_export.sh server1 myparamvalue1 'myparamvalue2';set -x sudo: false
</code>
Executing command on server1[server1]: chmod 755 migration_export.sh sudo: false
[Pipeline] sshCommand
Executing command on server1[server1]: set +x;./migration_export.sh server1 myparamvalue1 'myparamvalue2';set -x sudo: false
How can I hide above getting logged into jenkins console log? No matter what I do, whatever command I execute via sshCommand, the command in entirety is exposed in the console log. What if I don’t want to expose what command I’m executing in the remote server or the parameter values I’m using, for security reasons?
Looked at
How can I stop displaying the SSH exec command in the output console in Jenkins?
Hide command executed, only show output
Hide output of ssh command
But either they didn’t apply or didn’t work. For e.g the set +x hack also didn’t work