-
Notifications
You must be signed in to change notification settings - Fork 411
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
Add marker file via Dockerfile. Script will remove marker and exit if… #198
base: master
Are you sure you want to change the base?
Changes from 1 commit
ecd4ccb
ce62f18
f1d086d
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM cloudbees/cloudbees-core-mm:2.303.2.6 | ||
|
||
RUN mkdir -p /var/jenkins_home/init.groovy.d | ||
COPY ./ucCertRemediation.groovy /var/jenkins_home/init.groovy.d/ | ||
|
||
RUN touch /var/jenkins_home/init.groovy.d/DO_NOT_RUN_UC_REMEDIATION && \ | ||
chown jenkins /var/jenkins_home/init.groovy.d/DO_NOT_RUN_UC_REMEDIATION && \ | ||
chmod 755 /var/jenkins_home/init.groovy.d/DO_NOT_RUN_UC_REMEDIATION |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,10 @@ | |
* - 2.277.42.0.3 or newer on the 2.277.x fixed release, or | ||
* - 2.249.33.0.2 on the 2.249.x fixed release | ||
* | ||
* - OCI Container notes | ||
* If this script is installed into a container via Dockerfile, the container will need to be run once and restarted | ||
* for this script to take effect. | ||
* | ||
* How to use this script | ||
* - This script can be run using the script console on any individual operations center or controller. It may also be run via | ||
* a cluster-operation (https://docs.cloudbees.com/docs/cloudbees-ci/latest/cloud-admin-guide/cluster-operations) | ||
|
@@ -62,6 +66,18 @@ | |
* ERROR_CONTACT_SUPPORT: [msg] | ||
*/ | ||
|
||
import hudson.model.UpdateCenter; | ||
import hudson.model.UpdateSite; | ||
import hudson.util.PersistedList; | ||
import jenkins.model.Jenkins; | ||
import com.cloudbees.jenkins.plugins.license.nectar.CloudBeesUpdateSite; | ||
import net.sf.json.JSONObject; | ||
import net.sf.json.JSONException; | ||
import hudson.util.FormValidation; | ||
import java.security.cert.CertificateExpiredException; | ||
import hudson.model.DownloadService; | ||
|
||
|
||
def _script = ''' | ||
import hudson.model.UpdateCenter; | ||
import hudson.model.UpdateSite; | ||
|
@@ -95,6 +111,16 @@ _retry_time = 30000; // how long to wait before checking for an update site to | |
_cert_error_str = "CertificateExpiredException: NotAfter: Tue Oct 19 14:31:36 EDT 2021"; | ||
|
||
// MAIN CODE BODY | ||
info("Checking for first run inside an OCI container"); | ||
// The Dockerfile will need to create this file. It will prevent this script from running. | ||
noRunFilePath = "/var/jenkins_home/init.groovy.d/DO_NOT_RUN_UC_REMEDIATION"; | ||
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. I would store this marker file outside of the init.groovy folder in case jenkins tries to "run" it during the initial install |
||
def noRunFile = new File (noRunFilePath) | ||
if (noRunFile.exists()) { | ||
info("Found marker file for first run. Removing file and exiting") | ||
noRunFile.delete() | ||
return "NO_CHANGE_NEEDED" | ||
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.
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. do I need to add it to the list of ok returns or have it handle that as an error? 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. yeah, probably. i'd treat it as a success |
||
} | ||
|
||
info("Executing remediation check [v" + _version + "]"); | ||
if (System.properties['_CLOUDBEES_UC_CERT_REMEDIATION_INSTALL'] == "TRUE") { | ||
info("Running bootstrap install, disabling retry interval"); | ||
|
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.
suggest not storing this in the init.groovy.d folder so that jenkins doesn't try to run it
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.
Good plan