From bf3280423d09b409bf7134c5ddeb65996d8d743d Mon Sep 17 00:00:00 2001 From: Jan Nowak Date: Sun, 28 Mar 2021 22:00:27 +0200 Subject: [PATCH] Added sh script and done to 7-th task. --- Jenkinsfile | 43 +++++++++++++++++++++++++++++++++++++++++-- skrypt.sh | 16 ++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 skrypt.sh diff --git a/Jenkinsfile b/Jenkinsfile index ffd6cc0..15b290b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,10 +1,49 @@ pipeline { agent any stages { - stage('Stage 1') { + stage('Preparation') { + properties([ + parameters([ + string( + defaultValue: '0', + description: 'Umożliwia zdefiniowanie wielkości odcięcia zbioru danych.', + name: 'CUTOFF', + trim: false + ), + string( + defaultValue: 'rokoch', + 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('checkout') { steps { - echo 'Hello world!' + checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://git.wmi.amu.edu.pl/s426206/ium_426206.git']]]) } } + + stage('sh') { + steps { + withEnv(["KAGGLE_USERNAME=${params.KAGGLE_USERNAME}", + "KAGGLE_KEY=${params.KAGGLE_KEY}") { + sh 'echo KAGGLE_USERNAME: $KAGGLE_USERNAME' + sh 'kaggle datasets list' + sh './skrypt.sh params.CUTOFF | tee output.txt' + } + } + } + + stage('end') { + //Zarchiwizuj wynik + archiveArtifacts 'output.txt' + } } } \ No newline at end of file diff --git a/skrypt.sh b/skrypt.sh new file mode 100644 index 0000000..27314ee --- /dev/null +++ b/skrypt.sh @@ -0,0 +1,16 @@ +#!/bin/bash +kaggle datasets download -d apoorvaappz/global-super-store-dataset +unzip global-super-store-dataset.zip +cat Global_Superstore2.csv | shuf > Global_Superstore2.csv.shuf +if [ $1="0" ]; then + CUTOFF=51291 +else + CUTOFF=$1 +fi +prop1=$((CUTOFF/5)) +head -n $prop1 Global_Superstore2.csv.shuf > Global_Superstore2.csv.test +head -n $((prop1*2)) Global_Superstore2.csv.shuf | tail -n $prop1 > Global_Superstore2.csv.dev +tail -n +$((prop1*2+1)) Global_Superstore2.csv.shuf > Global_Superstore2.csv.train +rm Global_Superstore2.csv.shuf +#Sprawdźmy, czy wielkości się zgadzają: +wc -l Global_Superstore2.csv* \ No newline at end of file