- Platform information:
- Hardware: virtual Machine on ESX Server
- OS: Suse Linux Enterprise Server 15
- Java Runtime Environment: zulu8.33.0.1-jdk8.0.192
- openHAB version: 2.4.0
I want to read in status of a Jenkins integration server. My rule works, but always gives this validation warnings - and I don’t get where am I doing something wrong, especially since line numbers in the message are missing.
[INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'jenkins.rules', using it anyway:
Assignment to final variable
Assignment to final variable
Constant condition is always false.
Constant condition is always false.
Assignment to final variable
Full example:
rules/jenkins.rules
rule "Update Jenkins Status"
when
Item Debug_Trigger_Jenkins_Update changed to ON or
Item Jenkins_json changed
then
var jenkinsJobsCountSuccessful = 0
var jenkinsJobsCountFailed = 0
var jenkinsJobsCount = 0
logInfo("jenkins.rules", "Update Jenkins Status rule triggered")
jenkinsJobsCount = Integer.parseInt(transform("JSONPATH", "$.jobs.length()", Jenkins_json.state.toString))
//logInfo("jenkins.rules", "found " + jenkinsJobsCount + " jobs")
val currentJob = 0
val currentJobResult_string = ""
val currentJobResult_integer = 0
try {
while (currentJob < jenkinsJobsCount) {
currentJobResult_string = transform("JSONPATH", "$.jobs[" + currentJob + "].color", Jenkins_json.state.toString)
currentJobResult_integer = transform("MAP", "jenkins.map", currentJobResult_string)
//logInfo("jenkins.rules", "Job " + currentJob + " result: " + currentJobResult_string + " => " + currentJobResult_integer)
// map transforms to strings, so compare with strings
if(currentJobResult_integer == "1") {
jenkinsJobsCountSuccessful += 1
}
if(currentJobResult_integer == "0") {
jenkinsJobsCountFailed += 1
}
currentJob += 1
}
}
catch(Throwable t) {
logError("jenkins.rules", "Some bad stuff happened in my rule: " + T.toString)
}
finally {
Jenkins_Successful_Percent.postUpdate(jenkinsJobsCountSuccessful * 100.0 / (jenkinsJobsCountSuccessful + jenkinsJobsCountFailed))
Jenkins_Job_Count.postUpdate(jenkinsJobsCount)
Jenkins_Job_Failed.postUpdate(jenkinsJobsCountFailed)
Jenkins_Job_Successful.postUpdate(jenkinsJobsCountSuccessful)
logInfo("jenkins.rules", "found " + jenkinsJobsCount + " jobs, " + jenkinsJobsCountSuccessful + " of them successful (" + Jenkins_Successful_Percent.state.toString + ")")
}
if(Debug_Trigger_Jenkins_Update.state == ON) { Debug_Trigger_Jenkins_Update.sendCommand(OFF) }
end
services/http.cfg
jenkinsCache.url=https://amplab.cs.berkeley.edu/jenkins/api/json
jenkinsCache.updateInterval=60000
items/jenkins.items
Switch Debug_Trigger_Jenkins_Update
String Jenkins_json "Raw JSON Value of Jenkins result" { http="<[jenkinsCache:60000:REGEX((.*))]" }
Number Jenkins_Job_Count "Jenkins Job Count [%s]"
Number Jenkins_Job_Successful "Jenkins Job Successful [%s]"
Number Jenkins_Job_Failed "Jenkins Job Failed [%s]"
Number:Dimensionless Jenkins_Successful_Percent "Jenkins Successful Jobs [%.2f %%]"
transform/jenkins.map
aborted=-1
aborted_anime=-1
blue=1
blue_anime=1
disabled=-1
disabled_anime=-1
grey=-1
grey_anime=-1
notbuilt=-1
notbuilt_anime=-1
red=0
red_anime=0
yellow=0
yellow_anime=0
OpenHAB Addons: binding http1; transform regex, map