pipeline {
    agent { label 'docker' }
    parameters {
        choice(
            name: 'IMAGE',
            choices: ['acme-certbot', 'acme-nginx', 'ansible', 'apidocjs', 'composer', 'mondrian', 'php', 'robo'],
            description: 'What image would you like to build?'
        )
    }
    options {
        buildDiscarder(logRotator(numToKeepStr: '10'))
    }
    stages {
        stage('Build Image') {
            steps {
                //git credentialsId: 'f1f58215-c789-44a2-9b72-50e4425cb061', url: 'ssh://git@git.xai-corp.net:10022/xai-corp.net/provisioning.git'
                checkout scm
                sh 'ls'

                withDockerRegistry(credentialsId: 'b11d7f1a-81ac-4daf-8842-56afc0d2370e', url: 'http://dkregistry.xai-corp.net:5000') {

                    dir("dockerfiles/tasks/$params.IMAGE") {
                        ansiColor('xterm') {
                            sh 'chmod +x build.sh && ls -l'

                            sh './build.sh'
                        }
                    }

                }

            }
        }
    }
}
