Jenkinsfile 667 Bytes
Newer Older
João Lino's avatar
João Lino committed
1 2
node {
    label 'docker'
João Lino's avatar
João Lino committed
3
    def customImage
João Lino's avatar
João Lino committed
4 5
    stage('Clone repository') {
        checkout scm
6
    }
João Lino's avatar
João Lino committed
7 8
    stage('Build Docker image') {
        customImage = docker.build("demo-infra-jenkins-agent")
9
    }
João Lino's avatar
João Lino committed
10 11 12
    stage('Test Docker image') {
        app.inside {
            sh 'mvn'
13
        }
João Lino's avatar
João Lino committed
14 15 16 17 18 19 20 21
    }
    stage('Push image') {
        /* push image with two tags:
         *  - the incremental build number from Jenkins;
         *  - the 'latest' tag. */
        docker.withRegistry('https://www.joaolino.com/nexus/repository/docker-public/', 'nexus-admin') {
            customImage.push("${env.BUILD_NUMBER}")
            customImage.push("latest")
22 23 24
        }
    }
}