diff --git a/.gitignore b/.gitignore index 735dca1..9c9209f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ df_wta.csv atp-and-wta-tennis-data.zip data model.zip +secret.txt diff --git a/Dockerfile b/Dockerfile index b44dc48..b7c6426 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,18 +13,19 @@ RUN pip3 install pandas RUN pip3 install pillow --global-option="build_ext" --global-option="--disable-zlib" --global-option="--disable-jpeg" RUN pip3 install scikit-learn RUN pip3 install matplotlib -RUN mkdir ~/.kaggle/ -RUN echo '{"username":"wirus006","key":"c3323e37d3f91a0914d0172ef3c7c30c"}' > ~/.kaggle/kaggle.json # Create app directory in image WORKDIR /app -# Copy init dataset script to /app directory in image -COPY ./init.py ./ +COPY . . +ARG KAGGLE_USERNAME +ARG KAGGLE_KEY # Download kaggle dataset RUN kaggle datasets download -d hakeem/atp-and-wta-tennis-data RUN unzip -o atp-and-wta-tennis-data.zip # Script executed after docker run -CMD python3 ./init.py +RUN python3 ./init.py +RUN chmod a+rwx -R * +RUN ls -la \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index 6aae979..8689984 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,4 @@ -pipeline { - agent { - dockerfile true - } +pipeline { parameters { string ( defaultValue: 'wirus006', @@ -10,35 +7,28 @@ pipeline { trim: false ) password ( - defaultValue: 'c3323e37d3f91a0914d0172ef3c7c30c', + defaultValue: '', description: 'Kaggle token taken from kaggle.json file, as described in https://github.com/Kaggle/kaggle-api#api-credentials', name: 'KAGGLE_KEY' ) } + agent { + dockerfile { + additionalBuildArgs "--build-arg KAGGLE_USERNAME=${params.KAGGLE_USERNAME} --build-arg KAGGLE_KEY=${params.KAGGLE_KEY} -t s444498-create-dataset" + } + } stages { - stage('Hello') { - steps { - echo 'Hello world!' - } - } - stage('Checkout') { - steps { - git 'https://git.wmi.amu.edu.pl/s444498/ium_444498.git' - } - } - stage('Shell Script') { + stage('Archive dataset') { steps { withEnv(["KAGGLE_USERNAME=${params.KAGGLE_USERNAME}", "KAGGLE_KEY=${params.KAGGLE_KEY}"]) { - sh "chmod +x -R ${env.WORKSPACE}" sh 'echo hello world | figlet' + sh 'chmod a+rwx -R *' + sh 'pwd && ls' + sh 'ls /app/data/' + archiveArtifacts artifacts: '/app/data/*', onlyIfSuccessful: true } } } } - post { - always { - archiveArtifacts artifacts: '*atp*.csv', onlyIfSuccessful: true - } - } } diff --git a/init.py b/init.py index 97a7019..3f1fe4b 100644 --- a/init.py +++ b/init.py @@ -8,12 +8,6 @@ from pathlib import Path # Inicjalizacja danych -file_exists = exists('./df_atp.csv') - -if not file_exists: - subprocess.run(["kaggle", "datasets", "download", "-d", "hakeem/atp-and-wta-tennis-data"]) - subprocess.run(["unzip", "-o", "atp-and-wta-tennis-data.zip"]) - atp_data = pd.read_csv('df_atp.csv') print(atp_data)