node {
    def app
    def ecrPath = "792242783987.dkr.ecr.eu-west-1.amazonaws.com/prod"

    stage('Clone repository') {
        /* Let's make sure we have the repository cloned to our workspace */
        checkout scm
    }

    stage('Environment') {
        echo "Running ${env.BUILD_ID} on ${env.JENKINS_URL} for ${env.RELEASE_BRANCH}"
    }

    stage('Build and push image') {  
        env.RELEASE_NO = env.RELEASE_BRANCH.tokenize('/').reverse()[0]
        imageTag = "${ecrPath}:pdf_server_${env.RELEASE_NO}"
        app = sh "docker build -t ${imageTag} ."
        sh "docker push ${imageTag}"
    }
}