So I have a school project that have given me so many headaches in every step of the way. It is located on Github and is run through Jenkins as a pipeline project, parameterized with git parameters for branches. There are 2 branches, main and b1 and this is my Jenkinsfile
pipeline {
agent any
stages {
stage('build'){
steps{
sh "mvn compile"
}
}
stage('Test') {
steps{
sh "mvn test"
}
post {
always {
jacoco(
execPattern: 'target/*.exec',
classPattern: 'target/classes',
sourcePattern: 'src/main/java',
exclusionPattern: 'src/test*'
)
junit '**/TEST*.xml'
}
}
}
stage('Run Robot and Post Test') {
steps{
sh script: 'python -m robot C:/Users/ersha/.jenkins/workspace/Pär_Ershag/Selenium/test.robot', returnStatus: true
}
post {
always {
robot outputPath: 'C:/Users/ersha/.jenkins/workspace/Pär_Ershag@2', passThreshold: 100.0, unstableThreshold: 70.0, onlyCritical: false
}
}
}
}
}
My issue is that regardless of what branch I choose to build it will always use an old version of test.robot located at the same path as the step sh script: 'python -m robot...' is refering to. Main and b1 have both different versions of the file but neither are run. This despite having a "clean before cheackout" step in additional behaviours.
I have compared my Jenkinsfile to others doing the same project and the biggest difference is that the stage for 'Run Robot and Post Test' is stated as: bat " robot their test.robot path"
I can't use bat for my steps for some reason even though I use windows hence why I had to use sh and a script in Jenkins to make it work.
ps: I'm kinda new to Jenkins so there are many things that I don't understand yet.
Using hard coded paths is most of the times a bad idea.
Jenkins has a built in variable to reference the agent/node actual workspace. In you example I would try:
(...)
stage('Run Robot and Post Test') {
steps{
sh script: 'cd ${WORKSPACE} && python -m robot Pär_Ershag/Selenium/test.robot', returnStatus: true
}
post {
always {
robot outputPath: '${WORKSPACE}/Pär_Ershag@2', passThreshold: 100.0, unstableThreshold: 70.0, onlyCritical: false
}
}
}