woodburn/Jenkinsfile
Nathan Woodburn 8331ede34c
Some checks failed
Woodburn Main/woodburn/pipeline/head There was a failure building this commit
cd: Error if html in file
2023-07-13 18:08:03 +10:00

29 lines
955 B
Groovy

pipeline {
agent any
stages {
stage('Test Files') {
steps {
// 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}")
}
}
}
}
}
}