Skip to contentSkip to conversation

Allow ftc script to properly use Jenkins configured port

PATCH In review Guilherme Campos Camargo 2 participants 3 messages Feb 7, 2018 – Feb 8, 2018

lore
Share & tools
lore
#0 lore raw

cover Allow ftc script to properly use Jenkins configured port

Please see the commit messages for more details.

Guilherme Campos Camargo (1):
Allow ftc script to properly use Jenkins configured port

 engine/scripts/ftc | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
Signature · 1 line
2.16.1
#1 lore raw

PATCH 1/1 Allow ftc script to properly use Jenkins configured port

With the possibility of configuring jenkins porth through fuego/ro/conf/fuego.conf, a change on ftc script is needed so that it uses the configured port and not the default one (8080).

This patch solves that issue by using the ${jenkins_port} environment variable (set on entrypoint.sh) instead of the hardcoded 8080.

---
 engine/scripts/ftc | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
engine/scripts/ftc +8 -5
index bde3694..af5a2a7 100755
@@ -63,6 +63,8 @@ VERSION = (1,2,1)
 # define these as globals
 log = None
 tail_fd = None
+jenkins_port = os.getenv('jenkins_port', 8080)
+fuego_url = 'http://localhost:' + str(jenkins_port) + '/fuego'
 
 # here's a utility routine to print a variable with it's name and value
 def pvar(name):
@@ -72,7 +74,8 @@ def pvar(name):
 quiet = 0
 verbose = 0
 use_statusouput = 1
-server = jenkins.Jenkins('http://localhost:8080/fuego')
+server = jenkins.Jenkins(fuego_url)
+
 
 # keep configuration file in /fuego-ro/conf area
 config_dir = "/fuego-ro"
@@ -413,7 +416,7 @@ class config_class:
 
         # fuegotest.com is at: 52.88.166.49
         self.SERVER_URL_BASE = "http://52.88.166.49/server/Fuego_Server?action=Fuego."
-        self.JENKINS_URL = "http://localhost:8080/fuego"
+        self.JENKINS_URL = fuego_url
 
         # end of default configs
 
@@ -1159,7 +1162,7 @@ timeout --signal=9 {timeout} /bin/bash $FUEGO_CORE/engine/scripts/main.sh
     job_name=board+"."+test.spec+"."+test.name
     print("Creating job " + job_name)
     try:
