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