Update jenkinsfile after testing by edits live on jenkins

This commit is contained in:
Karl Palsson 2020-09-08 23:19:11 +00:00
parent 04dd4c6fc8
commit 52dc1ff6d7

View File

@ -2,72 +2,78 @@
pipeline { pipeline {
agent {label 'locm3-usb'} agent {label 'locm3-usb'}
parameters { parameters {
string(name:'pr_from_git_url', description:'the git url we are going to clone the pr from') 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_sha', description:'what we are going to build')
} }
stages { stages {
// TODO - set build status to pneding....
stage('checkout') { stage('checkout') {
steps { steps {
sh "echo karl we are building $pr_from_sha" 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"]]])
//checkout([$class: 'GitSCM', branches: [[name: $pr_from_sha]], userRemoteConfigs: [[url: $pr_from_git_url]]]) step([$class: 'GitHubSetCommitStatusBuilder'])
git branch: "$pr_from_sha", url: "$pr_from_url"
} }
} }
stage('build') { stage('prepare') {
steps { steps {
sh 'make -j5 V=s' sh label: 'preparing python', script: '''
sh 'make -C tests/gadget-zero all V=s' [ -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') { stage('Testprepare') {
steps { steps {
sh label: 'preparing ', script: ''' sh label: 'gadget0', script: '''
[ -f .env3 ] || python3 -m venv .env3 cd tests/gadget-zero
. .env/bin/activate echo "hla_serial 53FF6E066765505136472567" > openocd.stm32f3-disco.local.cfg
pip install pyusb echo "hla_serial 57FF6B064967485630481087" > openocd.stm32f4disco.local.cfg
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
'''
} }
} }
stage('flashin') { stage('flashin') {
steps { steps {
dir('tests/gadget-zero') { dir('tests/gadget-zero') {
sh ''' sh '''
make -f Makefile.stm32f3-disco flash V=1 make -f Makefile.stm32f3-disco flash V=1
make -f Makefile.stm32f4disco flash V=1 make -f Makefile.stm32f4disco flash V=1
''' '''
} }
} }
} }
stage('run-test') { stage('run-test') {
steps { steps {
sh ''' sh '''
. .env/bin/activate . .env3/bin/activate
cd tests/gadget-zero cd tests/gadget-zero
python test_gadget0.py -X rm -rf tests
for x in tests/*; do TT=$(basename $x); sed -i "s/testcase classname=\"/testcase classname=\"${TT}./g" $x/TEST-*; done 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 { post {
always { always {
junit 'tests/gadget-zero/tests/*/TEST-*.xml' junit 'tests/gadget-zero/tests/*/TEST-*.xml'
step([ step([
$class: "GitHubCommitStatusSetter", $class: "GitHubCommitStatusSetter",
commitShaSource: [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/karlp/libopencm3"], commitShaSource: [$class: "ManuallyEnteredShaSource", sha: "$pr_from_sha"],
reposSource: [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/karlp/libopencm3"], reposSource: [$class: "ManuallyEnteredRepositorySource", url: "$pr_from_git_url"],
contextSource: [$class: "DefaultCommitContextSource"], contextSource: [$class: "DefaultCommitContextSource"],
statusResultSource: [ $class: "DefaultStatusResultSource"] statusResultSource: [ $class: "DefaultStatusResultSource"]
]); ]);
} }
} }
} }