[Fuego] Eliminating the usage of jenkins-cli.jar in ftc script
Srivatsan S <[email protected]> Wed, 18 Nov 2020 12:35:13 +0530
| Newsgroups | dev.linux.lists.fuego |
|---|---|
| Message-ID | <CAMAk937he50nOrzhQf58xQAvgFiuc7GBRyO1Ka=m1oBEMor_bg@mail.gmail.com> |
Tim,
While we were looking at eliminating the usage of jenkins-cli.jar in the
ftc script, we came across create_job() API in the Jenkins Python module
which can be used to create jobs in Jenkins, thus eliminating the usage of
jenkins-cli.jar in the ftc script.
The below patch works for job creation in Jenkins through ftc script. We
shall get back to you on ways to programmatically update other job
properties.
git diff ftc
diff --git a/scripts/ftc b/scripts/ftc
index 30195fb..a193c4d 100755
--- a/scripts/ftc
+++ b/scripts/ftc
@@ -1559,9 +1559,7 @@ ftc run-test -b $NODE_NAME -t {testdir} -s {testspec}
\\
job_name = board + "." + test.spec + "." + test.name
print("Creating job " + job_name)
try:
- rcode = subprocess.call('java -jar
/var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -s '+conf.JENKINS_URL+'
create-job ' +
- job_name + ' < ' + tmp, shell=True)
- os.unlink(tmp)
+ rcode = server.create_job(job_name, jenkins.EMPTY_CONFIG_XML)
return rcode
except Exception as e:
print("Job already exists")
@@ -1609,9 +1607,7 @@ def create_batch_job(conf, board, testplan,
plan_tests):
print("Creating batch job ")
try:
job_name = board+'.'+testplan+'.batch'
- rcode = subprocess.call('java -jar
/var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -s '+conf.JENKINS_URL+'
create-job ' +
- job_name + '< ' + tmp, shell=True)
- os.unlink(tmp)
+ rcode = server.create_job(job_name, jenkins.EMPTY_CONFIG_XML)
return rcode
except Exception as e:
print("Job already exists")
Thanks,
Srivatsan
~
--
This
message contains confidential information and is intended only
for the
individual(s) named. If you are not the intended
recipient, you are
notified that disclosing, copying, distributing or taking any
action in
reliance on the contents of this mail and attached file/s is strictly
prohibited. Please notify the
sender immediately and delete this e-mail
from your system. E-mail transmission
cannot be guaranteed to be secured or
error-free as information could be
intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain
viruses. The sender therefore does
not accept liability for any errors or
omissions in the contents of this
message, which arise as a result of e-mail
transmission.