Hi, is there a way to specify who triggered a pipeline instance via the API?
I have a pipeline with the svn material AutoUpdate set to false. I then schedule it via the API, by posting materials[svn]=SOME_REVISION. In the post, I use my username to authenticate (e.g. -u user:password with curl). However, when the pipeline instance is scheduled, it shows "triggered by changes". The API call has the username hard coded, but we would like to reflect from the pipeline who is responsible for triggering the build (the svn commiter)
possible at all?
Comments
2 comments
Hi Brett,
I tried reproducing this issue on 2.1 and it seems to work just fine. Can you please confirm the http status code issued to the curl based API call?
AFAIR curl does not retun non-zero exit status for non 20X http-response status, so unless you are explicitly checking the return code, it may actually swallow the problem silently.
I mean, it may have so happened that, even though the script tried to trigger it, pipeline was probably auto-triggered, and script invocation didn't fail because curl process terminated just fine(inspite of receiving a non 20X response as schedule failed because another instance of first stage was active).
If you have the console dump of API call script, that may lead us in the right direction. Usually the server posts the reason for rejecting schedule request in response-body.
However, this potential problem can be ruled out by making first stage othis pipeline manual.
Regards,
Janmejay
Hi Janmejay,
stage is automatic (as we want upstream pipelines to trigger it). However, the only svn material for the pipeline has autoUpdate set to false - i.e. Go does not poll SVN and therefore will not by triggered by commits.
I am using the output from Go to determine if the scheduling was successful:
SR_SCHED_OK="Request to schedule pipeline $JOB accepted"
SR_SCHED_ERR="Failed to trigger pipeline: $JOB"
RES=`$CURL $CURL_OPTS -u $GO_USER:$GO_PASS -d 'materials[svn_material]=$REVISION' -- $GO_BASE/pipelines/$JOB/schedule`
if [ "x$RES" == "x$SR_SCHED_OK" ]; then
echo "Success"
fi
i.e. the output from Go is "Request to schedule pipeline $MYPIPELINE accepted"
Besides the upstream pipeline (which only triggers less than 1 in 15 of this pipeline), the only trigger to this is the API call. The view in the image is from /go/tab/pipeline/history/PipelineName
If I go into a pipeline instance -> stage -> job, I see the following in the header section: Build cause: triggered by "ABC"
ABC is either hte committer or the upstream pipeline.
Please sign in to leave a comment.