Commit 94faab0b authored by lavado's avatar lavado
Browse files

Merge branch 'jenkinsfile-structure' into 'master'

Improvements to Jenkinsfile structure to publish image

See merge request !3
parents 422e0d8a a4f64f4e
Loading
Loading
Loading
Loading
+33 −15
Original line number Diff line number Diff line
def dockerImage

pipeline {
    agent none
  environment {
    imagename = "opensourcemano/api-fe"
    registryCredential = '<credentials>'  // To be updated with actual ID in the future
  }
  agent any
  stages {
/*      stage('Test') {
          agent { dockerfile true }
    stage('Build API-FE image') {
      steps{
                sh 'echo HOLA'
        sh "echo Building API-FE image"
        script {
          dockerImage = docker.build "${env.imagename}:${env.BUILD_NUMBER}"
        }
      }
*/
        stage('Build') {
            agent any
    }
    stage('Upload to Docker registry') {
      steps{
        sh "echo Here it would upload the image with appropriate tags: build number, latest"
        /*script {
          docker.withRegistry( '', registryCredential ) {
            dockerImage.push("${env.BUILD_NUMBER}")
            dockerImage.push('latest')
          }
        }*/
      }
    }
    stage('Remove unused Docker image') {
      steps{
                sh 'docker build .'
                sh 'echo PUBLISH'
        sh "docker rmi ${imagename}:${BUILD_NUMBER}"
        // Commented until "upload" stage can be uncommented as well
        //sh "docker rmi ${imagename}:latest"
      }
    }
  }