From 7656ba3dc45178105de6d9957eae6fdbc819015d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Pogodzi=C5=84ski?= Date: Sat, 15 May 2021 18:39:17 +0200 Subject: [PATCH] added docker to jenkins files (lab4/zad3) --- Jenkinsfile | 15 +++++++++++---- Jenkinsfile-stats | 43 ++++++++++++++++++++++--------------------- script.sh | 2 +- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7f3380c..51f48f8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,15 +4,22 @@ pipeline{ stages{ stage('checkout: Check out from version control'){ steps{ - git url: 'https://github.com/jfrogdev/project-examples.git' + git url: 'https://git.wmi.amu.edu.pl/s437622/ium_s437622.git' } } - stage('sh: Shell Script'){ + stage('docker') + { steps{ - ./script.sh + script{ + def img = docker.build('jpogodzinski/ium:1') + img.inside{ + sh './script.sh' + } + } + } } - stage('Archive artifacts'){ + stage('end'){ steps{ archiveArtifacts 'test.csv' archiveArtifacts 'dev.csv' diff --git a/Jenkinsfile-stats b/Jenkinsfile-stats index 111ddec..a3c845f 100644 --- a/Jenkinsfile-stats +++ b/Jenkinsfile-stats @@ -1,29 +1,30 @@ - pipeline{ +pipeline{ agent any - properties([parameters([ - buildSelector( - defaultSelector: lastSuccessful(), - description: 'Which build to use for copying artifacts', - name: 'BUILD_SELECTOR') -])]) + parameters{ + buildSelector( + defaultSelector: lastSuccessful(), + description: 'Which build to use for copying artifacts', + name: 'BUILD_SELECTOR') + } stages{ - stage('checkout: Check out from version control'){ - steps{ - git credentialsId: 'b4ba8ec9-8fc6-4f68-bf24-695634cec73e', url: 'https://git.wmi.amu.edu.pl/s437622/ium_s437622.git' + stage('Copy artifacts'){ + copyArtifacts filter: 'dev.csv, train.csv, test.csv', fingerprintArtifacts: false, projectName: 's437622-create-dataset', selector: buildParameter('BUILD_SELECTOR') + } + stage('Docker') { + steps { + script { + docker.image("jpogodzinski/ium:1").inside { + sh 'rm -rf ium_s437622' + sh 'git clone https://git.wmi.amu.edu.pl/s437622/ium_s437622.git' + sh "chmod +x ium_s437622/stats.sh" + sh "ium_437622/stats.sh" + }} + } } - } - stage('copy artifacts'){ - copyArtifacts filter: 'dev.csv, train.csv, test.csv', fingerprintArtifacts: true, projectName: 's437622-create-dataset', selector: buildParameter('BUILD_SELECTOR') - } - stage('sh: Shell Script'){ - steps{ - ./stats.sh - } - } stage('Archive artifacts'){ steps{ archiveArtifacts 'stats.txt' + } } } - } -} \ No newline at end of file + } \ No newline at end of file diff --git a/script.sh b/script.sh index 6a1cb26..74e8446 100755 --- a/script.sh +++ b/script.sh @@ -1,6 +1,6 @@ #!/bin/bash curl -OL https://git.wmi.amu.edu.pl/s437622/ium_s437622/src/branch/master/games.csv -head -n -1 games.csv | shuf > chess.csv.shuf +tail -n +2 games.csv | shuf > chess.csv.shuf wc -l chess.csv head -n 2006 chess.csv.shuf > test.csv head -n 4012 chess.csv.shuf | tail -n 2006 > dev.csv