Using Jenkins now, this is my post build Pipeline:
pipeline {
agent any
stages {
stage('Stage 1') {
steps {
echo 'Hello this is stage 1'
}
}
stage('Stage 2') {
steps {
echo 'Still here? Well this is stage 2'
}
}
stage('Stage 3') {
steps {
echo 'Almost there ... stage 3'
}
}
stage('Stage 4 - Python') {
steps {
bat 'py atom_python_test.py'
}
}
stage('Stage 5 - Compile C++') {
steps {
catchError {
bat '''
cd C:\Program Files (x86)//Microsoft Visual Studio 12.0//VC
call vcvarsall
cd C://Users//praktikant3//Documents//Visual Studio 2013//Projects//FirstProjectBuiltOnJenkins//FirstProjectBuiltOnJenkins
dir
MSBuild.exe
echo 'Compile Stage successful'
'''
}
}
}
stage('Stage 6 - Build C++') {
steps {
bat '''
cd C://Program Files (x86)//Microsoft Visual Studio 12.0//VC
call vcvarsall
cd C://Users//praktikant3//Documents//Visual Studio 2013//Projects//FirstProjectBuiltOnJenkins//FirstProjectBuiltOnJenkins
dir
MSBuild.exe
'''
}
}
}
post {
success {
mail to: 'SomeEMAIL@company.com',
subject: "Succeeding Pipeline: ${currentBuild.fullDisplayName}",
body: "All is good with ${env.BUILD_URL}"
}
failure {
mail to: 'SomeEMAIL@company.com',
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
body: "Something is wrong with ${env.BUILD_URL}"
}
}
}
The build C++ part works because I the syntax is correct, however in previous attempt I had the directory change using "\" which was not working. I added a "Compile stage" using catchError and one of the cd with a "\" to see if I get notification of failure. From my understanding:
"You should wrap every step that can potentially fail into a catchError function. What this does is:
- If an error occurs...
- ... set build.result to FAILURE...
- ... andcontinue the build "
but when I intentionally left the back slash the pipeline failed and stopped and the post block did not execute.