I recently changed on project with 27 build runs the project settings from "Jenkinsfile" to "Jenkinsfile.groovy". A "Scan Multibranch Pipeline" happend and could not find that file, because git repo was not prepared for that change (a commit/push would have caused a build run before i where able to change the project settings). Build history disappeared. Removing "Jenkinsfile" and adding "Jenkinsfile.groovy" with the next commit enables "Scan Multibranch Pipeline" to find the "Jenkinsfile.groovy" but build number was reset to 1 and history of the other 27 builds is still gone.
BTW: I am not sure why the filename refactoring in IntelliJ IDEA did not end up in a git tracked file rename (as deleted and created instead), but this is not be the root cause here (i think), because the multibranch feature is a VCS agnostic feature (as far as i know; should work with other VCS than git, so should not tied to git rename tracking).
When changing the Jenkinsfile filename the build history should stay intact and the very next available build number should be picket for next build. Resetting build number to 1 is not desireable. If it is not possible to keep the old build history and build number than a "Do you really want to drop build history and reset your build number?" should be asked when changing Jenkinsfile filename in project settings. Build numbers are very important to track changes from ticket to release and for support feedback loop. Disrupting the tracking chain and integration with other tools (ticket system, artifact repo, documentation, etc.) is a very bad impact.
Please provide instruction:
- on how to recover to old history (Jenkinsfile)
- on how to go ahead with Jenkins.groovy, keeping old history and maintaining build numbers (next = 28)
I am running:
Jenkins: Jenkins ver. 2.46.2
Pipeline Multibranch (workflow-multibranch-plugin) 2.16
Changing the filename was introduced by https://issues.jenkins-ci.org/browse/JENKINS-34561 i think that case was not tested.
JENKINS-34561 was merged at 2017-06-05 and release on 2017-06-20 (see https://github.com/jenkinsci/workflow-multibranch-plugin/releases )
I think the one in https://issues.jenkins-ci.org/browse/JENKINS-36244 could ran into the same problem (but he or she could not figure out the root cause) - i link his/her ticket here as related.