diff --git a/Dockerfile b/Dockerfile index 371619e..cc96876 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ FROM ubuntu:latest -ENV KAGGLE_USERNAME=alicjaszulecka -ENV KAGGLE_KEY=default_key +# Dockerfile +ARG KAGGLE_USERNAME +ARG KAGGLE_KEY RUN apt update && apt install -y python3-pip RUN apt install unzip diff --git a/Jenkinsfile b/Jenkinsfile index 7d4f8e5..0938ec6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,27 +1,30 @@ pipeline { agent { - dockerfile true + dockerfile { + args '-v /var/run/docker.sock:/var/run/docker.sock' + } } parameters { - string(name: 'KAGGLE_USERNAME', defaultValue: 'alicjaszulecka', description: 'Kaggle username') - password(name: 'KAGGLE_KEY', defaultValue:'', description: 'Kaggle Key') - string(name: 'CUTOFF', defaultValue: '100', description: 'cut off number') + string(name: 'KAGGLE_USERNAME', defaultValue: 'alicjaszulecka', description: 'Kaggle username') + password(name: 'KAGGLE_KEY', defaultValue:'', description: 'Kaggle Key') + string(name: 'CUTOFF', defaultValue: '100', description: 'cut off number') } stages { stage('Git Checkout') { steps { - checkout scm + checkout scm } } - stage('Build') { - steps { - withEnv(["KAGGLE_USERNAME=${params.KAGGLE_USERNAME}", - "KAGGLE_KEY=${params.KAGGLE_KEY}" ]) { - - sh 'bash ./get_dataset.sh $CUTOFF' - archiveArtifacts artifacts: 'artifacts/*', onlyIfSuccessful: true - } - } - } - } -} \ No newline at end of file + stage('Build') { + steps { + script { + def customImage = docker.build("my-custom-image:${BUILD_NUMBER}", "--build-arg KAGGLE_USERNAME=${params.KAGGLE_USERNAME} --build-arg KAGGLE_KEY=${params.KAGGLE_KEY} .") + customImage.inside { + sh 'bash ./get_dataset.sh ${params.CUTOFF}' + } + } + archiveArtifacts artifacts: 'artifacts/*', onlyIfSuccessful: true + } + } + } +}