Skip to content

Commit

Permalink
perform config terminology migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
samrocketman committed Oct 23, 2022
1 parent aac6882 commit 0861acc
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 54 deletions.
4 changes: 2 additions & 2 deletions jenkins_bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,5 @@ fi

#configure jenkins agent credentials
#jenkins_console --script "${SCRIPT_LIBRARY_PATH}/credentials-jenkins-agent.groovy"
#disable agent -> master security
#jenkins_console --script "${SCRIPT_LIBRARY_PATH}/security-disable-agent-master.groovy"
#disable agent -> controller security
#jenkins_console --script "${SCRIPT_LIBRARY_PATH}/security-disable-agent-controller.groovy"
8 changes: 4 additions & 4 deletions scripts/configure-docker-cloud.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ JSONArray clouds_docker = [
launcher_credentials_id: "jenkins-docker-cloud-credentials",
launcher_jvm_options: "",
launcher_java_path: "/home/jenkins/java/openjdk8/bin/java",
launcher_prefix_start_slave_cmd: "",
launcher_suffix_start_slave_cmd: "",
launcher_prefix_start_agent_cmd: "",
launcher_suffix_start_agent_cmd: "",
launcher_connection_timeout_seconds: 0,
launcher_max_num_retries: 0,
launcher_retry_wait_time: 0
Expand Down Expand Up @@ -129,8 +129,8 @@ def newDockerTemplate(JSONObject obj) {
obj.optString('launcher_credentials_id'),
obj.optString('launcher_jvm_options'),
obj.optString('launcher_java_path'),
obj.optString('launcher_prefix_start_slave_cmd'),
obj.optString('launcher_suffix_start_slave_cmd'),
obj.optString('launcher_prefix_start_agent_cmd'),
obj.optString('launcher_suffix_start_agent_cmd'),
obj.optInt('launcher_connection_timeout_seconds'),
obj.optInt('launcher_max_num_retries'),
obj.optInt('launcher_retry_wait_time')
Expand Down
64 changes: 32 additions & 32 deletions scripts/configure-jenkins-settings.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,39 @@
- System message
- Quiet Period
- SCM checkout retry count
- Number of master executors
- Master labels
- Master usage (e.g. exclusive or any job runs on master)
- TCP port for JNLP slave agents
- Number of controller executors
- Controller labels
- Controller usage (e.g. exclusive requiring built-in label or any job could run by default)
- TCP port for JNLP build agents
*/

import jenkins.model.Jenkins
import jenkins.model.JenkinsLocationConfiguration
import net.sf.json.JSONObject

if(!binding.hasVariable('master_settings')) {
master_settings = [:]
if(!binding.hasVariable('controller_settings')) {
controller_settings = [:]
}
if(!(master_settings instanceof Map)) {
throw new Exception('master_settings must be a Map.')
if(!(controller_settings instanceof Map)) {
throw new Exception('controller_settings must be a Map.')
}

master_settings = master_settings as JSONObject
controller_settings = controller_settings as JSONObject

def requiredDefaultValues(def value, List values, def default_value) {
(value in values)? value : default_value
}

//settings with sane defaults
String frontend_url = master_settings.optString('frontend_url', 'http://localhost:8080/')
String admin_email = master_settings.optString('admin_email')
String system_message = master_settings.optString('system_message')
int quiet_period = master_settings.optInt('quiet_period', 5)
int scm_checkout_retry_count = master_settings.optInt('scm_checkout_retry_count', 0)
int master_executors = master_settings.optInt('master_executors', 2)
String master_labels = master_settings.optString('master_labels')
String master_usage = requiredDefaultValues(master_settings.optString('master_usage').toUpperCase(), ['NORMAL', 'EXCLUSIVE'], 'EXCLUSIVE')
int jnlp_slave_port = master_settings.optInt('jnlp_slave_port', -1)
String frontend_url = controller_settings.optString('frontend_url', 'http://localhost:8080/')
String admin_email = controller_settings.optString('admin_email')
String system_message = controller_settings.optString('system_message')
int quiet_period = controller_settings.optInt('quiet_period', 5)
int scm_checkout_retry_count = controller_settings.optInt('scm_checkout_retry_count', 0)
int controller_executors = controller_settings.optInt('controller_executors', 2)
String controller_labels = controller_settings.optString('controller_labels')
String controller_usage = requiredDefaultValues(controller_settings.optString('controller_usage').toUpperCase(), ['NORMAL', 'EXCLUSIVE'], 'EXCLUSIVE')
int jnlp_agent_port = controller_settings.optInt('jnlp_agent_port', -1)

Jenkins j = Jenkins.instance
JenkinsLocationConfiguration location = j.getExtensionList('jenkins.model.JenkinsLocationConfiguration')[0]
Expand Down Expand Up @@ -86,29 +86,29 @@ if(j.scmCheckoutRetryCount != scm_checkout_retry_count) {
j.scmCheckoutRetryCount = scm_checkout_retry_count
save = true
}
if(j.numExecutors != master_executors) {
println "Setting master num executors to: ${master_executors}"
j.numExecutors = master_executors
if(j.numExecutors != controller_executors) {
println "Setting controller num executors to: ${controller_executors}"
j.numExecutors = controller_executors
save = true
}
if(j.labelString != master_labels) {
println "Setting master labels to: ${master_labels}"
j.setLabelString(master_labels)
if(j.labelString != controller_labels) {
println "Setting controller labels to: ${controller_labels}"
j.setLabelString(controller_labels)
save = true
}
if(j.mode.toString() != master_usage) {
println "Setting master usage to: ${master_usage}"
j.mode = Node.Mode."${master_usage}"
if(j.mode.toString() != controller_usage) {
println "Setting controller usage to: ${controller_usage}"
j.mode = Node.Mode."${controller_usage}"
save = true
}
if(j.slaveAgentPort != jnlp_slave_port) {
if(jnlp_slave_port <= 65535 && jnlp_slave_port >= -1) {
println "Set JNLP Slave port: ${jnlp_slave_port}"
j.slaveAgentPort = jnlp_slave_port
if(j.slaveAgentPort != jnlp_agent_port) {
if(jnlp_agent_port <= 65535 && jnlp_agent_port >= -1) {
println "Set JNLP Agent port: ${jnlp_agent_port}"
j.slaveAgentPort = jnlp_agent_port
save = true
}
else {
println "WARNING: JNLP port ${jnlp_slave_port} outside of TCP port range. Must be within -1 <-> 65535. Nothing changed."
println "WARNING: JNLP port ${jnlp_agent_port} outside of TCP port range. Must be within -1 <-> 65535. Nothing changed."
}
}
//save configuration to disk
Expand Down
2 changes: 1 addition & 1 deletion scripts/configure-permanent-agents.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ permanent_agents = [
plugin without requiring that it be installed if an admin does not need to
configure SSH agents.
This script will succeed both with and without the SSH slaves plugin
This script will succeed both with and without the SSH Build Agents plugin
installed.
*/
Class loadClass(String clazz) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/configure-pipeline-global-shared-libraries.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ boolean isLibrariesEqual(List lib1, List lib2) {
/* Example configuration
pipeline_shared_libraries = [
'Global Library Name': [
'defaultVersion': 'master-fu',
'defaultVersion': 'main',
'implicit': true,
'allowVersionOverride': false,
'includeInChangesets': false,
Expand Down
22 changes: 11 additions & 11 deletions scripts/configure-yadocker-cloud.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ clouds_yadocker = [
//STOP CONTAINER SETTINGS
remove_volumes: false,
force_remove_containers: false,
//JENKINS SLAVE CONFIG
//JENKINS AGENT CONFIG
remote_fs_root: "/home/jenkins",
labels: "stable docker ubuntu1604 sudo language:groovy env jdk",
//valid values: exclusive or normal
Expand All @@ -143,17 +143,17 @@ clouds_yadocker = [
launch_ssh_port: 22,
launch_ssh_java_path: "",
launch_ssh_jvm_options: "",
launch_ssh_prefix_start_slave_command: "",
launch_ssh_suffix_start_slave_command: "",
launch_ssh_prefix_start_agent_command: "",
launch_ssh_suffix_start_agent_command: "",
launch_ssh_connection_timeout: 120,
launch_ssh_max_num_retries: 10,
launch_ssh_time_wait_between_retries: 10,
//settings specific to launch_jnlp
launch_jnlp_linux_user: "jenkins",
launch_jnlp_launch_timeout: 120,
launch_jnlp_slave_jar_options: "",
launch_jnlp_slave_jvm_options: "",
launch_jnlp_different_jenkins_master_url: "",
launch_jnlp_agent_jar_options: "",
launch_jnlp_agent_jvm_options: "",
launch_jnlp_different_jenkins_controller_url: "",
launch_jnlp_ignore_certificate_check: false,
//NODE PROPERTIES
//environment_variables is a HashMap of key/value pairs
Expand Down Expand Up @@ -186,8 +186,8 @@ def selectLauncher(String launcherType, JSONObject obj) {
obj.optString('launch_ssh_credentials_id'),
obj.optString('launch_ssh_jvm_options'),
obj.optString('launch_ssh_java_path'),
obj.optString('launch_ssh_prefix_start_slave_command'),
obj.optString('launch_ssh_suffix_start_slave_command'),
obj.optString('launch_ssh_prefix_start_agent_command'),
obj.optString('launch_ssh_suffix_start_agent_command'),
obj.optInt('launch_ssh_connection_timeout'),
obj.optInt('launch_ssh_max_num_retries'),
obj.optInt('launch_ssh_time_wait_between_retries')
Expand All @@ -197,9 +197,9 @@ def selectLauncher(String launcherType, JSONObject obj) {
DockerComputerJNLPLauncher dockerComputerJNLPLauncher = new DockerComputerJNLPLauncher()
dockerComputerJNLPLauncher.setUser(obj.optString('launch_jnlp_linux_user','jenkins'))
dockerComputerJNLPLauncher.setLaunchTimeout(obj.optLong('launch_jnlp_launch_timeout', 120L))
dockerComputerJNLPLauncher.setSlaveOpts(obj.optString('launch_jnlp_slave_jar_options'))
dockerComputerJNLPLauncher.setJvmOpts(obj.optString('launch_jnlp_slave_jvm_options'))
dockerComputerJNLPLauncher.setJenkinsUrl(obj.optString('launch_jnlp_different_jenkins_master_url'))
dockerComputerJNLPLauncher.setSlaveOpts(obj.optString('launch_jnlp_agent_jar_options'))
dockerComputerJNLPLauncher.setJvmOpts(obj.optString('launch_jnlp_agent_jvm_options'))
dockerComputerJNLPLauncher.setJenkinsUrl(obj.optString('launch_jnlp_different_jenkins_controller_url'))
dockerComputerJNLPLauncher.setNoCertificateCheck(obj.optBoolean('launch_jnlp_ignore_certificate_check', false))
return dockerComputerJNLPLauncher
default:
Expand Down
2 changes: 1 addition & 1 deletion scripts/credentials-multitype.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ import org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl
plugin without requiring that it be installed if an admin does not need to
configure SSH agents.
This script will succeed both with and without the SSH slaves plugin
This script will succeed both with and without the SSH Build Agents plugin
installed.
*/
Class loadClass(String clazz) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/upgrade/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Plugins are stored at [`repo.jenkins-ci.org`][2]. Gradle is used to download
plugins using [GAV coordinates][3]. When running `upgrade_build_gradle.sh`,
a local Jenkins instance is upgraded and all of the plugins are upgraded. Once
Jenkins is upgraded then `build.gradle` and `dependencies.gradle` is updated
with the new Jenkins master and plugin versions.
with the new Jenkins controller and plugin versions.

### Override Jenkins Update Center

Expand Down
2 changes: 1 addition & 1 deletion scripts/upgrade/upgrade_build_gradle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if [ -n "${USE_GRADLE_PROPERTIES:-}" ]; then
VERSION="${VERSION%.*}.$(( ${VERSION##*.} + 1 ))"
fi

#write jenkins master and plugin versions to build.gradle and dependencies.gradle
#write jenkins controller and plugin versions to build.gradle and dependencies.gradle
"${SCRIPT_LIBRARY_PATH}"/upgrade/remote_dependencies.sh

# GNU or BSD sed is required. Homebrew on Mac installs GNU sed as gsed.
Expand Down

0 comments on commit 0861acc

Please sign in to comment.