From 941f1161c9187b2ee4d851a10337ecedf8255046 Mon Sep 17 00:00:00 2001 From: s464953 Date: Sat, 30 Mar 2024 13:59:36 +0100 Subject: [PATCH] zad4 jenkins docker image pull --- Jenkinsfile-docker-image-pull | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Jenkinsfile-docker-image-pull diff --git a/Jenkinsfile-docker-image-pull b/Jenkinsfile-docker-image-pull new file mode 100644 index 0000000..6f3cc03 --- /dev/null +++ b/Jenkinsfile-docker-image-pull @@ -0,0 +1,44 @@ +pipeline { + agent any + + parameters { + string(name: 'KAGGLE_USERNAME', defaultValue: 'gulczas', description: 'Kaggle username') + password(name: 'KAGGLE_KEY', defaultValue: '', description: 'Kaggle API key') + } + + stages { + stage('Clone Repository') { + steps { + git 'https://git.wmi.amu.edu.pl/s464953/ium_464953.git' + } + } + + stage('Stop and remove existing container') { + steps { + script { + sh "docker stop s464953 || true" + sh "docker rm s464953 || true" + } + } + } + + stage('Run Docker container') { + steps { + script { + withEnv([ + "KAGGLE_USERNAME=${env.KAGGLE_USERNAME}", + "KAGGLE_KEY=${env.KAGGLE_KEY}" + ]) { + sh "docker run --name s464953 -e KAGGLE_USERNAME=$KAGGLE_USERNAME -e KAGGLE_KEY=$KAGGLE_KEY -v ${WORKSPACE}:/app michalgulczynski/ium_s464953:1.0" + } + } + } + } + + stage('Archive stats.txt artifact') { + steps { + archiveArtifacts artifacts: 'stats.txt', allowEmptyArchive: true + } + } + } +}