0

I am following Git flow: How to configure a one-click release process in Jenkins? to implement release process with Jenkins pipeline. However I am not sure what should I do to reset develop branch if something will fail.

This is a part on my pipeline stage:

try {
    sh "mvn -f jgitflow:release-start -B -U -DskipTests"

    try {
        sh "mvn -f jgitflow:release-finish -B -U -DskipTests -Dmaven.javadoc.skip=true -DnoDeploy=false"
    } catch(err) {
        currentBuild.result = 'FAILURE'
        println("Cannot finish a release, undoing...")

        //undoing

        return
    }

} catch(err) {
    currentBuild.result = 'FAILURE'
    println("Release failed")
    return
}

Should I discover a release branch (with regexp) and delete it, then do a git reset --hard HEAD~1 to reset a develop branch?

Are there any other ways to do it?

OK999
  • 1,353
  • 2
  • 19
  • 39
staszko032
  • 802
  • 6
  • 16
  • the main objective in the question doesn't seem to have any co-relation with git flow. Its more about how to use Git. If your code is not compiling error free, you fix the code and re-build it. Why do you think, you have to do a reset --hard HEAD~1? This will delete your history and even more dangerous when you have committed to the remote – OK999 Apr 19 '18 at 14:51
  • I just want to restore the previous state of repository if something fails, e.g. I don't want to keep a commit increasing a snapshot version of pom on develop branch and I don't want to keep a release branch anymore. – staszko032 Apr 19 '18 at 14:59
  • For the release branch or any branch, if you dont need it. just delete it. To delete it locally: `git branch -d feature/login` and to delete it from the remote: `git push origin --delete feature/login`. And for the other question: not a recommended standard process, to try and delete if failed from a remote repo. Try and build the project locally first, before you push – OK999 Apr 19 '18 at 15:04
  • So should I disable automatic pushing with jgitflow, then perform release-start operation, finally, if everything will be ok, push local changes to remote? The same flow for release-finish? I am not a git expert, I am sorry. – staszko032 Apr 19 '18 at 15:19
  • 1
    i am sorry, i can't really advise without having an understanding on your local env. But all the code/jenkins pipeline, that you shared in the OP will be executed for codes that reaches the git repo. What i do and many others is to build the code locally in my workstation even before i push, like `mvn install`. And if this looks okay locallu, do a `git push` to remote to be shared with the collaborators. – OK999 Apr 19 '18 at 15:46
  • I think that you have helped me to understand a real problem, thank you. – staszko032 Apr 19 '18 at 16:00

0 Answers0