woodburn/Jenkinsfile

30 lines
1.0 KiB
Plaintext
Raw Normal View History

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:39:45 +10:00
// Search for occurrences of the file name with the .html extension
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:39:45 +10:00
// Find files with occurrences of the file name with the .html extension
2023-07-13 18:36:36 +10:00
def affectedFiles = sh(
2023-07-13 18:39:45 +10:00
script: 'find . -type f -name "*.html" -exec grep -l "{}" "{}" \\;',
2023-07-13 18:36:36 +10:00
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) {
2023-07-13 18:39:45 +10:00
error("Error: Found occurrences of file names with the .html extension in the following files:\n${affectedFiles}")
2023-07-13 18:08:03 +10:00
}
}
2023-07-13 17:19:45 +10:00
}
}
}
}