RE: Jenkins init.groovy compilation

2017-12-19 Thread Jason Grammenos
Thank you very much Reinhold Füreder

I will look into reflection, but probably just choose to ignore the errors and 
they do not end up causing problems anyways.
And I will consider filling a bug with Jenkins.


[Agility PR Solutions]<https://agilitypr.com/>
Jason Grammenos | Operations and Infrastructure Analyst
P: 613.232.7797 | Toll-free: 866.545.3745
Work hours: Monday-Friday, 8am-4:30pm ET
jason.gramme...@agilitypr.com
agilitypr.com<https://agilitypr.com/> (formerly MediaMiser)

From: jenkinsci-users@googlegroups.com 
[mailto:jenkinsci-users@googlegroups.com] On Behalf Of Reinhold Füreder
Sent: December 19, 2017 1:45 AM
To: jenkinsci-users@googlegroups.com
Subject: RE: Jenkins init.groovy compilation

Hi Jason,

yes, I remember stumbling over this as well.

Partially I have actually uses a workaround for that compilation failure: 
However, I am not sure it is worth it – because it is based on using 
reflection, e.g.:

def instance = Jenkins.getInstance()
…
// LDAPSecurityRealm class depends on "LDAP" plugin => use reflection for 
creation:
def ldapSecurityRealmClass = 
this.class.classLoader.loadClass('hudson.security.LDAPSecurityRealm')
SecurityRealm ldapRealm = ldapSecurityRealmClass.newInstance(server, 
rootDN, userSearchBase, userSearch, groupSearchBase, managerDN, 
managerPassword, inhibitInferRootDN)
instance.setSecurityRealm(ldapRealm)
instance.save()


And later on, IIRC, I mostly “only” relied on the init scripts (one for each 
responsibility “area”) checking whether or not a restart due to plugin 
installation/updates is still pending based on a kind of marker file (and 
ignoring compilation failures):

def restartFile = new File(instance.getRootDir(), "JenkinsRestartByInitScript")
if (restartFile.exists()) {
  println "--> Jenkins restart is pending: skipping this hook script"
  return
}
// Here follows the logic like setting up the LDAP security realm…


HTH -- although this is not a real solution,
Reinhold
--
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<mailto:jenkinsci-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/AM4P190MB00677F1A1C76C862343A189EF70F0%40AM4P190MB0067.EURP190.PROD.OUTLOOK.COM<https://groups.google.com/d/msgid/jenkinsci-users/AM4P190MB00677F1A1C76C862343A189EF70F0%40AM4P190MB0067.EURP190.PROD.OUTLOOK.COM?utm_medium=email_source=footer>.
For more options, visit https://groups.google.com/d/optout.

-- 
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/YTOPR0101MB100385502D752D88B987294DE40F0%40YTOPR0101MB1003.CANPRD01.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


FW: Jenkins init.groovy compilation

2017-12-15 Thread Jason Grammenos

Hello,

I am having an issue with multiple scripts in init.groovy.d, and the scripts 
failing compilation.
Situation:
There are 2 scripts

  1.  The first script installs a bunch of plugins.
  2.  Second script sets up authentication

The second script depends on plugins installed by script 1  (eg: import 
com.michelin.cio.hudson.plugins.rolestrategy.*)
Script 1, invokes a Jenkins restart when it is finished.

So Jenkins start its init, compiles and runs script 1, and then attempts to 
compile script 2,
but has not yet completed its restart and doesn't realise the plugins are 
installed so Script 2 fails compilation.
The restart completes and all the scripts are run again, this time successfully.

Is there any way to prevent this compilation failure?

Thank you
Regards
Jason

[Agility PR Solutions]<https://agilitypr.com/>
Jason Grammenos | Operations and Infrastructure Analyst
P: 613.232.7797 | Toll-free: 866.545.3745
Work hours: Monday-Friday, 8am-4:30pm ET
jason.gramme...@agilitypr.com<mailto:jason.gramme...@agilitypr.com>
agilitypr.com<https://agilitypr.com/> (formerly MediaMiser)

-- 
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/YTOPR0101MB1003831F222090C48417072EE40B0%40YTOPR0101MB1003.CANPRD01.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.