this.metaClass.mixin script
}
+// New container have their all jobs nextBuildNumber=1 if it is restarted prior to deploy.
+// Below will keep current build numbers.
+def setNextBuildNumber = {
+ jobs = Jenkins.instance.projects.collect { it.name }
+ jobs.each() { job ->
+ set_num = 0
+ new File(env['JENKINS_HOME'] + '/jobs/' + job + '/builds').eachDir() { dir ->
+ def thisdir = dir.getName().split("\\.")[0]
+ if (thisdir.isNumber()) {
+ if (thisdir.toInteger() > set_num) {
+ set_num = thisdir.toInteger()
+ }
+ }
+ }
+ item = Jenkins.instance.getItemByFullName(job)
+ item.updateNextBuildNumber(set_num + 1)
+ item.save()
+ }
+}
+
Properties properties = new Properties()
try {
properties.load(new FileInputStream(env['JENKINS_HOME'] + '/.groovy_init_required'))
new File(env['JENKINS_HOME'] + '/.groovy_init_required').delete()
///////////////////////////////////////////////////////////////////
+/////////// Update proper build numbers for each job ////////////
+///////////////////////////////////////////////////////////////////
+setNextBuildNumber()
+
+///////////////////////////////////////////////////////////////////
/////////////////// E-mail Notification /////////////////////////
///////////////////////////////////////////////////////////////////
if (properties.SMTP_HOST != null && properties.SMTP_HOST != '') {