ium_424714/Jenkinsfile-eval
2023-05-10 17:05:15 +02:00

86 lines
3.3 KiB
Plaintext

node {
stage('Preparation') {
properties([
pipelineTriggers([
// TODO change auto run after train
upstream(
threshold: hudson.model.Result.SUCCESS,
upstreamProjects: 's424714-create-dataset'
)
]),
copyArtifactPermission('*'),
parameters([
buildSelector(
defaultSelector: lastSuccessful(),
description: 'Which build to use for copying artifacts',
name: 'BUILD_SELECTOR'
),
])
])
}
stage('Git clone') {
//cloning git repo
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: 's424714', url: 'https://git.wmi.amu.edu.pl/s424714/ium_424714']]])
}
stage('Dockerfile build') {
sh "chmod +x -R ${env.WORKSPACE}"
copyArtifacts fingerprintArtifacts: true, projectName: 's424714-create-dataset', selector: buildParameter('BUILD_SELECTOR')
//TODO from train
copyArtifacts filter: '*', projectName: 's424714-training/train'
// copyArtifacts filter('*.csv') projectName: env.JOB_NAME, selector: specific(env.BUILD_NUMBER)
// copyArtifacts fingerprintArtifacts: true, projectName: 's424714-create-dataset', selector: buildParameter('BUILD_SELECTOR')
def dockerImage = docker.image("s424714-model:latest")
dockerImage.inside {
withEnv(["TRANSFORMERS_CACHE=./.cache"]) {
stage("Docker: cloning artifacts"){
script {
if (currentBuild.previousBuild) {
try {
copyArtifacts(projectName: currentBuild.projectName,
selector: specific("${currentBuild.previousBuild.number}"))
echo("The current build is ${currentBuild.number}")
sh 'mkdir -p ./results/'
sh 'mv acc.csv ./results/acc.csv'
} catch(err) {
echo("NOT FOUND previos acc artifacts")
// ignore error
}
}
}
sh 'mkdir -p ./data/dataset'
sh 'mv -t ./data/dataset train.csv test.csv val.csv'
sh 'mv -t ./data True.csv Fake.csv'
sh 'mkdir -p ./results/'
sh 'mv model.pt ./results/model.pt'
}
stage("Docker: Running evaluation model")
{
sh 'mkdir -p ./.cache'
// sh ""
sh 'python ./src/main.py --test --build_id=1 '
sh 'python ./src/plot.py '
sh "cp ./results/*.csv ${WORKSPACE}"
sh "cp ./results/*.png ${WORKSPACE}"
}
}
}
}
stage('Saving artefacts') {
echo 'Goodbye!'
sh 'ls'
archiveArtifacts artifacts: '*.csv', '*.png'
}
}