-
New Feature
-
Resolution: Won't Fix
-
Minor
I am able to run this in the "Pipeline" project type.
import groovy.json.JsonSlurperClassic
def TARGET_IP = "104.239.251.41"
def test_dir = "/home/ubuntu/workspace/Athena/modules/delorean/test-api"
def testJobs = [:]
@NonCPS
def slurpJSON(text) {
final slurper = new JsonSlurperClassic()
return slurper.parseText(text)
//return new HashMap<>(slurper.parseText(inputFile)) => not serializable
}
@NonCPS
buildCommand(domain, TARGET_IP, test_dir) {
def sb = new StringBuffer()
return sb.plus('ATHENA_ENV_TARGET_IP=' + TARGET_IP)
.plus(' ATHENA_ENV_TARGET_DOMAIN=' + domain)
.plus(' ATHENA_ENV_TARGET_PROXY=http://athena-plugin-proxy-' + domain)
.plus(' ATHENA_ENV_TARGET_REPORT=report_' + domain)
.plus(' ATHENA_INSTANCE=' + domain)
.plus(' /home/ubuntu/athena/athena php api ' + test_dir)
.plus(' ' + test_dir +'/athena.json')
.plus(' || ( sudo mv ' + test_dir + '/report_' + domain)
.plus('/report.html ' + test_dir + '/report_' + domain + '.html && exit 1)')
}
node('athena'){
def aw = Jenkins.instance.getJob('Athena').lastBuild.workspace;
//def athenaSufix = "/modules/delorean/test-api/athena.json"
//def athenaJson = aw + athenaSufix
echo '\tWorking with domains under =>' + aw
def inputJSON = slurpJSON(readFile('/home/ubuntu/workspace/Athena/modules/delorean/test-api/athena.json'))
//echo '\tList size = ' + inputJSON["proxy"]["remapHosts"].size()
def domains = []
for (param in inputJSON.proxy.remapHosts)
inputJSON = null
echo '\tFinished loading domains'
i = 0
for (domain in domains) {
//println "\t\tDomain = " + domain
def command = buildCommand(domain, TARGET_IP, test_dir)
testJobs["split${i}"] = {
node('athena')
}
i++
}
parallel testJobs
}
The Job DSL Plugin allow me to run all BUT the PARALLEL.