I have an environment variable named TRIGGER_JOB in Jenkins that tells me what job triggered that build.
Since I'm using groovy to start a new job, I rely on /buildWithParameters like this...
https://jenkins/job/job_name/buildWithParameters?TRIGGER_JOB=test
But the environment variable doesn't get set. I know a workaround is to introduce a dummy parameter and then use Environment injection plugin to set TRIGGER_JOB but I'm curious if there is another more straightforward solution.
I did not find a good solution but two of the "workarounds" seem sufficient.
Introduce a dummy parameter and then use Environment injection plugin
If you just want this parameter to show up in the build description (like I did) you might as well do a httpPost request JOB_URL/submitDescription
with the parameter description
set to whatever you want (in my case the TRIGGER_URL)