-        subprocess.call('java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -s http://localhost:8080/fuego create-job ' +
+        subprocess.call('java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -s' + fuego_url + 'create-job ' +
             job_name + ' < ' + tmp, shell=True)
         os.unlink(tmp)
     except Exception as e:
@@ -1207,7 +1210,7 @@ def create_batch_job(board, testplan, plan_tests):
     print("Creating batch job ")
     try:
         job_name = board+'.'+testplan+'.batch'
-        subprocess.call('java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -s http://localhost:8080/fuego create-job ' +
+        subprocess.call('java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -s' + fuego_url + 'create-job ' +
              job_name + '< ' + tmp, shell=True)
         os.unlink(tmp)
     except Exception as e:
@@ -3581,7 +3584,7 @@ def user_check():
 
     new_user = "jenkins"
     if getpass.getuser() == "root":
-        cmd = ["sudo", "-u", new_user, "python"] + sys.argv
+        cmd = ["sudo", "-u", new_user, "-E", "python"] + sys.argv
         rcode = subprocess.call(cmd)
         sys.exit(rcode)
 
Signature · 1 line
2.16.1
#2 lore raw
Quoted 9 lines

-----Original Message-----
From: Guilherme Campos Camargo

With the possibility of configuring jenkins porth through fuego/ro/conf/fuego.conf, a change on ftc script is needed so that it uses the configured port and not the default one (8080).

This patch solves that issue by using the ${jenkins_port} environment variable (set on entrypoint.sh) instead of the hardcoded 8080.

Thanks. This was on my list of things to do. I made an attempt to add this support to ftc, but came up with something much more complicated, because I tried to do too much other stuff at the same time.

Comments inline below.

Quoted 10 lines
---
 engine/scripts/ftc | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
engine/scripts/ftc +0 -0
index bde3694..af5a2a7 100755

engine/scripts/ftc VERSION = (1,2,1) · line 66

Quoted 4 lines
engine/scripts/ftc +1 -0
@@ -63,6 +63,8 @@ VERSION = (1,2,1)
 # define these as globals
 log = None
 tail_fd = None
+jenkins_port = os.getenv('jenkins_port', 8080)

The environment variable 'jenkins_port' is not defined in anything but the main container shell.

ftc can be run from outside the container, and it calls itself inside the container such that jenkins_port is not defined.

Also:

 $ sudo docker exec -I -t fuego-container bash
starts a new shell, where ftc can be run, but jenkins_port is
not defined (I believe).

It would be better to read the port value from the configuration file, in /fuego_ro/conf/fuego.conf.

Quoted 57 lines
engine/scripts/ftc +3 -1
+fuego_url = 'http://localhost:' + str(jenkins_port) + '/fuego'
 
 # here's a utility routine to print a variable with it's name and value
 def pvar(name):
@@ -72,7 +74,8 @@ def pvar(name):
 quiet = 0
 verbose = 0
 use_statusouput = 1
-server = jenkins.Jenkins('http://localhost:8080/fuego')
+server = jenkins.Jenkins(fuego_url)
+
 
 # keep configuration file in /fuego-ro/conf area
 config_dir = "/fuego-ro"
@@ -413,7 +416,7 @@ class config_class:
 
         # fuegotest.com is at: 52.88.166.49
         self.SERVER_URL_BASE =

"http://52.88.166.49/server/Fuego_Server?action=Fuego."

engine/scripts/ftc +1 -1
-        self.JENKINS_URL = "http://localhost:8080/fuego"
+        self.JENKINS_URL = fuego_url
 
         # end of default configs
@@ -1159,7 +1162,7 @@ timeout --signal=9 {timeout} /bin/bash

$FUEGO_CORE/engine/scripts/main.sh
job_name=board+"."+test.spec+"."+test.name print("Creating job " + job_name)
try:
- subprocess.call('java -jar /var/cache/jenkins/war/WEB-INF/jenkins-
cli.jar -s http://localhost:8080/fuego create-job ' +
+ subprocess.call('java -jar /var/cache/jenkins/war/WEB-INF/jenkins-
cli.jar -s' + fuego_url + 'create-job ' +
job_name + ' < ' + tmp, shell=True)
os.unlink(tmp)
except Exception as e:

engine/scripts/ftc +0 -1
@@ -1207,7 +1210,7 @@ def create_batch_job(board, testplan, plan_tests):
     print("Creating batch job ")
     try:
         job_name = board+'.'+testplan+'.batch'
-        subprocess.call('java -jar /var/cache/jenkins/war/WEB-INF/jenkins-

cli.jar -s http://localhost:8080/fuego create-job ' +
+ subprocess.call('java -jar /var/cache/jenkins/war/WEB-INF/jenkins-
cli.jar -s' + fuego_url + 'create-job ' +
job_name + '< ' + tmp, shell=True)
os.unlink(tmp)
except Exception as e:

engine/scripts/ftc +1 -2
@@ -3581,7 +3584,7 @@ def user_check():
 
     new_user = "jenkins"
     if getpass.getuser() == "root":
-        cmd = ["sudo", "-u", new_user, "python"] + sys.argv
+        cmd = ["sudo", "-u", new_user, "-E", "python"] + sys.argv
         rcode = subprocess.call(cmd)
         sys.exit(rcode)
 
--
Quoted 1 line

2.16.1

Other than that - looks good. Can you please make the requested change?
-- Tim