From 4cf94b59ae3880cb1b7efadcf0ff2ee411e70eca Mon Sep 17 00:00:00 2001 From: filnow Date: Tue, 26 Mar 2024 21:15:11 +0100 Subject: [PATCH] jenkins --- JenkinsFileStats | 38 ++++++++++++++++++++++++++++++++++++++ Jenkinsfile | 45 +++++++++++++++++++++++++++++++++++++++++++-- calculate.sh | 1 + download.sh | 6 ++++++ 4 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 JenkinsFileStats create mode 100644 calculate.sh create mode 100644 download.sh diff --git a/JenkinsFileStats b/JenkinsFileStats new file mode 100644 index 0000000..a3562a6 --- /dev/null +++ b/JenkinsFileStats @@ -0,0 +1,38 @@ +pipeline { + agent any + + parameters { + buildSelector( + defaultSelector: lastSuccessful(), + description: 'Which build to use for copying artifacts', + name: 'BUILD_SELECTOR') + } + + stages { + stage('Checkout') { + steps { + git branch: 'main', url: 'https://git.wmi.amu.edu.pl/s464915/ium_464915.git' + } + } + + stage('Copy Artifacts') { + steps { + script { + copyArtifacts fingerprintArtifacts: true, projectName: 'z-s464915-create-dataset', selector: buildParameter('BUILD_SELECTOR') + } + } + } + + stage('Execute Script') { + steps { + sh 'bash calculate.sh' + } + } + + stage('Archive Results') { + steps { + archiveArtifacts artifacts: 'stats.txt', onlyIfSuccessful: true + } + } + } +} \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index 89aa24e..4f66394 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,9 +1,50 @@ pipeline { agent any + + parameters { + string( + defaultValue: 'filipnowicki', + description: 'Kaggle username', + name: 'KAGGLE_USERNAME', + trim: false + ) + string( + defaultValue: '100', + description: 'Dataset cutoff parametr', + name: 'CUTOFF', + 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' + ) + } + stages { - stage('Stage 1') { + stage('Download Dataset') { steps { - echo 'Hello World' + script { + def datasetDir = 'data' + if (!fileExists(datasetDir)) { + sh "mkdir ${datasetDir}" + } + + withEnv(["KAGGLE_USERNAME=${params.KAGGLE_USERNAME}", + "KAGGLE_KEY=${params.KAGGLE_KEY}"]) { + sh "bash ./download.sh" + } + } + } + post { + success { + archiveArtifacts artifacts: 'data/**', onlyIfSuccessful: true + } + } + } + stage('Checkout') { + steps { + git branch: 'main', url: 'https://git.wmi.amu.edu.pl/s464915/ium_464915.git' } } } diff --git a/calculate.sh b/calculate.sh new file mode 100644 index 0000000..f622b7b --- /dev/null +++ b/calculate.sh @@ -0,0 +1 @@ +wc -l calculate_stats.sh > stats.txt \ No newline at end of file diff --git a/download.sh b/download.sh new file mode 100644 index 0000000..ad4f2ba --- /dev/null +++ b/download.sh @@ -0,0 +1,6 @@ +pip install kaggle +kaggle datasets download -d fanconic/skin-cancer-malignant-vs-benign +mv skin-cancer-malignant-vs-benign.zip ./data/ +unzip ./data/skin-cancer-malignant-vs-benign.zip -d ./data/ +rm ./data/skin-cancer-malignant-vs-benign.zip +