/ Jenkinsfile
Jenkinsfile
1 pipeline { 2 agent { 3 docker { 4 label 'linuxcontainer' 5 image 'harbor.status.im/infra/ci-build-containers:linux-base-1.0.0' 6 args '--volume=/var/run/docker.sock:/var/run/docker.sock ' + 7 '--user jenkins' 8 } 9 } 10 11 options { 12 disableRestartFromStage() 13 disableConcurrentBuilds() 14 /* manage how many builds we keep */ 15 buildDiscarder(logRotator( 16 numToKeepStr: '20', 17 daysToKeepStr: '30', 18 )) 19 } 20 21 parameters { 22 string( 23 name: 'DOCKER_CRED', 24 description: 'Name of Docker Registry credential.', 25 defaultValue: params.DOCKER_CRED ?: 'harbor-status-im-robot', 26 ) 27 string( 28 name: 'DOCKER_REGISTRY_URL', 29 description: 'URL of the Docker Registry', 30 defaultValue: params.DOCKER_REGISTRY_URL ?: 'https://harbor.status.im' 31 ) 32 } 33 stages { 34 stage('Bulding docker images') { 35 steps { script { 36 def directories= findFiles().findAll { item -> item.directory && item.name != '.git' } 37 for (directory in directories) { 38 stage("Building ${directory}"){ 39 script { 40 def metadataVal = readYaml file : "./${directory}/metadata.yaml" 41 image_tag = metadataVal['data']['dockerImageTag'] 42 image_name = metadataVal['data']['dockerRepository'] 43 echo "Building ${directory} - image name : ${image_name}:${image_tag}" 44 } 45 script { 46 image = docker.build( 47 "${image_name}:${image_tag}", 48 "./${directory}" 49 ) 50 } 51 script { 52 withDockerRegistry([ 53 credentialsId: params.DOCKER_CRED, url: params.DOCKER_REGISTRY_URL 54 ]) { 55 image.push() 56 } 57 } 58 } 59 } 60 } } 61 } 62 } 63 post { 64 always { cleanWs()} 65 } 66 }