woodburn/Jenkinsfile

29 lines
955 B
Plaintext
Raw Normal View History

2023-07-13 17:19:45 +10:00
pipeline {
agent any
stages {
2023-07-13 18:08:03 +10:00
stage('Test Files') {
2023-07-13 17:19:45 +10:00
steps {
2023-07-13 18:08:03 +10:00
// Search for occurrences of "<filename>.html"
script {
def fileExists = false
// Find files with "<filename>.html" occurrences
def affectedFiles = sh returnStdout: true, script: 'grep -rl ".html" ./*.html'
// Trim
affectedFiles = affectedFiles.trim()
// If affectedFiles is not empty, set fileExists to true
if (affectedFiles) {
fileExists = true
}
// Fail the build and display the affected files
if (fileExists) {
error("Error: Found occurrences of 'filename.html' in the following files:\n${affectedFiles}")
}
}
2023-07-13 17:19:45 +10:00
}
}
}
}