Basically, many plugins contribute tokens. I think these come from the 
Environment inject plugin:

Build Causes
This plugin also exposes the cause of the current build as an environment 
variable. A build can be triggered by multiple causes at the same time e.g. an 
SCM Change could have occurred at the same time as a user triggers the build 
manually.
The build cause is exposed as a coma separated list:
BUILD_CAUSE=USERIDCAUSE, SCMTRIGGER, UPSTREAMTRIGGER
In addition, each cause is exposed as a single envvariable too:
BUILD_CAUSE_USERIDCAUSE=true
BUILD_CAUSE_SCMTRIGGER=true
BUILD_CAUSE_UPSTREAMTRIGGER=true

It looks like you can get the user id

From: jenkinsci-users@googlegroups.com 
[mailto:jenkinsci-users@googlegroups.com] On Behalf Of Sverre Moe
Sent: Thursday, February 19, 2015 6:54 AM
To: jenkinsci-users@googlegroups.com
Subject: Re: Groovy build script: What triggered the build

Excellent. I could not find any documentation about this variable. It is not 
listed among the environment variables of Jenkins. Makes me wonder which other 
variables are available that could be usefull.

When I trigger the build manually in Jenkins I got BUILD_CASE = UPSTREAMTRIGGER
When triggered by SCM change BUILD_CAUSE = SCMTRIGGER.
When triggered by an downstream project UPSTREAMTRIGGER (a library triggered a 
build on the app that uses it.

So it looks like the BUILD_CAUSE is the same for both manually trigger and 
triggered by an upstream/downstream project.
However I think I could work this that since I would have the same build 
procedure for both manual and automatic UPSTREAMTRIGGER build.
Still would be nice to also have BUILD_CAUSE_BY, user or project.

Where do I find a complete list of variables I could use?

tirsdag 17. februar 2015 14.21.59 UTC+1 skrev rginga følgende:
There is a BUILD_CAUSE environment variable that can have values like: 
SCMTRIGGER, MANUALTRIGGER, and others

From: jenkins...@googlegroups.com<javascript:> 
[mailto:jenkins...@googlegroups.com<javascript:>] On Behalf Of Sverre Moe
Sent: Monday, February 16, 2015 7:06 AM
To: jenkins...@googlegroups.com<javascript:>
Subject: Groovy build script: What triggered the build

Is it possible to find out who or what triggered the build from a Groovy 
script? Either an SCM change, another project or user. I have just begun 
reading a little about Groovy and the Jenkins API.

I want to check for the following conditions and build accordingly.

if (trigger == scm) {
  build_with_automake
  new_version = git tag exist for version
  if (new_version) {
    tag new release candidate in Git
    publish rc
  }
}
else if (trigger == "Build other projects") {
  build_with_automake
}

The project should build on every SCM change, but only tag and publish if 
version has been increased. It should also build when a build has been 
triggered by another project.
--
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-use...@googlegroups.com<javascript:>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/a4a10f09-9846-4c6e-b572-ed5123f0977d%40googlegroups.com<https://groups.google.com/d/msgid/jenkinsci-users/a4a10f09-9846-4c6e-b572-ed5123f0977d%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
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<mailto:jenkinsci-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/ef08a7f4-380f-40da-bcc3-649188688ee1%40googlegroups.com<https://groups.google.com/d/msgid/jenkinsci-users/ef08a7f4-380f-40da-bcc3-649188688ee1%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

-- 
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/6C6EE445A6F6CE4E8A0FFB51B071A4E26E4FC8A6%40AMERMBX02.PERKINELMER.NET.
For more options, visit https://groups.google.com/d/optout.

Reply via email to