Finding who triggered a pipeline
CompletedI've been hacking around trying to find who triggered a pipeline from within a Go job. Looking through the feeds API I mananged to find some value, either "changes" or the username of some person who manually triggered the pipeline.
Here is a ruby script that shows how to get either the username (if manually triggered) or the authors of changesets in materials: https://gist.github.com/1731305.
If you don't care about who made the changes you can use this ruby script: https://gist.github.com/1753163.
The second approach is based on feedback from the Go dev team. Still using the API, you use this URL:
url = "#{ENV['GO_SERVER_URL']}pipelines/#{ENV['GO_PIPELINE_NAME']}/#{ENV['GO_PIPELINE_COUNTER']}/#{ENV['GO_STAGE_NAME']}/#{ENV['GO_STAGE_COUNTER']}.xml"
Then, use XPath to lookup //approvedBy/text().
Ultimately, it will be cleaner to have an environment variable on the Go job with the value of the "approveBy" XML element. This has already been logged as a feature request, but I wanted to share the undocumented API and a programmatic way to use it.
Please sign in to leave a comment.
Comments
0 comments