Jenkins Pipeline sshPublisher: Как получить код выхода и вывод execCommand? - PullRequest
0 голосов
/ 01 марта 2019

Используя плагин sshPublisher Jenkins Pipeline ("опубликовать поверх ssh"), возможно ли получить код выхода , и вывод команды запускается с execCommand (после того, как артефакты имеютбыло перенесено через)?

Я использую плагин следующим образом:

script {
    echo "Sending artifacts to machine at " + remoteDirectory

    // Use of the ssh publisher plugin over SSH
    sshPublisher(
        failOnError: false,
        publishers: [
            sshPublisherDesc(
                configName: "my-drive",
                transfers: [
                    sshTransfer(
                        sourceFiles: mySourceFilesList,
                        remoteDirectory: remoteDirectory,
                        flatten: true,
                        execCommand: commandToExec,
                        execTimeout: 1800000
                    )
                ],
                sshRetry: [
                    retries: 0
                ]
            )
        ]
    )
    // How can I get the output of execCommand?
    // If the exit code was 1, I want to perform some special steps
    // I'd also like to include the output of the command in these steps
}

На вики-странице здесь написано (хотя это старое и с 2011 года):

STDOUT и STDERR из выполнения команды записываются в консоли Jenkins.

1 Ответ

0 голосов
/ 05 сентября 2019

Это «Нет» (не могу быть уверен, но я пробую все, что могу).
И теперь я доволен этим сценарием ssh user@nas01 su -c "/path/to/command1 arg1 arg2"

...