Gist for https://youtu.be/admAfAYoVRo
pipeline {
agent any
stages {
stage('check file') {
steps {
script {
if (fileExists('file.txt')) {
echo "File file.txt found!"
}
}
}
}
}
}
pipeline {
agent any
stages {
stage('check file') {
when {
expression {
return fileExists('file.txt')
}
}
steps {
echo "File file.txt found!"
}
}
}
}
pipeline {
agent any
stages {
stage('create file') {
steps {
sh 'touch file.txt'
}
}
stage('check file') {
when {
expression {
return fileExists('file.txt')
}
}
steps {
echo "File file.txt found!"
}
}
}
}
pipeline {
agent any
stages {
stage('check directory') {
when {
expression {
return fileExists('src/main')
}
}
steps {
echo "Directory src/main found!"
}
}
}
}
pipeline {
agent any
stages {
stage('create directory') {
steps {
sh 'mkdir -p src/main'
}
}
stage('check directory') {
when {
expression {
return fileExists('src/main')
}
}
steps {
echo "Directory src/main found!"
}
}
}
}