pipeline {
   agent  any

   //Definijuemy parametry, które będzie można podać podczas wywoływania zadania
         parameters{
             string(
                 defaultValue: 'patrykgaka',
                 description: 'Kaggle username',
                 name: 'KAGGLE_USERNAME',
                 trim: false
             )
             password(
                 defaultValue: 'd14370cec1714b0cd1ef2875038b5950',
                 description: 'Kaggle token taken from kaggle.json file, as described in https://github.com/Kaggle/kaggle-api#api-credentials',
                 name: 'KAGGLE_KEY'
             )
             string(
                 defaultValue: '500',
                 description: 'CUTOFF',
                 name: 'CUTOFF',
                 trim: false
             )
         }
    stages {
      stage('clear_all') {
         steps {
            //Wypisz wartość parametru w konsoli (To nie jest polecenie bash, tylko groovy!)
            sh 'rm -rf *'
         }
      }
      stage('checkout') {
         steps {
            //Wypisz wartość parametru w konsoli (To nie jest polecenie bash, tylko groovy!)
            sh 'git clone https://git.wmi.amu.edu.pl/s434686/ium_z434686'
         }
      }
      

      stage('Build') {
         steps {
         // Run the maven build
         withEnv(["KAGGLE_USERNAME=${params.KAGGLE_USERNAME}",
                  "KAGGLE_KEY=${params.KAGGLE_KEY}" ]) {
               sh 'kaggle datasets download -d rush4ratio/video-game-sales-with-ratings'
               sh 'unzip ./ium_z434686/video-game-sales-with-ratings.zip'
               sh 'rm video-game-sales-with-ratings.zip'
         }
         }
      }
      stage('Docker') {
         agent { 
            dockerfile {
               filename 'create.dockerfile'
               }
         }
      steps {
               sh 'ls -a'
               sh 'python create-dataset.py'
               archiveArtifacts 'X_train.csv'
               archiveArtifacts 'X_dev.csv'
               archiveArtifacts 'X_tes.csv'
         }
      }
   }
}