I tried Jenkins build multiple times, Build was successfull but when I try to submit it is showing an error “Validation file is not found in App server”.
I checked /var/www/html and found index.html file inside the folder on App server 1. Not sure what exactly I have to do to complete this task.
This is the pipeline script I used. Can you provide any suggestions for a simple script and also a way to resolve this issue.
There are several issues with your script:
- First, the agent is running as user sarah, and ‘/var/www/html’ belongs to that user, so you should not be changing that.
- The script is more complex than it needs to be. I used this, which worked:
pipeline {
agent { label 'stapp01' }
parameters {
string(name: 'BRANCH', defaultValue: 'master', description: 'Branch to deploy')
}
stages {
stage('Deploy') {
steps {
sh """
cd /var/www/html
git checkout ${params.BRANCH}
git pull origin ${params.BRANCH}
"""
}
}
}
}