Hi All, I have written groovy script to set the global environment variables as part of the post build groovy step. I could able to the set the properties but the properties are not refreshing by default while running next build.
Is there any way to refresh the global properties once we set through the groovy script. import hudson.model.* import hudson.slaves.EnvironmentVariablesNodeProperty import jenkins.model.Jenkins //Removing the environment variables if any before creating. instance = Jenkins.getInstance() globalNodeProperties = instance.getGlobalNodeProperties() envVarsNodePropertyList = globalNodeProperties.getAll(EnvironmentVariablesNodeProperty.class) newEnvVarsNodeProperty = null envVars = null if ( envVarsNodePropertyList == null || envVarsNodePropertyList.size() == 0 ) { newEnvVarsNodeProperty = new EnvironmentVariablesNodeProperty(); globalNodeProperties.add(newEnvVarsNodeProperty) envVars = newEnvVarsNodeProperty.getEnvVars() } else { envVars = envVarsNodePropertyList.get(0).getEnvVars() } envVars.clear() //Setting the environment variables again def matcher = manager.getLogMatcher("(.*)Tests run: (.*), Failures: (.*), Errors:(.*), Skipped: (.*), Time elapsed:(.*)\$") if (matcher?.matches()) { def totalTests = matcher.group(2) as int; def totalFailedTests = matcher.group(3) as int; def totalErrorTests = matcher.group(4) as int; def totalSkippedTests = matcher.group(5) as int; def totalPassTests = totalTests - totalFailedTests - totalErrorTests -totalSkippedTests ; def overallPassPercentage = (totalPassTests/totalTests) * 100 as int; manager.listener.logger.println("totalTests count "+totalTests) manager.listener.logger.println("totalFailedTests count "+totalFailedTests) manager.listener.logger.println("totalErrorTests count "+totalErrorTests) manager.listener.logger.println("totalSkippedTests count "+totalSkippedTests) manager.listener.logger.println("totalPassTests count "+totalPassTests) manager.listener.logger.println("overallPassPercentage "+overallPassPercentage) envVars.put("totalTests", totalTests+"") envVars.put("totalFailedTests", totalFailedTests+"") envVars.put("totalErrorTests", totalErrorTests+"") envVars.put("totalSkippedTests", totalSkippedTests+"") envVars.put("totalPassTests", totalPassTests+"") envVars.put("overallPassPercentage", overallPassPercentage+"") instance.save() } I am getting the n-1 build values during N build execution in Post Build Task Step. Can someone help me on this. Please let me know if we can achieve "Passing Data From Groovy Post Build To Post Build Task Via Global Properties" in any other way. Thanks Santhosh. -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/7e6ccde2-a349-40a9-8952-8358625bdf82%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.