I've gone into the Manage Jenkins->In Process Script Security and nothing is pending approval.
I've taken the "7aa3609" string (which I'm guessing is a hash) and tried putting it directly into the approvedClasspathEntries in scriptApproval.xml
There is no "groovy sandbox" checkbox near the script as mentioned in similar problems I've seen described on the 'net.
I've started to play with Permissive Script Security Plugin, but would like to avoid that (and the instructions didn't make a lot of sense yet on MacOS).
The script is below. Is there an easy fix for this?!?
Pre-send script:
// Load up the first 1000 lines of the log file into a variable
def log = build.getLog(1000)
// Let's setup a boolean of the result of searching for the string that appears
// in the log file when a job successfully completes but no work occurred.
def NothingDone = (log ==~/.*Nothing downloaded, packaged or imported.*/)
assert NothingDone instanceof Boolean
logger.println("** NothingDone is " + NothingDone)
def Error = (log ==~/.*Error.*/)
assert Error instanceof Boolean
logger.println("** Error is " + Error)
def error = (log ==~/.*error.*/)
assert error instanceof Boolean
logger.println("** error is " + error)
// New items were imported into the munki repo
def NewItemsImported = (log ==~/.*new items were imported into Munki.*/)
assert NewItemsImported instanceof Boolean
logger.println("** NewItemsImported is " + NewItemsImported)
// New items were downloaded to the AutoPkg Cache directory
def NewItemsDownloaded = (log ==~/.*new items were downloaded.*/)
assert NewItemsDownloaded instanceof Boolean
logger.println("** NewItemsDownloaded is " + NewItemsDownloaded)
/* The below code is for AutoPkg FAQ #1:
*
* Every time I run a recipe it downloads something even if it didn't change. Why?
*
* the IS_TROUBLEMAKER is a per-job environmental variable set using the
*
* below is the elvis/ternary operator that does the following:
* if IS_TROUBLEMAKER is set from the Jenkins job configuration, take that value
* (it should be true). If it's not set/doesn't exist, set it to false
* because we have a lot of existing jobs and only set the IS_TROUBLEMAKER on jobs that
* ARE troublemakers!
*/
try {
// if IS_TROUBLMAKER is set by EnvInject plugin, set known_troublemaker to that value
// (as it could've been a troublemaker in the past, and set to false when it was
// fixed
known_troublemaker = $IS_TROUBLEMAKER
} catch (MissingPropertyExceptionmpe) {
// if we get an error, then it's because $IS_TROUBLEMAKER doesn't exist, so we
// should set it to false
known_troublemaker = false
logger.println("** IS_TROUBLEMAKER try failed, caught MissingPropertyExceptionmpe and set known_troublemaker to " + known_troublemaker)
}
logger.println("** known_troublemaker is " + known_troublemaker)
/* And now let's test against that boolean and kill the e-mail (cancelEmail = true) if it found the
* -Nothing downloaded, packaged or imported- string AND it hasn't found a string with Error or error
*/
if (NothingDone && !Error && !error) {
// AutoPkg neither downloaded to the AutoPkg Cache nor imported anything to the munki repo,
// so no e-mail this is the case 99% of the time
logger.println("=== e-mail cancelled: Job completed without errors but nothing was done (nothing downloaded or imported)")
cancel=true
} else if (NewItemsImported) {
// New items were imported into the Munki Repo, send the email.
logger.println("=*=*=*=*=*=*=*=*=*=*=*=* New Item in Munki Repo, E-mail Sent !!!! =*=*=*=*=*=*=*=*=*=*=*=*")
cancel=false
} else if (NewItemsDownloaded && known_troublemaker) {
// logger.println("** AutoPkg downloaded, but not imported to Munki as " + $JOB_NAME + " is a known troublemaker.")
logger.println("=== e-mail cancelled: KNOWN TROUBLEMAKER: AutoPkg downloaded sucessufully (but no import as this version was already in the munki repo")
cancel=true
} else {
// Send the email, something's run amok
cancel=false
logger.println('@#$%&!@#$%&!@#$%&!@#$%&! Ruh Roh! Something went wrong -- E-mail Sent !!!!! @#$%&!@#$%&!@#$%&!@#$%&!')
}
// logger.println("** End of Presend Script and it is " + IS_TROUBLEMAKER + " that " + JOB_NAME + " is a known troublemaker.")
// logger.println("** cancel = " + cancel)
// logger.println("** \n\nlogfile begin ..........\n" + log + "\n\n..........\nlog file end")