diff --git a/Jenkinsfile b/Jenkinsfile index 4ccfecf..d50e4df 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,22 +1,95 @@ pipeline { - agent any + agent { + docker { + image 'docker:27-cli' + args '-v /var/run/docker.sock:/var/run/docker.sock' + } + } + + environment { + IMAGE_NAME = 'core-pim-test' + IMAGE_TAG = 'latest' + CONTAINER_NAME = "${IMAGE_NAME}-container" + + DOCKERHUB_USER = 'ramonvasquezliesa' + DOCKERHUB_REPO = "${DOCKERHUB_USER}/${IMAGE_NAME}" + DOCKERHUB_IMAGE = "${DOCKERHUB_REPO}:${IMAGE_TAG}" + + FORGEJO_URL = 'https://forgejo.test.dev.it.liesa.com.ar' + FORGEJO_OWNER = 'it.dev' + FORGEJO_REPO = 'integrations.core.pim.git' + + REQUIRE_VERSION_TAG = 'true' + REMOVE_DANGLING_IMAGES = 'true' + + PORTS = '8081:80' + ENV_FILE = '' + VOLUMES = '' + } stages { - stage('Stage Test') - { + stage('Checkout (with submodules)') { steps { - echo 'Un día me preguntaron qué es lo que quería...' - echo 'les contesté que Racing el domingo me dé una alegría...' - echo 'para poder festejar con toda la gente...' - echo 'Racing, mi buen amigo...' + checkout(scmGit( + // branches: [[name: '*/dev']], + userRemoteConfigs: [[ + url: "${FORGEJO_URL}/${FORGEJO_OWNER}/${FORGEJO_REPO}", + credentialsId: 'forgejo-token-hermes' + ]], + extensions: [ + [$class: 'SubmoduleOption', + disableSubmodules: false, + recursiveSubmodules: true, + parentCredentials: true, + trackingSubmodules: true + ] + ] + )) + } + } + + stage('Login Docker') { + steps { + sh ''' + docker --version + echo "$DOCKERHUB_TOKEN" | docker login -u "$DOCKERHUB_USER" --password-stdin + ''' + } + } + + stage('Docker Login') { + steps { + withCredentials([ + usernamePassword( + credentialsId: 'dockerhub-credentials-hermes', + usernameVariable: 'DOCKERHUB_USER', + passwordVariable: 'DOCKERHUB_PASS' + ) + ]) { + sh ''' + set -eu pipefail + echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USER" --password-stdin + ''' + } + } + } + + stage('Build Image') { + steps { + script { + docker.build("${DOCKERHUB_REPO}:${TAG}", '-f src/Service/Infrastructure/App/Dockerfile .') + } + } + } + + stage('Push Image') { + steps { + script { + docker.withRegistry('https://index.docker.io/v1/', 'dockerhub-credentials-hermes') { + docker.image("${DOCKERHUB_REPO}:${TAG}").push() + } + } } } } } -// -// -// -// -// -// -//