|
23 | 23 | - System message
|
24 | 24 | - Quiet Period
|
25 | 25 | - SCM checkout retry count
|
26 |
| - - Number of master executors |
27 |
| - - Master labels |
28 |
| - - Master usage (e.g. exclusive or any job runs on master) |
29 |
| - - TCP port for JNLP slave agents |
| 26 | + - Number of controller executors |
| 27 | + - Controller labels |
| 28 | + - Controller usage (e.g. exclusive requiring built-in label or any job could run by default) |
| 29 | + - TCP port for JNLP build agents |
30 | 30 | */
|
31 | 31 |
|
32 | 32 | import jenkins.model.Jenkins
|
33 | 33 | import jenkins.model.JenkinsLocationConfiguration
|
34 | 34 | import net.sf.json.JSONObject
|
35 | 35 |
|
36 |
| -if(!binding.hasVariable('master_settings')) { |
37 |
| - master_settings = [:] |
| 36 | +if(!binding.hasVariable('controller_settings')) { |
| 37 | + controller_settings = [:] |
38 | 38 | }
|
39 |
| -if(!(master_settings instanceof Map)) { |
40 |
| - throw new Exception('master_settings must be a Map.') |
| 39 | +if(!(controller_settings instanceof Map)) { |
| 40 | + throw new Exception('controller_settings must be a Map.') |
41 | 41 | }
|
42 | 42 |
|
43 |
| -master_settings = master_settings as JSONObject |
| 43 | +controller_settings = controller_settings as JSONObject |
44 | 44 |
|
45 | 45 | def requiredDefaultValues(def value, List values, def default_value) {
|
46 | 46 | (value in values)? value : default_value
|
47 | 47 | }
|
48 | 48 |
|
49 | 49 | //settings with sane defaults
|
50 |
| -String frontend_url = master_settings.optString('frontend_url', 'http://localhost:8080/') |
51 |
| -String admin_email = master_settings.optString('admin_email') |
52 |
| -String system_message = master_settings.optString('system_message') |
53 |
| -int quiet_period = master_settings.optInt('quiet_period', 5) |
54 |
| -int scm_checkout_retry_count = master_settings.optInt('scm_checkout_retry_count', 0) |
55 |
| -int master_executors = master_settings.optInt('master_executors', 2) |
56 |
| -String master_labels = master_settings.optString('master_labels') |
57 |
| -String master_usage = requiredDefaultValues(master_settings.optString('master_usage').toUpperCase(), ['NORMAL', 'EXCLUSIVE'], 'EXCLUSIVE') |
58 |
| -int jnlp_slave_port = master_settings.optInt('jnlp_slave_port', -1) |
| 50 | +String frontend_url = controller_settings.optString('frontend_url', 'http://localhost:8080/') |
| 51 | +String admin_email = controller_settings.optString('admin_email') |
| 52 | +String system_message = controller_settings.optString('system_message') |
| 53 | +int quiet_period = controller_settings.optInt('quiet_period', 5) |
| 54 | +int scm_checkout_retry_count = controller_settings.optInt('scm_checkout_retry_count', 0) |
| 55 | +int controller_executors = controller_settings.optInt('controller_executors', 2) |
| 56 | +String controller_labels = controller_settings.optString('controller_labels') |
| 57 | +String controller_usage = requiredDefaultValues(controller_settings.optString('controller_usage').toUpperCase(), ['NORMAL', 'EXCLUSIVE'], 'EXCLUSIVE') |
| 58 | +int jnlp_agent_port = controller_settings.optInt('jnlp_agent_port', -1) |
59 | 59 |
|
60 | 60 | Jenkins j = Jenkins.instance
|
61 | 61 | JenkinsLocationConfiguration location = j.getExtensionList('jenkins.model.JenkinsLocationConfiguration')[0]
|
@@ -86,29 +86,29 @@ if(j.scmCheckoutRetryCount != scm_checkout_retry_count) {
|
86 | 86 | j.scmCheckoutRetryCount = scm_checkout_retry_count
|
87 | 87 | save = true
|
88 | 88 | }
|
89 |
| -if(j.numExecutors != master_executors) { |
90 |
| - println "Setting master num executors to: ${master_executors}" |
91 |
| - j.numExecutors = master_executors |
| 89 | +if(j.numExecutors != controller_executors) { |
| 90 | + println "Setting controller num executors to: ${controller_executors}" |
| 91 | + j.numExecutors = controller_executors |
92 | 92 | save = true
|
93 | 93 | }
|
94 |
| -if(j.labelString != master_labels) { |
95 |
| - println "Setting master labels to: ${master_labels}" |
96 |
| - j.setLabelString(master_labels) |
| 94 | +if(j.labelString != controller_labels) { |
| 95 | + println "Setting controller labels to: ${controller_labels}" |
| 96 | + j.setLabelString(controller_labels) |
97 | 97 | save = true
|
98 | 98 | }
|
99 |
| -if(j.mode.toString() != master_usage) { |
100 |
| - println "Setting master usage to: ${master_usage}" |
101 |
| - j.mode = Node.Mode."${master_usage}" |
| 99 | +if(j.mode.toString() != controller_usage) { |
| 100 | + println "Setting controller usage to: ${controller_usage}" |
| 101 | + j.mode = Node.Mode."${controller_usage}" |
102 | 102 | save = true
|
103 | 103 | }
|
104 |
| -if(j.slaveAgentPort != jnlp_slave_port) { |
105 |
| - if(jnlp_slave_port <= 65535 && jnlp_slave_port >= -1) { |
106 |
| - println "Set JNLP Slave port: ${jnlp_slave_port}" |
107 |
| - j.slaveAgentPort = jnlp_slave_port |
| 104 | +if(j.slaveAgentPort != jnlp_agent_port) { |
| 105 | + if(jnlp_agent_port <= 65535 && jnlp_agent_port >= -1) { |
| 106 | + println "Set JNLP Agent port: ${jnlp_agent_port}" |
| 107 | + j.slaveAgentPort = jnlp_agent_port |
108 | 108 | save = true
|
109 | 109 | }
|
110 | 110 | else {
|
111 |
| - println "WARNING: JNLP port ${jnlp_slave_port} outside of TCP port range. Must be within -1 <-> 65535. Nothing changed." |
| 111 | + println "WARNING: JNLP port ${jnlp_agent_port} outside of TCP port range. Must be within -1 <-> 65535. Nothing changed." |
112 | 112 | }
|
113 | 113 | }
|
114 | 114 | //save configuration to disk
|
|
0 commit comments