pipeline {
    agent {
        dockerfile {
			 additionalBuildArgs "--build-arg KAGGLE_USERNAME=${params.KAGGLE_USERNAME} --build-arg KAGGLE_KEY=${params.KAGGLE_KEY} --build-arg CUTOFF=${params.CUTOFF} -t sebastianwalesa"
        }
    }
    parameters {
        string (
            defaultValue: 'sebastianwalesa',
            description: 'Kaggle username',
            name: 'KAGGLE_USERNAME',
            trim: false
        )
        password (
            defaultValue: 'c879e3806be4cd6ade7aa10ea81d4cfe',
            description: 'Kaggle token taken from kaggle.json file, as described in https://github.com/Kaggle/              kaggle-api#api-credentials',
            name: 'KAGGLE_KEY'
        )
    }
    stages {
        stage('First step') {
            steps {
                echo 'Hello world!'
                }
        }
        stage('Checkout') {
            steps {
                checkout([$class: 'GitSCM', branches: [[name: '*/feature']], extensions: [], userRemoteConfigs: [
                    [url: 'https://git.wmi.amu.edu.pl/s478839/ium_478839.git']]])
            }
        }
        stage('Shell Script') {
            steps {
                withEnv(["KAGGLE_USERNAME=${params.KAGGLE_USERNAME}",
                "KAGGLE_KEY=${params.KAGGLE_KEY}"]) {
                sh "chmod +x -R ${env.WORKSPACE}"
                sh './skrypt.sh'
                }
            }
        }
        stage('Arichve') {
            steps{
                archiveArtifacts artifacts: 'understat.csv', followSymlinks: false
                archiveArtifacts artifacts: 'understat_per_game.csv', followSymlinks: false
                archiveArtifacts artifacts: 'understat.csv.dev', followSymlinks: false
                archiveArtifacts artifacts: 'understat.csv.train', followSymlinks: false
                archiveArtifacts artifacts: 'understat.csv.test', followSymlinks: false
                archiveArtifacts artifacts: 'understat.csv.cutted', followSymlinks: false
            }            
        }
    }
}