#jenkins #jenkins-pipeline
Вопрос:
Это мой сценарий конвейера Дженкинса.
pipeline {
agent any
environment {
PATH = "/usr/local/apache-maven/apache-maven-3.8.1/bin:$PATH"
}
stages {
stage('checkout') {
steps {
sh 'git --version'
git branch: "develop", credentialsId: 'deployments-bitbucket', url: 'https://abc/service-platform.git'
}
}
stage('Build') {
steps {
sh 'pwd'
sh 'mvn clean install -DskipTests -X'
}
}
stage('Deploy') {
steps {
script {
def remote = [:]
remote.name = "sysadmin"
remote.host = "10.30.0.56"
remote.allowAnyHosts = true
withCredentials([sshUserPrivateKey(credentialsId: "10.00.0.56-ssh-key", keyFileVariable: 'sshKey', usernameVariable: 'sshUser', passphraseVariable: 'passphrase' )]) {
remote.user = sshUser
remote.identityFile = sshKey
remote.passphrase = passphrase
sshCommand remote: remote, command: 'mv /BACKEND/MainService/MainService-1.0-SNAPSHOT.jar /BACKEND/MainService/MainService-1.0-SNAPSHOT.jar_old', failOnError: 'false'
sshCommand remote: remote, command: "kill $(ps aux | grep 'MainService-1.0-SNAPSHOT.jar' | grep -v grep | awk '{print $2}')", failOnError: 'false'
sshPut remote: remote, from: 'MainService/target/MainService-1.0-SNAPSHOT.jar', into: '/BACKEND/MainService/'
sshCommand remote: remote, command: "cd /BACKEND/MainService/; ./deploy.sh"
sshCommand remote: remote, command: 'jps'
}
}
}
}
}
}
Когда я запускаю этот скрипт, он застревает на sshCommand remote: remote, command: "cd /BACKEND/MainService/; ./deploy.sh"
этом шаге и непрерывно печатает журналы. Как отключить печать журнала и перейти к следующему шагу.
Это мое deploy.sh Сценарий
#!/bin/sh
set x
nohup java -jar MainService-1.0-SNAPSHOT.jar amp;