From ea622e6f2a7399ad98e1463a9c347c1d619613a2 Mon Sep 17 00:00:00 2001 From: Claudiu Guiman Date: Fri, 14 Apr 2017 08:05:34 -0700 Subject: [PATCH] While installing jenkins set the Jenkins URL to the private ip so JNLP works & disable reverse proxy warning --- jenkins/install_jenkins.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/jenkins/install_jenkins.sh b/jenkins/install_jenkins.sh index e3eb13a..b1435a8 100644 --- a/jenkins/install_jenkins.sh +++ b/jenkins/install_jenkins.sh @@ -6,6 +6,7 @@ Command $0 Arguments --jenkins_fqdn|-jf [Required] : Jenkins FQDN + --vm_private_ip|-pi : The VM private ip used to configure Jenkins URL. If missing, jenkins_fqdn will be used instead --artifacts_location|-al : Url used to reference other scripts/artifacts. --sas_token|-st : A sas token needed if the artifacts location is private. EOF @@ -34,6 +35,10 @@ do jenkins_fqdn="$1" shift ;; + --vm_private_ip|-pi) + vm_private_ip="$1" + shift + ;; --artifacts_location|-al) artifacts_location="$1" shift @@ -54,6 +59,14 @@ done throw_if_empty --jenkins_fqdn $jenkins_fqdn +if [ -z "$vm_private_ip" ]; then + #use port 80 for public fqdn + jenkins_url="http://${jenkins_fqdn}/" +else + #use port 8080 for internal + jenkins_url="http://${vm_private_ip}:8080/" +fi + jenkins_auth_matrix_conf=$(cat < com.cloudbees.plugins.credentials.CredentialsProvider.Create:authenticated @@ -96,6 +109,22 @@ jenkins_auth_matrix_conf=$(cat < + + address not configured yet <nobody@nowhere> + ${jenkins_url} + +EOF +) + +jenkins_disable_reverse_proxy_warning=$(cat < + hudson.diagnosis.ReverseProxySetupMonitor + +EOF +) + nginx_reverse_proxy_conf=$(cat < /dev/null +#set up Jenkins URL to private_ip:8080 so JNLP connections can be established +echo "${jenkins_location_conf}" | sudo tee /var/lib/jenkins/jenkins.model.JenkinsLocationConfiguration.xml > /dev/null + +#disable 'It appears that your reverse proxy set up is broken' warning. +# This is visible when connecting through SSH tunneling +inter_jenkins_config=$(sed -zr -e"s||{disable-reverse-proxy-token}|" /var/lib/jenkins/config.xml) +final_jenkins_config=${inter_jenkins_config//'{disable-reverse-proxy-token}'/${jenkins_disable_reverse_proxy_warning}} +echo "${final_jenkins_config}" | sudo tee /var/lib/jenkins/config.xml > /dev/null + #restart jenkins sudo service jenkins restart