Jenkinsfile 1.2 KB
Newer Older
MOREY Thibault's avatar
MOREY Thibault committed
1
2
node{
    def app
MOREY Thibault's avatar
MOREY Thibault committed
3
    def image="${registryProject}:version-${env.BUILD_ID}"
Thibault's avatar
Thibault committed
4
5
    def registryProject='http://172.20.0.2:8083/repository/RegistryDocker/'  

MOREY Thibault's avatar
MOREY Thibault committed
6
7
8
9
10

        stage('Clone') {
            checkout scm
        }

MOREY Thibault's avatar
MOREY Thibault committed
11
        stage('Scan hadolint'){
MOREY Thibault's avatar
MOREY Thibault committed
12
            sh 'docker run --rm -i hadolint/hadolint < Dockerfile > rapportHadolint || true'
MOREY Thibault's avatar
MOREY Thibault committed
13
14
        }

MOREY Thibault's avatar
MOREY Thibault committed
15
        stage('Build image') {
MOREY Thibault's avatar
MOREY Thibault committed
16
            app = docker.build ("debian:buster")
MOREY Thibault's avatar
MOREY Thibault committed
17
18
19
        }

        stage('Test image') {
MOREY Thibault's avatar
MOREY Thibault committed
20
            docker.image('debian:buster').withRun() { c -> 
MOREY Thibault's avatar
MOREY Thibault committed
21
                        
MOREY Thibault's avatar
MOREY Thibault committed
22
23
            sh 'docker ps'
        }
MOREY Thibault's avatar
MOREY Thibault committed
24
        }
MOREY Thibault's avatar
MOREY Thibault committed
25
        stage('Scan Dockle'){
MOREY Thibault's avatar
MOREY Thibault committed
26
            sh 'dockle debian:buster > rapportDockle'
MOREY Thibault's avatar
MOREY Thibault committed
27
        }
MOREY Thibault's avatar
MOREY Thibault committed
28

MOREY Thibault's avatar
MOREY Thibault committed
29
30
        stage('Scan Clair'){
            sh '''
Thibault's avatar
Thibault committed
31
               wget -qO clair-scanner https://github.com/arminc/clair-scanner/releases/download/v8/clair-scanner_linux_amd64 && chmod +x clair-scanner
Thibault's avatar
Thibault committed
32
               ./clair-scanner --report="rapportClair" --ip="172.20.0.4" --clair="http://172.20.0.6:6060" debian:buster || exit 0
Thibault's avatar
Thibault committed
33
               '''
MOREY Thibault's avatar
MOREY Thibault committed
34
        }
Thibault's avatar
Thibault committed
35
        
MOREY Thibault's avatar
MOREY Thibault committed
36
        stage('Push on repo nexus'){
Thibault's avatar
Thibault committed
37
38
            docker.withRegistry(registryProject,'Jenkins-credential'){
                app.push()
MOREY Thibault's avatar
MOREY Thibault committed
39
            } 
MOREY Thibault's avatar
MOREY Thibault committed
40
        }
MOREY Thibault's avatar
MOREY Thibault committed
41
}