Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

setValue is behaving weird #4105

ari ·

i have a script that updates a step variables it works fine but a line after this it returs the default value

here is my script "

groovy:

for (agent in system.agentManager.buildAgents) {
logger.info("******************************************************")

def agent_ip = agent.ip
def agent_hostname= agent.hostName

def evalContext = ["host_ip":agent.ip,
"host_hostname":agent.hostName,
"pdu_ip":agent.userAttributes.get("pdu_ip"),
"pdu_port":agent.userAttributes.get("pdu_port") ,
"number_of_pf":"2" ,
"gpio_ip":agent.userAttributes.get("gpio_board_ip"),
"gpio_port":agent.userAttributes.get("gpio_port")]
logger.info("***************Vars Before")

logger.info("agent_ip = {}", vars.getValue("hostname_ip"))
logger.info("agent_hostname = {}",vars.getValue("hostname"))
logger.info("gpio_ip = {} ", vars.getValue("gpio_board_ip"));
logger.info("gpio_port = {} ", vars.getValue("gpio_port"));
logger.info("pdu_ip = {} ", vars.getValue("pdu_ip"));
logger.info("pdu_port = {} ", vars.getValue("pdu_port"));
logger.info("**********************************************************************************")
//vars.get("hostname_ip").setValue(agent.ip)
vars.get("hostname").setValue(agent.hostName)
vars.get("gpio_ip").setValue(agent.userAttributes.get("gpio_board_ip"));
vars.get("gpio_port").setValue(agent.userAttributes.get("gpio_port"));
vars.get("pdu_ip").setValue(agent.userAttributes.get("pdu_ip"));
vars.get("pdu_port").setValue(agent.userAttributes.get("pdu_port"), false);

//["host_ip":agent.ip,"host_hostname":agent.hostName,"pdu_ip":agent.userAttributes.get("pdu_ip"),"pdu_port":agent.userAttributes.get("pdu_port") ,"number_of_pf":"2" , "gpio_ip":agent.userAttributes.get("gpio_board_ip"),"gpio_port":agent.userAttributes.get("gpio_port")]

logger.info("agent_ip = {}", vars.getValue("hostname_ip"))
logger.info("agent_hostname = {}",vars.getValue("hostname"))
logger.info("gpio_ip = {} ", agent.userAttributes.get("gpio_board_ip"));
logger.info("gpio_port = {} ", agent.userAttributes.get("gpio_port"));
logger.info("pdu_ip = {} ", agent.userAttributes.get("pdu_ip"));
logger.info("pdu_port = {} ", agent.userAttributes.get("pdu_port"));

logger.info("******************Vars After")

logger.info("agent_ip = {}", vars.getValue("hostname_ip"))
logger.info("agent_hostname = {}",vars.getValue("hostname"))
logger.info("gpio_ip = {} ", vars.getValue("gpio_board_ip"));
logger.info("gpio_port = {} ", vars.getValue("gpio_port"));
logger.info("pdu_ip = {} ", vars.getValue("pdu_ip"));
logger.info("pdu_port = {} ", vars.getValue("pdu_port"));
logger.info("**********************************************************************************")

//def scriptRunOnAgent = "python /home/svjer/my_tests/Scripts/automation/ssh.py ${vars.getValue("pdu_ip")} ${vars.getValue("pdu_port")} 2 ${vars.getValue("gpio_ip")} ${vars.getValue("gpio_port")}"

//return python /home/svjer/my_tests/Scripts/automation/ssh.py ${vars.getValue("pdu_ip")} ${vars.getValue("pdu_port")} 2 ${vars.getValue("gpio_ip")} ${vars.getValue("gpio_port")}".execute()

//return "python /home/svjer/my_tests/Scripts/automation/ssh.py".execute().text

//def output = node.nodeService.evalGroovyScript(scriptRunOnAgent, evalContext);
//logger.info(output)

logger.warn("python /home/svjer/my_tests/Scripts/automation/ssh.py " + evalContext['host_ip'] +" "+ evalContext["host_hostname"] +" pdu_ip ${vars.getValue("pdu_ip")} pdu_port ${vars.getValue("pdu_port")} 2 gpio_ip ${vars.getValue("gpio_ip")} ${vars.getValue("gpio_port")}")
def command = "python /home/svjer/my_tests/Scripts/automation/ssh.py ${vars.getValue("hostname_ip")} ${vars.getValue("hostname")} ${vars.getValue("pdu_ip")} ${vars.getValue("pdu_port")} 2 ${vars.getValue("gpio_ip")} ${vars.getValue("gpio_port")}"
logger.warn(command)

and the output

20:58:13,987 INFO - ******************************************************
20:58:13,987 INFO - ***************Vars Before
20:58:13,987 INFO - agent_ip = null
20:58:13,987 INFO - agent_hostname = Platform2
20:58:13,987 INFO - gpio_ip = null
20:58:13,987 INFO - gpio_port = 4
20:58:13,987 INFO - pdu_ip = 10.12.235.3
20:58:13,987 INFO - pdu_port = 2
20:58:13,987 INFO - **********************************************************************************
20:58:14,013 INFO - agent_ip = null
20:58:14,013 INFO - agent_hostname = Platform1
20:58:14,014 INFO - gpio_ip = 10.12.249.49
20:58:14,014 INFO - gpio_port = 1
20:58:14,014 INFO - pdu_ip = 10.12.235.3
20:58:14,014 INFO - pdu_port = 1
20:58:14,014 INFO - ******************Vars After
20:58:14,014 INFO - agent_ip = null
20:58:14,014 INFO - agent_hostname = Platform1
20:58:14,014 INFO - gpio_ip = null
20:58:14,014 INFO - gpio_port = 1
20:58:14,014 INFO - pdu_ip = 10.12.235.3
20:58:14,014 INFO - pdu_port = 1
20:58:14,015 INFO - **********************************************************************************
20:58:14,015 WARN - python /home/svjer/my_tests/Scripts/automation/ssh.py 10.12.234.212 Platform1 pdu_ip 10.12.235.3 pdu_port 2 2 gpio_ip 10.12.249.49 4
20:58:14,015 WARN - python /home/svjer/my_tests/Scripts/automation/ssh.py Platform2 10.12.235.3 2 2 10.12.249.49 4

as you can see the var pdu_ip has been change and after get the ld value

what do i do wrong

thanks

  • replies 1
  • views 310
  • stars 0
robinshen ADMIN ·

What is wrong here? I see from the log value of this variable is always "10.12.235.3", which is the same as value the user attribute "pdu_ip" and is expected.