Answer the question
In order to leave comments, you need to log in
How to output stdout from a script in Jenkins?
I'm trying to install Jenkins on a VPS. The repository has already been cloned and launched in the docker.
I need to execute a couple of commands there just during deployment, in that directory.
pipeline {
agent any
stages {
stage('Test') {
steps {
slackSend (color: '#FFFF00', message: "TEST STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
sh 'chmod +x ./sh/*.sh'
sh 'bash ./sh/postinstall.sh'
sh 'cp .env.example .env'
sh 'rm -rf ./node_modules'
sh 'npm install --from-lock-file --force --no-save'
sh 'npm run lint'
sh 'npm run docs'
sh 'npm run test'
slackSend (color: '#00FF00', message: "TEST COMPLETED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
}
stage('Stage build') {
when {
anyOf {
branch 'dev'
}
}
steps {
slackSend (color: '#FFFF00', message: "STAGE BUILD STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
ws('/home/ubuntu/deploy/backend') {
sh(returnStdout: true, script: 'chmod +x ./sh/*.sh && bash ./sh/stage.sh')
}
slackSend (color: '#00FF00', message: "STAGE BUILD COMPLETED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
}
}
environment {
STAGE_PATH = '/home/ubuntu/deploy/backend'
}
post {
failure {
slackSend (color: '#FF0000', message: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question