75 lines
2.2 KiB
Groovy
75 lines
2.2 KiB
Groovy
// Pipeline de construction des images Docker des services Zéphir
|
|
def call() {
|
|
pipeline {
|
|
|
|
agent {
|
|
label 'common'
|
|
}
|
|
|
|
parameters {
|
|
string(
|
|
name: 'url',
|
|
description: 'URL d\'entrée pour l\'audit'
|
|
)
|
|
}
|
|
|
|
stages {
|
|
|
|
stage("Check parameters") {
|
|
steps {
|
|
script {
|
|
if (!params.url?.trim()) {
|
|
error("L'URL du paquet n'est pas définie !")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
stage("Test URL") {
|
|
steps {
|
|
script {
|
|
def w3afImage = buildDockerImage()
|
|
def dockerArgs = """
|
|
"""
|
|
w3afImage.inside(dockerArgs) {
|
|
sh './w3af_console '
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
post {
|
|
failure {
|
|
wrap([$class: 'BuildUser']) {
|
|
rocketSend (
|
|
avatar: 'https://jenkins.cadol.es/static/b5f67753/images/headshot.png',
|
|
message: """
|
|
Le test de sécurité pour `${params.url}` a échoué:
|
|
|
|
[Voir le job](${env.RUN_DISPLAY_URL})
|
|
|
|
@${env.BUILD_USER_ID ? env.BUILD_USER_ID : 'here'}
|
|
""".stripIndent(),
|
|
rawMessage: true
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
def buildDockerImage() {
|
|
dir ('.w3af') {
|
|
def dockerfile = libraryResource 'com/cadoles/w3af/Dockerfile'
|
|
writeFile file:'Dockerfile', text:dockerfile
|
|
|
|
def audit = libraryResource 'com/cadoles/w3af/audit.w3af'
|
|
writeFile file:'audit.w3af', text:audit
|
|
|
|
def safeJobName = URLDecoder.decode(env.JOB_NAME).toLowerCase().replace('/', '-').replace(' ', '-')
|
|
def imageTag = "${safeJobName}-${env.BUILD_ID}"
|
|
return docker.build("w3af:${imageTag}", ".")
|
|
}
|
|
} |