From c98f3376aeedaecbf7cecd6fc50ac83b1032a2a1 Mon Sep 17 00:00:00 2001 From: Monssaf Toukal Date: Thu, 10 Feb 2022 11:41:27 -0500 Subject: [PATCH] fix failed builds in jenkinsfile --- Jenkinsfile | 20 ++++++++++---------- benchmark/push_benchmarks.sh | 16 ++++++++++++++-- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b27adc933..43afeb3da 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -64,13 +64,16 @@ pipeline { stages { stage('clone repo') { when { - expression { REPO_EXISTS == 'false' } + expression { REPO_EXISTS == 'false' && env.comment } } steps { sh 'git clone https://${GITHUB_AUTH}@github.com/$org/$repo.git' } } stage('checkout on new branch') { + when { + expression { env.comment } + } steps { dir(WORKSPACE + "/$repo") { sh ''' @@ -87,6 +90,9 @@ pipeline { } } stage('run benchmarks') { + when { + expression {env.comment} + } steps { script { def data = env.comment.tokenize(' ') @@ -95,9 +101,9 @@ pipeline { } } dir(WORKSPACE + "/$repo") { - sh "mkdir -p $HOME/benchmarks/${org}/${repo}" - sh "qsub -N ${repo}_${pullrequest} -V -cwd -o $HOME/benchmarks/${org}/${repo}/${pullrequest}_${BUILD_NUMBER}_bmark_output.log -e $HOME/benchmarks/${org}/${repo}/${pullrequest}_${BUILD_NUMBER}_bmark_error.log benchmark/push_benchmarks.sh $bmarkFile" - } + sh "mkdir -p $HOME/benchmarks/${org}/${repo}" + sh "qsub -N ${repo}_${pullrequest} -V -cwd -o $HOME/benchmarks/${org}/${repo}/${pullrequest}_${BUILD_NUMBER}_bmark_output.log -e $HOME/benchmarks/${org}/${repo}/${pullrequest}_${BUILD_NUMBER}_bmark_error.log benchmark/push_benchmarks.sh $bmarkFile" + } } } } @@ -106,13 +112,7 @@ pipeline { echo "SUCCESS!" } cleanup { - dir(WORKSPACE + "/$repo") { sh 'printenv' - sh ''' - git clean -fd - git checkout main - ''' - } } } } diff --git a/benchmark/push_benchmarks.sh b/benchmark/push_benchmarks.sh index 62414443f..ca5fc8bfa 100644 --- a/benchmark/push_benchmarks.sh +++ b/benchmark/push_benchmarks.sh @@ -1,10 +1,18 @@ #!/bin/bash +set -e +git clean -fd +git checkout main +git pull origin main +git fetch origin +LOCAL_BRANCH_NAME="temp_bmark" +git branch -D $LOCAL_BRANCH_NAME || true +git fetch origin pull/$pullrequest/head:$LOCAL_BRANCH_NAME +git checkout $LOCAL_BRANCH_NAME -- || true + julia --project=benchmark -E 'using Pkg; Pkg.resolve()' julia --project=benchmark benchmark/send_comment_to_pr.jl -o $org -r $repo -p $pullrequest -c '**Starting benchmarks!**' -LOCAL_BRANCH_NAME="temp_bmark" -git checkout $LOCAL_BRANCH_NAME -- || true julia --project=benchmark benchmark/$1 $repo @@ -14,3 +22,7 @@ else ERROR_LOGS="/home/jenkins/benchmarks/$org/$repo/${pullrequest}_${BUILD_NUMBER}_bmark_error.log" julia --project=benchmark benchmark/send_comment_to_pr.jl -o $org -r $repo -p $pullrequest -c "**An error occured while running $1**" -g $ERROR_LOGS fi + +git clean -fd +git reset --hard +git checkout main