Perhaps the best way is to define a global environment variable with different values for each Jenkins instance
Manage Settings > Configure System Global properties Environment variables https://build-ci.company.com;8443/ JENKINS_ENVIRONMENT > PRODUCTION https://build-ci-test.company.com;8443/ JENKINS_ENVIRONMENT > TEST Which can be read in scripted pipeline as env.JENKINS_ENVIRONMENT mandag 12. november 2018 15.43.20 UTC+1 skrev Sverre Moe følgende: > > > We have copied our Jenkins instance to have an identical test Jenkins. > > Is there a *proper* way to distinguish between production Jenkins and > test Jenkins within a Scripted Pipeline? > > We need different behaviour for some parts of our builds, like publishing > Yum artifacts, git tagging releases. > This we need to check if the running Jenkins instance is either production > or test. > > I know we can check the environment variable JENKINS_URL, but that is not > a good solution. > It would require us to have the both URLs defined in our shared pipeline > scripts. > def environments [:] > environments["PRODUCTION"] = "https://build-ci.company.com:8443" > environments["TEST"] = "https://build-ci-test.company.com:8443" > > -- 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/ea6b61d2-4ae4-4946-86de-c1a51c081697%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.