pipeline { agent { node { label 'docker' } } options { timeout(time: 1, unit: 'HOURS') buildDiscarder( logRotator( numToKeepStr: '10', artifactNumToKeepStr: '3' ) ) ansiColor('xterm') } triggers { cron('@weekly') } stages { def customImage stage('Clone repository') { checkout scm } stage('Build Docker image') { customImage = docker.build("demo-infra-jenkins-agent") } stage('Test Docker image') { app.inside { sh 'mvn' } } 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") } } } }