2020-08-10 15:15:32 +02:00
|
|
|
def audit(String url, Map params = [:]) {
|
|
|
|
def reporter = params.reporter ? params.reporter : 'html'
|
2020-08-10 16:48:05 +02:00
|
|
|
def username = params.username ? params.username : '';
|
|
|
|
def password = params.password ? params.password : '';
|
2020-08-11 10:22:57 +02:00
|
|
|
def standard = params.standard ? params.standard : 'WCAG2AA';
|
2020-08-11 10:53:49 +02:00
|
|
|
def includeWarnings = params.includeWarnings ? params.includeWarnings : false;
|
|
|
|
def includeNotices = params.includeNotices ? params.includeNotices : false;
|
2020-08-10 16:48:05 +02:00
|
|
|
|
2020-08-10 15:15:32 +02:00
|
|
|
def pa11yImage = buildDockerImage()
|
|
|
|
|
|
|
|
def dockerArgs = """
|
|
|
|
-e PA11Y_REPORTER='${reporter}'
|
|
|
|
-e PA11Y_URL='${url}'
|
2020-08-10 16:48:05 +02:00
|
|
|
-e PA11Y_USERNAME='${username}'
|
|
|
|
-e PA11Y_PASSWORD='${password}'
|
2020-08-11 10:22:57 +02:00
|
|
|
-e PA11Y_STANDARD='${standard}'
|
2020-08-11 10:53:49 +02:00
|
|
|
-e PA11Y_INCLUDE_WARNINGS='${includeWarnings}'
|
|
|
|
-e PA11Y_INCLUDE_NOTICES='${includeNotices}'
|
2020-08-10 15:15:32 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
pa11yImage.inside(dockerArgs) {
|
|
|
|
sh 'chown -R pa11y: ./'
|
|
|
|
def report = sh(
|
|
|
|
script: 'su pa11y - /usr/local/bin/run-audit',
|
|
|
|
returnStdout: true
|
|
|
|
)
|
|
|
|
|
|
|
|
return report
|
|
|
|
}
|
2020-08-10 15:03:40 +02:00
|
|
|
}
|
|
|
|
|
2020-08-10 15:15:32 +02:00
|
|
|
|
|
|
|
|
2020-08-10 15:03:40 +02:00
|
|
|
def buildDockerImage() {
|
|
|
|
dir ('.pa11y') {
|
|
|
|
def resourceFiles = [
|
|
|
|
'com/cadoles/pa11y/Dockerfile',
|
|
|
|
'com/cadoles/pa11y/patty.json.tmpl',
|
|
|
|
'com/cadoles/pa11y/run-audit.sh'
|
|
|
|
];
|
|
|
|
|
|
|
|
for (res in resourceFiles) {
|
|
|
|
def fileContent = libraryResource res
|
|
|
|
def fileName = res.substring(res.lastIndexOf("/")+1)
|
|
|
|
writeFile file:fileName, text:fileContent
|
|
|
|
}
|
|
|
|
|
|
|
|
def safeJobName = URLDecoder.decode(env.JOB_NAME).toLowerCase().replace('/', '-').replace(' ', '-')
|
|
|
|
def imageTag = "${safeJobName}-${env.BUILD_ID}"
|
|
|
|
return docker.build("pa11y:${imageTag}", ".")
|
|
|
|
}
|
|
|
|
}
|