I’m about ready to throw in the towel regarding remote job triggers.  It is 
definitely a *LOT* too hard.

I’m trying to start an Ansible construction job on a Jenkins-2 cluster from a 
Jenkins-1 cluster, as a workaround for a massive number of items not working in 
Jenkins-1.

My prototyping appears to show that

1.       I need to know the login credentials and Jenkins user key for the 
person who pushed the button.  These do not appear to be exposed as variables 
to the job on Jenkins-1.  For my prototyping, I’m just hardcoding my own 
credentials, but moving forward I will need some way of obtaining these in a 
shell script for production use.

2.       The obvious API way of doing this job start refuses to work, I believe 
ever since the XSRF additions were added.

3.       You need an XSRF cookie to do this remote job start, for unclear 
reasons.  Both of my Jenkins sites are exposed through an nginx redirect from 
port 80, which may have something to do with this.  Is this an unresolved bug?

4.       The XSRF cookie is not accepted, for unclear reasons.  The log is 
totally useless to figure out why.

There must be an undocumented trick, so what is it?  Has anyone got remote job 
initiation actually working?


CRUMB=$(curl -s 
http://$OWNER:$OWNERKEY@$JENKINS2/crumbIssuer/api/xml?$JENKINS2/crumbRequestField,":",//crumb)

curl -o $RUNLOG \
  -X POST \
  -H "Jenkins-Crumb: $CRUMB" \
  $JENKINS2/job/$FOLDER/$JOB/buildWithParameters?token=$JOBTOKEN \
  --user $OWNER:$OWNERKEY \
  --data-urlencode json='{"parameter": [{"name":"OS_TEMPLATE", 
"value":"{OS_TEMPLATE}"},
                                        {"name":"VM_HOST",     
"value":"{VM_HOST}"    },
                                        {"name":"VM_MEMORY",   
"value":"{VM_MEMORY}"  },
                                        {"name":"VM_CPU",      
"value":"{VM_CPU}"     },
                                        {"name":"VM_DISK",     
"value":"{VM_DISK}"    },
                                        {"name":"STATIC_IP",   
"value":"{STATIC_IP}"  }]}'
cat $RUNLOG    # (obfuscation added as xxx):


  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  1564  100   354  100  1210  50348   168k --:--:-- --:--:-- --:--:--  196k
+ cat /tmp/run.log
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Problem accessing /job/xxx/xxx/buildWithParameters. Reason:
<pre>    Not Found</pre></p><hr><a href="http://eclipse.org/jetty";>Powered by 
Jetty:// 9.4.z-SNAPSHOT</a><hr/>

</body>
</html>
+ grep -q 'HTTP ERROR 403' /tmp/run.log
Build step 'Execute shell' marked build as failure
Finished: FAILURE

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/b57477b973114bb7947a873cafa910ec%40mbx02cmb01p.esentire.local.
For more options, visit https://groups.google.com/d/optout.
  • [no subject] John Mellor
    • Re: James Nord

Reply via email to