For my ETL scripts I am using a continuous development infrastructure: if the test workflow is successful, it means that it can be pushed into production and then be run during the night, if the test is not successful then the changes are not pushed but the production scripts still run.
So far I am manually rebasing my test branch to my master branch every time I make a successful change. I would like to automate this so that, once the test pipeline job is complete and successful, Jenkins automatically rebase the master branch on the test branch and push it on the remote repository.
Here's my current jenkins pipeline code mock-up (Jenkinsfile_test):
def gv
pipeline {
agent any
stages{
stage("init") {
steps {
script {
gv = load "script.groovy"
}
}
}
stage("01_test1") {
when {
changeset "**/01_test1/**"
}
steps {
script {
gv.test1()
}
}
}
stage("02_test2") {
when {
changeset "**/02_test2/**"
}
steps {
script {
gv.test2()
}
}
}
}
post {
success {
echo "success"
withCredentials([usernamePassword(credentialsId: 'xxx',
usernameVariable: 'xxx',
passwordVariable: 'xxx')]){
sh "git checkout master"
sh "git rebase test"
sh("git push http://$username:$password@http://git-server/test.git test")
}
}
}
}
I tried solutions found here: Is it possible to Git merge / push using Jenkins pipeline
But it is not working. I actually do not know how to set up my success step.
Here are the errors I get when running the jenkins pipeline job:
Error when executing success post condition:
java.io.IOException: CreateProcess error=2, The system cannot find the file specified
Caused: java.io.IOException: Cannot run program "nohup" (in directory "C:\Program Files
(x86)\Jenkins\workspace\test_pipeline")
Any help would be much appreciated.