Well JENKINS_HOME will not be guaranteed to be set when running on a build slave... so really not robust.
In any case, IMHO, it is a bad plan if the build runs differently when run on the CI server versus when run on a developer's machine... you run the risk of returning to the bad ways of "well it builds on my machine" only now it becomes "well it builds on *all* the developers machines so the CI server *must* be broken"! One thing you could do is have some sort of one-way hash function and store a secret at a specific file system location on all your build slaves... then check if the hash of that file matches and if it does... you're on a Jenkins machine... That won't help if developers can login to build slaves directly though On 18 June 2014 09:59, William Damage <[email protected]> wrote: > Our devs use the same build.gradle script in Android Studio as Jenkins - > but we'd like to know if the build was created locally or from CI. > I guess I can test if $JENKINS_HOME is set as an env var but this doesn't > seem too robust; an enterprising dev might even set Jenkins up locally or > whatever. > > Is there anything I can test to guarantee the build is being run under > Jenkins please? > > -- > 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 [email protected]. > 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
