2020-08-11 14:32:06 +02:00
import hudson.tasks.test.AbstractTestResultAction
2022-09-14 09:14:34 +02:00
@Library('cadoles') _
2020-08-11 14:32:06 +02:00
pipeline {
2022-09-14 09:14:34 +02:00
parameters {
2020-08-11 14:32:06 +02:00
text(name: 'URLS', defaultValue: 'https://msedev.crous-toulouse.fr\nhttps://msedev.crous-toulouse.fr/envole/enregistrement\nhttps://msedev.crous-toulouse.fr/envole/page/faq\nhttps://msedev.crous-toulouse.fr/envole/page/?t=liens_utiles\nhttps://msedev.crous-toulouse.fr/envole/page/?t=mentions_legales\nhttps://msedev.crous-toulouse.fr/envole/message/new\nhttps://msedev.crous-toulouse.fr/envole/recuperation/email\nhttps://msedev.crous-toulouse.fr/envole/courriel/raz', description: 'Liste des URLs à tester, une par ligne')
booleanParam(name: 'INCLUDE_WARNINGS', defaultValue: false, description: 'Inclure les avertissements')
booleanParam(name: 'INCLUDE_NOTICES', defaultValue: false, description: 'Inclure les notifications')
2022-11-18 16:17:22 +01:00
text(name: 'COOKIE_VALUE', defaultValue: 'mselang=fr_FR')
2020-08-11 14:32:06 +02:00
}
options {
disableConcurrentBuilds()
}
agent {
node {
2022-09-14 09:14:34 +02:00
label 'docker'
2020-08-11 14:32:06 +02:00
}
}
stages {
2022-09-14 09:14:34 +02:00
stage('Run RGAA audit') {
2020-08-11 14:32:06 +02:00
steps {
script {
2022-09-14 09:14:34 +02:00
def urls = params.URLS.split('\n')
def count = 0
urls.each { u ->
stage("Audit page '${u}'") {
withCredentials([
usernamePassword(
credentialsId: 'msedev-basic-auth',
usernameVariable: 'MSEDEV_USERNAME',
passwordVariable: 'MSEDEV_PASSWORD'
)
]) {
def report = pa11y.audit(u.trim(), [
2022-11-17 10:54:17 +01:00
reporter: 'junit',
2022-09-14 09:14:34 +02:00
username: env.MSEDEV_USERNAME,
password: env.MSEDEV_PASSWORD,
standard: 'WCAG2AA',
includeNotices: params.INCLUDE_NOTICES,
includeWarnings: params.INCLUDE_WARNINGS,
2022-11-18 16:17:22 +01:00
cookie_value: params.COOKIE_VALUE
2022-09-14 09:14:34 +02:00
])
2022-11-16 13:31:05 +01:00
writeFile file:"./report_${count}.xml", text:report
2022-09-14 09:14:34 +02:00
count++
}
}
}
2022-11-16 13:31:05 +01:00
junit testResults: '*.xml', skipPublishingChecks: true
2022-09-14 09:14:34 +02:00
rocketSend(
channel: '#cnous-mse',
2020-08-11 14:32:06 +02:00
avatar: 'https://jenkins.cadol.es/static/b5f67753/images/headshot.png',
message: """
Audit RGAA | ${testStatuses()}
2022-09-14 09:14:34 +02:00
2020-08-11 14:32:06 +02:00
- [Voir les tests](${env.RUN_DISPLAY_URL})
@here
""".stripIndent(),
rawMessage: true,
)
}
}
}
}
2022-06-16 12:21:06 +02:00
post {
always {
cleanWs()
}
}
2020-08-11 14:32:06 +02:00
}
@NonCPS
def testStatuses() {
2022-09-14 09:14:34 +02:00
def testStatus = ''
AbstractTestResultAction testResultAction = currentBuild.rawBuild.getAction(AbstractTestResultAction.class)
if (testResultAction != null) {
def total = testResultAction.totalCount
def failed = testResultAction.failCount
def skipped = testResultAction.skipCount
def passed = total - failed - skipped
testStatus = "Passant(s): ${passed}, Échoué(s): ${failed} ${testResultAction.failureDiffString}, Désactivé(s): ${skipped}"
}
return testStatus
}