'Executing Same Jenkins job by picking fail_skip xml once first execution is over
I am from QA automation and pretty new to jenkins, below is my case
Process: I have a jenkins job which picks up a file criticalsuite.xml (testng) and triggers the execution. once the job completes, it generates a file name fail_skip xml in the same workspace.
Question: How do I configure a job to pick up this fail_skip.xml and trigger the execution automatically once the main job completes execution.
CUrrently, we are manually triggering the same job by pasting the fail_skip xml. I basically want to get rid of this maual intervention
Solution 1:[1]
If you used Jenkins pipeline, It would be easy to do it in a different stage. In my below declarative Jenkinsfile example, the stage-01 create a file and stage-02 parse it and read it.
pipeline {
agent any;
stages {
stage('01') {
steps {
writeFile file: "${env.WORKSPACE}/details.yml", text: """
name: Scott
address:
houseNumber: x01
city: XX
country: Space
"""
}
}
stage('02') {
steps {
script {
def yamlContent = readYaml file: "${env.WORKSPACE}/details.yml"
println yamlContent.address.country
}
}
}
}
}
you can even extend this scenario with post-build stage. meaning after the job run depends on SUCCESS or FAILURE you can decide what to do. Please take a look at this jenkins documentation for more details. something like this:
pipeline {
agent any;
stages {
...
}
post {
success {
script {
def yamlContent = readYaml file: "${env.WORKSPACE}/details.yml"
println yamlContent.address.city
}
}
failure {
echo "IT'S FAIL"
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Samit Kumar Patel |