#!/usr/bin/env groovy library 'status-jenkins-lib@v1.9.41' pipeline { agent { docker { label 'linuxcontainer' image 'harbor.status.im/infra/ci-build-containers:linux-base-1.0.0' args '--volume=/var/run/docker.sock:/var/run/docker.sock ' + '--user jenkins' } } options { timestamps() ansiColor('xterm') disableRestartFromStage() timeout(time: 30, unit: 'MINUTES') buildDiscarder(logRotator( numToKeepStr: '10', daysToKeepStr: '30', )) } parameters { string( name: 'IMAGE_TAG', description: 'Name of Docker tag to push.', defaultValue: env.JOB_BASE_NAME ) string( name: 'IMAGE_NAME', description: 'Name of Docker image to push.', defaultValue: params.IMAGE_NAME ?: 'harbor.status.im/logos-messaging/chat-store', ) string( name: 'DOCKER_CRED', description: 'Name of Docker Registry credential.', defaultValue: params.DOCKER_CRED ?: 'harbor-logos-core-private-robot', ) string( name: 'DOCKER_REGISTRY_URL', description: 'URL of the Docker Registry', defaultValue: params.DOCKER_REGISTRY_URL ?: 'https://harbor.status.im' ) } stages { stage('Build') { steps { script { image = docker.build( "${params.IMAGE_NAME}:${params.IMAGE_TAG}", "--label=build='${env.BUILD_URL}' " + "--label=commit='${git.commit()}' " + "." ) } } } stage('Push') { steps { script { withDockerRegistry([ credentialsId: params.DOCKER_CRED, url: params.DOCKER_REGISTRY_URL ]) { image.push() } } } } } post { always { sh 'docker image prune -f' } } }