I am trying to use jenkins-job-trigger to trigger the scan Multibranch. It does work without the wait, but If I add a wait I get the error below. From my manual debugging it seems the error occurs because the POST request on the build endpoint gets redirected, which looses the location header.
It works fine for jobs inside the multibranch project.
I would like to wait for the scan to complete before I continue my pipeline. I have worked around it using some manual curl commands.
This is my usage of the pipe:
- pipe: atlassian/jenkins-job-trigger:0.10.0
variables:
JENKINS_URL: 'https:<my_jenkins_url>/job'
JENKINS_USER: $jenkins_user
JENKINS_TOKEN: $jenkins_token
JOB_NAME: 'bitbucket_poc_kto'
WAIT_MAX_TIME: '300' # seconds
DEBUG: 'true'
This is the error log
<span>Digest: sha256:9a4c0aa1133e6a3058e2dce29b92a640ba3348f908edd9f22f12549e3325ef8d</span>
<span>Status: Downloaded newer image for bitbucketpipelines/jenkins-job-trigger:0.10.0</span>
<span>DEBUG: Starting new HTTPS connection (1): <a href="http://bitbucket.org:443/" rel="noopener noreferrer" target="_blank">bitbucket.org:443</a></span>
<span>DEBUG: <a href="https://bitbucket.org/" rel="noopener noreferrer" target="_blank">https://bitbucket.org:443</a> "GET /bitbucketpipelines/official-pipes/raw/master/pipes.prod.json HTTP/11" 200 None</span>
<span>INFO: None</span>
<span>INFO: Submitting jenkins job...</span>
<span>DEBUG: Starting new HTTPS connection (1): <a href="https://dev.jenkins.build1.asysdev.com/" rel="noopener nofollow noreferrer" target="_blank"><my jenkins url></a></span>
<span>DEBUG: <a href="https://dev.jenkins.build1.asysdev.com/" rel="noopener nofollow noreferrer" target="_blank">https://</a><a href="https://dev.jenkins.build1.asysdev.com/" rel="noopener nofollow noreferrer" target="_blank"><my jenkins url></a> "POST /job/bitbucket_poc_kto/build HTTP/11" 302 0</span>
<span>DEBUG: <a href="https://dev.jenkins.build1.asysdev.com/" rel="noopener nofollow noreferrer" target="_blank">https://<my jenkins url></a> "GET /job/bitbucket_poc_kto/ HTTP/11" 200 None</span>
<span>Traceback (most recent call last):</span>
<span>File "/pipe.py", line 200, in <module></span>
<span>pipe.run()</span>
<span>File "/pipe.py", line 191, in run</span>
<span>self.wait_for_job(build_response.headers['Location'])</span>
<span>File "/usr/local/lib/python3.10/site-packages/requests/structures.py", line 52, in __getitem__</span>
<span>return self._store[key.lower()][1]</span>
<span>keyError: 'location'</span>