pipeline {
    agent  any
    parameters{
     string(
         defaultValue: 'piotrwrzodak',
         description: 'Kaggle username',
         name: 'KAGGLE_USERNAME',
         trim: false
     )
     password(
         defaultValue: '',
         description: 'Kaggle token taken from kaggle.json file, as described in https://github.com/Kaggle/kaggle-api#api-credentials',
         name: 'KAGGLE_KEY'
     )
     string(
         defaultValue: '100',
         description: 'CUTOFF',
         name: 'CUTOFF',
         trim: false
     )
    }
    stages {
        stage('checkout: Check out from version control') {
            steps {
                checkout scm
            }
        }
        stage('Build') {
            steps {
                withEnv(["KAGGLE_USERNAME=${params.KAGGLE_USERNAME}", "KAGGLE_KEY=${params.KAGGLE_KEY}" ]) {
                   sh 'kaggle datasets download -d thedevastator/airbnb-prices-in-european-cities'
                   sh 'unzip airbnb-prices-in-european-cities.zip -d data'
                }
            }
        }
        stage('Docker') {
            agent {
                dockerfile {
                   filename 'Dockerfile'
                   dir      'ium_z444510'
                   reuseNode true
                }
            }
            steps {
                archiveArtifacts artifacts: 'barcelona_weekends.train.csv, barcelona_weekends.dev.csv, barcelona_weekends.test.csv', fingerprint: true
            }
        }
   }
}