From 2733ccab0bfc86142bb1772ec779e7331fa619b7 Mon Sep 17 00:00:00 2001 From: Maciej Czajka Date: Fri, 25 Mar 2022 21:15:44 +0100 Subject: [PATCH] update jenkinsfile --- Jenkinsfile | 77 ++++++++++++++++++----------------------------------- 1 file changed, 26 insertions(+), 51 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 61d545a..e21187b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,31 +1,25 @@ pipeline { agent any - //Definiujemy parametry, które będzie można podać podczas wywoływania zadania - parameters { - string ( - defaultValue: 'Hello World!', - description: 'Tekst, którym chcesz przywitać świat', - name: 'INPUT_TEXT', - trim: false + + parameters { + string( + defaultValue: 'maciejczajka', + description: 'Kaggle username', + name: 'KAGGLE_USERNAME', + trim: false ) - } - stages { - stage('Hello') { - steps { - //Wypisz wartość parametru w konsoli (To nie jest polecenie bash, tylko groovy!) - echo "INPUT_TEXT: ${INPUT_TEXT}" - //Wywołaj w konsoli komendę "figlet", która generuje ASCI-art - sh "figlet \"${INPUT_TEXT}\" | tee output.txt" - } - } - stage('Goodbye!') { - steps { - echo 'Goodbye!' - //Zarchiwizuj wynik - archiveArtifacts 'output.txt' - } - } + password( + defaultValue: '', + description: 'Kaggle token taken from kaggle.json file, as described in https://github.com/Kaggle/kaggle-api#api-credentials', + name: 'KAGGLE_KEY' + ) + } + environment { + KAGGLE_USERNAME="$params.KAGGLE_USERNAME" + KAGGLE_KEY="$params.KAGGLE_KEY" + } + stages { stage('Checkout'){ steps { checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: 's444356', url: 'https://git.wmi.amu.edu.pl/s444356/ium_444356.git']]]) @@ -34,34 +28,15 @@ pipeline { stage('Script'){ steps { + script { + withEnv(["KAGGLE_USERNAME=${params.KAGGLE_USERNAME}", + "KAGGLE_KEY=${params.KAGGLE_KEY}" ]) { + sh 'echo KAGGLE_USERNAME: $KAGGLE_USERNAME' + sh 'kaggle datasets list' + } + } sh './download.sh' } } - - stage('Preparation') { - properties([ - parameters([ - string( - defaultValue: 'maciejczajka', - 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' - ) - ]) - ]) - } - stage('Build') { - // Run the maven build - withEnv(["KAGGLE_USERNAME=${params.KAGGLE_USERNAME}", - "KAGGLE_KEY=${params.KAGGLE_KEY}" ]) { - sh 'echo KAGGLE_USERNAME: $KAGGLE_USERNAME' - sh 'kaggle datasets list' - } - } - } + } } \ No newline at end of file