pipeline {
agent any
tools {
gradle 'Gradle'
}
environment {
JASYPT_PASSWORD = credentials('jasypt-password-id')
SERVER_IP = '***.***.***.***'
DEPLOY_PATH = '/root'
JAR_FILE = 'build/libs/bobzip-0.0.1-SNAPSHOT.jar'
}
stages {
stage('Checkout') {
steps {
git url: 'https://github.com/Firedrago95/project_bobzip', branch: 'main'
}
}
stage('Prepare') {
steps {
script {
sh 'chmod +x ./gradlew'
}
}
}
stage('Build') {
steps {
script {
sh "./gradlew clean build -x test -Pjasypt.encryptor.password=${JASYPT_PASSWORD}"
}
}
}
stage('Deploy') {
steps {
script {
def runAppCommand = "java -Dspring.profiles.active=prod -Djasypt.encryptor.password=${JASYPT_PASSWORD} -jar $DEPLOY_PATH/bobzip-0.0.1-SNAPSHOT.jar"
sh "scp -o StrictHostKeyChecking=no $JAR_FILE root@$SERVER_IP:$DEPLOY_PATH/"
sshagent(['deploy_ssh_key']) {
sh """
ssh -o StrictHostKeyChecking=no root@$SERVER_IP '
$runAppCommand'
"""
}
}
}
}
}
post {
success {
echo 'Deployment was successful.'
}
failure {
echo 'Deployment failed'
}
}
The Jenkins Pipeline code is as shown above. The build succeeds, but an error occurs during runtime. The error code is as follows:
enter image description here
This is my first time using Jenkins, so I’m not sure how to resolve the issue.
New contributor
user25916347 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.