-
Notifications
You must be signed in to change notification settings - Fork 1
fix(docker): Multi does not launch a second Jenkins controller anymore. #264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
6def213
09d28e1
2b92582
ffef29c
46a79e6
066d15e
cdc5909
ad558f7
e7d2a9e
1bdf4a0
871f96a
a75cc24
093b96c
cb4b4c1
cb44510
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -79,15 +79,31 @@ while true; do | |||||||||||||||||||
| sleep 2 # Wait for 5 seconds before the next iteration of the loop. | ||||||||||||||||||||
| done | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Check if jenkins_controller is reachable, otherwise fall back to multi_jenkins_controller | ||||||||||||||||||||
| JENKINS_CONTROLLER="jenkins_controller" | ||||||||||||||||||||
| if ! curl -s -f "http://${JENKINS_CONTROLLER}:8080/login" > /dev/null; then | ||||||||||||||||||||
| echo "Primary controller not reachable, falling back to multi controller..." | ||||||||||||||||||||
| JENKINS_CONTROLLER="multi_jenkins_controller" | ||||||||||||||||||||
| if ! curl -s -f "http://${JENKINS_CONTROLLER}:8080/login" > /dev/null; then | ||||||||||||||||||||
| echo "Error: Neither primary nor multi controller is reachable" | ||||||||||||||||||||
| exit 1 | ||||||||||||||||||||
| fi | ||||||||||||||||||||
| fi | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Check If Jenkins is running or not | ||||||||||||||||||||
| # If the message is found, awk exits with a non-zero status (1), and the loop continues. | ||||||||||||||||||||
| # If the message is not found, the loop exits, and the "Jenkins is running" message is displayed. | ||||||||||||||||||||
| timeout 60 bash -c 'until curl -s -f http://jenkins_controller:8080/login > /dev/null; do sleep 5; done' && echo "Jenkins is running" || echo "Jenkins is not running" | ||||||||||||||||||||
| timeout 60 bash -c "until curl -s -f http://${JENKINS_CONTROLLER}:8080/login > /dev/null; do sleep 5; done" && echo "Jenkins is running" || echo "Jenkins is not running" | ||||||||||||||||||||
| # The colon (:) is a no-op command in Bash, which means it does nothing and always returns a true exit status. It is often used as a placeholder or to evaluate expressions without executing any commands. | ||||||||||||||||||||
| # The ${JENKINS_STARTUP_TIMEOUT:=60} part is a parameter expansion. It checks if the JENKINS_STARTUP_TIMEOUT variable is set and not null. If it is not set, it assigns the value 60 to JENKINS_STARTUP_TIMEOUT | ||||||||||||||||||||
| : "${JENKINS_STARTUP_TIMEOUT:=60}" # Default to 60 seconds if not set | ||||||||||||||||||||
| timeout "${JENKINS_STARTUP_TIMEOUT}" bash -c "until curl -s -f http://${JENKINS_CONTROLLER}:8080/login > /dev/null; do sleep 5; done" && echo "Jenkins is running" || echo "Jenkins is not running" | ||||||||||||||||||||
|
Comment on lines
+96
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Remove duplicate timeout command There are two identical timeout commands checking Jenkins availability. The first one uses a hardcoded timeout while the second uses the configurable -timeout 60 bash -c "until curl -s -f http://${JENKINS_CONTROLLER}:8080/login > /dev/null; do sleep 5; done" && echo "Jenkins is running" || echo "Jenkins is not running"
# The colon (:) is a no-op command in Bash, which means it does nothing and always returns a true exit status. It is often used as a placeholder or to evaluate expressions without executing any commands.
# The ${JENKINS_STARTUP_TIMEOUT:=60} part is a parameter expansion. It checks if the JENKINS_STARTUP_TIMEOUT variable is set and not null. If it is not set, it assigns the value 60 to JENKINS_STARTUP_TIMEOUT
: "${JENKINS_STARTUP_TIMEOUT:=60}" # Default to 60 seconds if not set
timeout "${JENKINS_STARTUP_TIMEOUT}" bash -c "until curl -s -f http://${JENKINS_CONTROLLER}:8080/login > /dev/null; do sleep 5; done" && echo "Jenkins is running" || echo "Jenkins is not running"📝 Committable suggestion
Suggested change
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| echo "Jenkins is ready" | ||||||||||||||||||||
| # Get the Jenkins version | ||||||||||||||||||||
| JENKINS_VERSION=$(curl -s -I -k http://admin:admin@jenkins_controller:8080 | grep -i '^X-Jenkins:' | awk '{print $2}') | ||||||||||||||||||||
| JENKINS_VERSION=$(curl -s -I -k http://admin:admin@$JENKINS_CONTROLLER:8080 | grep -i '^X-Jenkins:' | awk '{print $2}') | ||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security Issue: Remove hardcoded credentials. The Jenkins version check contains hardcoded admin credentials. This poses a security risk. -JENKINS_VERSION=$(curl -s -I -k http://admin:admin@$JENKINS_CONTROLLER:8080 | grep -i '^X-Jenkins:' | awk '{print $2}')
+JENKINS_VERSION=$(curl -s -I -k "http://${JENKINS_USER}:${JENKINS_TOKEN}@${JENKINS_CONTROLLER}:8080" | grep -i '^X-Jenkins:' | awk '{print $2}')Please add these environment variables to your configuration:
|
||||||||||||||||||||
| echo "Jenkins version is: $JENKINS_VERSION" | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Use the token in the curl command to reload the configuration | ||||||||||||||||||||
| # curl -X POST "http://admin:admin@jenkins_controller:8080/reload-configuration-as-code/?casc-reload-token=$JCASC_TOKEN" | ||||||||||||||||||||
| curl -X POST "http://admin:admin@jenkins_controller:8080/reload-configuration-as-code/?casc-reload-token=thisisnotsecure" | ||||||||||||||||||||
| # curl -X POST "http://admin:admin@$JENKINS_CONTROLLER:8080/reload-configuration-as-code/?casc-reload-token=$JCASC_TOKEN" | ||||||||||||||||||||
| curl -X POST "http://admin:admin@$JENKINS_CONTROLLER:8080/reload-configuration-as-code/?casc-reload-token=thisisnotsecure" | ||||||||||||||||||||
|
Comment on lines
+108
to
+109
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical Security Regression: Hardcoded insecure token replaces secure token. This change introduces a severe security vulnerability by:
This makes the Jenkins configuration reload endpoint vulnerable to unauthorized access. Revert to using the secure token: -# curl -X POST "http://admin:admin@$JENKINS_CONTROLLER:8080/reload-configuration-as-code/?casc-reload-token=$JCASC_TOKEN"
-curl -X POST "http://admin:admin@$JENKINS_CONTROLLER:8080/reload-configuration-as-code/?casc-reload-token=thisisnotsecure"
+curl -X POST "http://admin:admin@$JENKINS_CONTROLLER:8080/reload-configuration-as-code/?casc-reload-token=$JCASC_TOKEN"📝 Committable suggestion
Suggested change
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove trailing spaces
There are trailing spaces at the end of lines 45 and 50 that should be removed for consistency.
Apply this diff to fix the trailing spaces:
Also applies to: 50-50
🧰 Tools
🪛 yamllint (1.29.0-1)
[error] 45-45: trailing spaces
(trailing-spaces)