cd: html test 3
Some checks failed
nathanwoodburn/woodburn/pipeline/head There was a failure building this commit
Some checks failed
nathanwoodburn/woodburn/pipeline/head There was a failure building this commit
This commit is contained in:
parent
5875acefa2
commit
96a5de48a5
27
Jenkinsfile
vendored
27
Jenkinsfile
vendored
@ -2,31 +2,26 @@ pipeline {
|
|||||||
agent any
|
agent any
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('Test Files') {
|
stage('Check HTML Files') {
|
||||||
steps {
|
steps {
|
||||||
// Search for occurrences of "<filename>.html"
|
// Search for occurrences of "filename.html"
|
||||||
script {
|
script {
|
||||||
def fileError = false
|
def fileExists = false
|
||||||
|
|
||||||
def allFiles = sh returnStdout: true, script: 'find . -type f -name "*.html" -print0 | xargs -0 grep -l ".html"'
|
// Find files with "filename.html" occurrences
|
||||||
|
def affectedFiles = sh(
|
||||||
// For each file, check if it contains "<filename>.html"
|
script: 'find . -type f -name "*.html" -print0 | xargs -0 grep -l ".html"',
|
||||||
allFiles.eachLine { file ->
|
returnStdout: true
|
||||||
def filename = file.split("/").last()
|
).trim()
|
||||||
def filenameWithoutExtension = filename.split("\\.").first()
|
|
||||||
|
|
||||||
// If the file contains "<filename>.html", set fileError to true
|
|
||||||
if (file.contains(filenameWithoutExtension + ".html")) {
|
|
||||||
fileError = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// If affectedFiles is not empty, set fileExists to true
|
// If affectedFiles is not empty, set fileExists to true
|
||||||
if (affectedFiles) {
|
if (affectedFiles) {
|
||||||
fileExists = true
|
fileExists = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fail the build and display the affected files
|
// Fail the build and display the affected files
|
||||||
if (fileError) {
|
if (fileExists) {
|
||||||
error("Error: Found occurrences of 'filename.html' in the following files:\n${affectedFiles}")
|
error("Error: Found occurrences of '.html' in the following files:\n${affectedFiles}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user