cd: Error if html in file
Some checks failed
Woodburn Main/woodburn/pipeline/head There was a failure building this commit

This commit is contained in:
Nathan Woodburn 2023-07-13 18:08:03 +10:00
parent bb70f69a34
commit 8331ede34c
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

22
Jenkinsfile vendored
View File

@ -2,9 +2,27 @@ pipeline {
agent any
stages {
stage('None') {
stage('Test Files') {
steps {
echo "Done"
// 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}")
}
}
}
}
}