I am trying to do something that, in my opinion, should be simple, but I cannot figure out how to do it.
Mostly I have a Jenkins wizard (runs on Linux) and two slaves, one on Windows and the other on macOS.
I want to create my project on all three platforms and run GTest tests on all three platforms.
I can create and run the test, but the junit step does not seem to collect any test results.
I tried to hang the post block everywhere, but it just doesn't work. If I try to put the post block at the testing stage or as sibling stages , I get the following error:
Required context class hudson.FilePath is missing Perhaps you forgot to surround the code with a step that provides this, such as: node which is called agent none - the post block does not know where to run.
So, I tried to put the post block inside the node block in the parallel step for the testing phase, but it doesn't seem to do anything - it doesn't even display the output on the console.
Here is my Jenkins file:
pipeline { agent none stages { stage ('Clean') { steps { parallel ( "linux" : { node ("linux") { dir("build") { deleteDir() writeFile file:'dummy', text:'' // Creates the directory } } }, "windows" : { node('windows') { dir("build") { deleteDir() writeFile file:'dummy', text:'' // Creates the directory } } }, "mac" : { node('mac') { dir("build") { deleteDir() writeFile file:'dummy', text:'' // Creates the directory } } } ) } } stage ('Build') { steps { parallel ( "linux" : { node ("linux") { checkout scm dir("build") { sh '/opt/cmake/bin/cmake .. -DCMAKE_BUILD_TYPE=Release' sh 'make' } } }, "windows" : { node('windows') { checkout(changelog: false, scm: scm) // Changelog to false, otherwise Jenkins shows duplicates. Only linux (the Jenkins master) has the changelog enabled. dir("build") { bat 'cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_PREFIX_PATH=C:/Qt/5.9.1/msvc2017_64' bat "\"${tool 'MSBuild'}\" project.sln /p:Configuration=Release /p:Platform=\"x64\" /p:ProductVersion=1.0.0.${env.BUILD_NUMBER} /m" } } }, "mac" : { node('mac') { checkout(changelog: false, scm: scm) // Changelog to false, otherwise Jenkins shows duplicates. Only linux (the Jenkins master) has the changelog enabled. dir("build") { sh 'cmake .. -DCMAKE_PREFIX_PATH=/usr/local/Cellar/qt/5.9.1 -DCMAKE_BUILD_TYPE=Release' sh 'make' } } } ) } } stage ('Test') { steps { parallel ( "linux" : { node ("linux") { dir('Build') { sh './bin/project-tests --gtest_output=xml:project-tests-results.xml' // Add other test executables here. } post { always { junit '*-tests-results.xml' } } } }, "windows" : { node('windows') { dir("build") { bat 'tests\\project\\Release\\project-tests --gtest_output=xml:project-tests-results.xml' // Add other test executables here. } post { always { junit '*-tests-results.xml' } } } }, "mac" : { node('mac') { dir("build") { sh './bin/project-tests --gtest_output=xml:project-tests-results.xml' // Add other test executables here. } post { always { junit '*-tests-results.xml' } } } } ) } } } }
What am I doing wrong?