From 12b0121c4d60c69dfb8da7f600ef51a7f0a1a485 Mon Sep 17 00:00:00 2001 From: Adrian Charkiewicz Date: Thu, 24 Mar 2022 19:43:47 +0100 Subject: [PATCH] Jenkinsfile functions --- Jenkinsfile | 43 ++++++++++++++++++++++++++++++++++--------- Jenkinsfile2 | 52 ++++++++++++++++++++++++++++++++-------------------- 2 files changed, 66 insertions(+), 29 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 96c5209..5e78b83 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,12 +1,37 @@ pipeline { agent any - stages { - stage('Stage 1') { - steps { - - echo 'Hello elo jenkins!' - - } - } - } + parameters { + string( + defaultValue: 'sknera', + description: 'username', + name: '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' + ) + string( + defaultValue: '', + description: 'Value for head command', + name: 'CUTOFF' + ) + } + environment { + KAGGLE_USERNAME="$params.KAGGLE_USERNAME" + KAGGLE_KEY="$params.KAGGLE_KEY" + CUTOFF="$params.CUTOFF" + } + stages { + stage('Stage 1') { + steps { + echo 'Hello world' + checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[url: 'https://git.wmi.amu.edu.pl/s444354/ium_444354']]]) + sh "chmod u+x ./dataset_download.sh" + sh "KAGGLE_USERNAME=${KAGGLE_USERNAME} KAGGLE_KEY=${KAGGLE_KEY} CUTOFF=${CUTOFF} ./download.sh" + archiveArtifacts 'data.txt' + } + } + } } \ No newline at end of file diff --git a/Jenkinsfile2 b/Jenkinsfile2 index 9f16f1e..bc5a04c 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -1,25 +1,37 @@ pipeline { agent any - stages { - stage('Check out from version control') { + parameters { + string( + defaultValue: 'sknera', + description: 'username', + name: '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' + ) + string( + defaultValue: '', + description: 'Value for head command', + name: 'CUTOFF' + ) + } + environment { + KAGGLE_USERNAME="$params.KAGGLE_USERNAME" + KAGGLE_KEY="$params.KAGGLE_KEY" + CUTOFF="$params.CUTOFF" + } + stages { + stage('Stage 1') { steps { - checkout scm + echo 'Hello world' + checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[url: 'https://git.wmi.amu.edu.pl/s444354/ium_444354']]]) + sh "chmod u+x ./dataset_download.sh" + sh "KAGGLE_USERNAME=${KAGGLE_USERNAME} KAGGLE_KEY=${KAGGLE_KEY} CUTOFF=${CUTOFF} ./download.sh" + archiveArtifacts 'data.txt' } } - - stage('Shell Script') { - steps { - sh '''#!/bin/bash - sh './script.sh' - ''' - } - } - - - - -} -} - - - + } +} \ No newline at end of file