From 52dc1ff6d77b49c5cf01fd90a46b86eaaa873a4f Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Tue, 8 Sep 2020 23:19:11 +0000 Subject: [PATCH] Update jenkinsfile after testing by edits live on jenkins --- tests/gadget-zero/Jenkinsfile | 104 ++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 49 deletions(-) diff --git a/tests/gadget-zero/Jenkinsfile b/tests/gadget-zero/Jenkinsfile index 92210115..49a5fa36 100644 --- a/tests/gadget-zero/Jenkinsfile +++ b/tests/gadget-zero/Jenkinsfile @@ -2,72 +2,78 @@ pipeline { agent {label 'locm3-usb'} parameters { - string(name:'pr_from_git_url', description:'the git url we are going to clone the pr from') - string(name:'pr_from_sha', description:'what we are going to build') + string(name:'pr_from_git_url', description:'the git url we are going to clone the pr from') + string(name:'pr_from_sha', description:'what we are going to build') } stages { - // TODO - set build status to pneding.... stage('checkout') { steps { - sh "echo karl we are building $pr_from_sha" - step([$class: 'GitHubSetCommitStatusBuilder']) - //checkout([$class: 'GitSCM', branches: [[name: $pr_from_sha]], userRemoteConfigs: [[url: $pr_from_git_url]]]) - git branch: "$pr_from_sha", url: "$pr_from_url" + sh "echo karl we are building $pr_from_sha" + checkout([$class: 'GitSCM', branches: [[name: "$pr_from_sha"]], userRemoteConfigs: [[url: "$pr_from_git_url"]]]) + step([$class: 'GitHubSetCommitStatusBuilder']) } } - stage('build') { - steps { - sh 'make -j5 V=s' - sh 'make -C tests/gadget-zero all V=s' - } - } + stage('prepare') { + steps { + sh label: 'preparing python', script: ''' + [ -f .env3 ] || python3 -m venv .env3 + . .env3/bin/activate + pip install pyusb + pip install unittest-xml-reporting + ''' + } + } + stage('build') { + steps { + sh ''' + . .env3/bin/activate + make -j5 V=s + make -C tests/gadget-zero all V=s + ''' + } + } stage('Testprepare') { steps { - sh label: 'preparing ', script: ''' - [ -f .env3 ] || python3 -m venv .env3 - . .env/bin/activate - pip install pyusb - pip install unittest-xml-reporting - ''' - sh label: 'gadget0', script: ''' - cd tests/gadget-zero - echo "hla_serial 53FF6E066765505136472567" > openocd.stm32f3-disco.local.cfg - echo "hla_serial 57FF6B064967485630481087" > openocd.stm32f4disco.local.cfg - ''' + sh label: 'gadget0', script: ''' + cd tests/gadget-zero + echo "hla_serial 53FF6E066765505136472567" > openocd.stm32f3-disco.local.cfg + echo "hla_serial 57FF6B064967485630481087" > openocd.stm32f4disco.local.cfg + ''' } } - stage('flashin') { - steps { - dir('tests/gadget-zero') { - sh ''' - make -f Makefile.stm32f3-disco flash V=1 - make -f Makefile.stm32f4disco flash V=1 - ''' - } - } - } + stage('flashin') { + steps { + dir('tests/gadget-zero') { + sh ''' + make -f Makefile.stm32f3-disco flash V=1 + make -f Makefile.stm32f4disco flash V=1 + ''' + } + } + } stage('run-test') { steps { sh ''' - . .env/bin/activate - cd tests/gadget-zero - python test_gadget0.py -X - for x in tests/*; do TT=$(basename $x); sed -i "s/testcase classname=\"/testcase classname=\"${TT}./g" $x/TEST-*; done - ''' + . .env3/bin/activate + cd tests/gadget-zero + rm -rf tests + python test_gadget0.py -X + for x in tests/*; do TT=$(basename \$x); sed -i "s/testcase\\ classname=\\"/testcase\\ classname=\\"\${TT}./g" \$x/TEST-*; done + ''' } } } post { - always { - junit 'tests/gadget-zero/tests/*/TEST-*.xml' - step([ - $class: "GitHubCommitStatusSetter", - commitShaSource: [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/karlp/libopencm3"], - reposSource: [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/karlp/libopencm3"], - contextSource: [$class: "DefaultCommitContextSource"], - statusResultSource: [ $class: "DefaultStatusResultSource"] - ]); - } + always { + junit 'tests/gadget-zero/tests/*/TEST-*.xml' + step([ + $class: "GitHubCommitStatusSetter", + commitShaSource: [$class: "ManuallyEnteredShaSource", sha: "$pr_from_sha"], + reposSource: [$class: "ManuallyEnteredRepositorySource", url: "$pr_from_git_url"], + contextSource: [$class: "DefaultCommitContextSource"], + statusResultSource: [ $class: "DefaultStatusResultSource"] + ]); + } } }