From 6c30c8406774e1811df913f21e8cb2dd22b120ba Mon Sep 17 00:00:00 2001 From: "l.gabrysiak" Date: Wed, 21 Aug 2024 16:11:58 +0200 Subject: [PATCH] jenkins init --- Jenkinsfile | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..9e5daf1 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,43 @@ +pipeline { + agent any + + environment { + DOCKER_IMAGE = 'docker.cloud.pokash.pl/szkolenia.riskoff.pl' + DOCKER_REGISTRY = 'docker.cloud.pokash.pl' + GIT_REPO = 'https://repo.pokash.pl/POKASH.PL/SzkoleniaRiskoff.git' + REGISTRY_CREDENTIALS_ID = '2753fc17-5ad1-4c78-b86a-a3e54c543adc' // ID poświadczeń do lokalnego rejestru + } + + stages { + stage('Checkout') { + steps { + git url: "${GIT_REPO}", branch: 'main' + } + } + + stage('Build Docker Image') { + steps { + script { + docker.build("${DOCKER_IMAGE}:latest") + } + } + } + + stage('Push Docker Image') { + steps { + script { + // Logowanie do lokalnego rejestru + docker.withRegistry("http://${DOCKER_REGISTRY}", "${REGISTRY_CREDENTIALS_ID}") { + docker.image("${DOCKER_IMAGE}:latest").push('latest') + } + } + } + } + } + + post { + always { + cleanWs() // Czyści workspace po zakończeniu builda + } + } +}