Fetching the current application environment

Is it possible to get the name, or some other data, that identifies the current environment of a BPM application?

In our app. we have a daily UCA that queries some data and does something with it. In an event of error it sends an email to the dev team. This happens in all our environments (dev, test, stage and production) and the same team receives the same email. What we want, is a way to identify from "where" did the email come from. Some way to see that this job failed, for example, on the test machine, so we can put TEST in the subject/body of the email.

One solution is to have a env. variable (say, ENVIRONMENT, with DEV, TEST, STAGE, PROD as its values) and to use that, but it seems kind of redundant.

Another suggestion is to use the host name (fetched via Packages.java.net.InetAddress.getLocalHost().getHostName();) to see the name of the server it originated from, but this isn't the real information we want.

The class contains methods such as getFullName() and getDisplayName() which should deliver what you are looking for.
Since BPM extends WebSphere Application Server, the API should work there as well, assuming that your application can access the package in question. I have not tested it yet but I know that it works in WebSphere Process Server, BPM's predecessor product.

One solution is to have a env.
variable (say, ENVIRONMENT, with DEV,
TEST, STAGE, PROD as its values) and
to use that, but it seems kind of
redundant.

It is the best solution because others ways using DB or JS would have some performance degradation.
I have tried to get some parameters from Teamworks configuration files. The simple query (like yours) takes me about 1-2 seconds on Process Center. It is very mush beside using ENV.

But first - the code what realise this part is different between 8 and 8.5.6 for example. You will get not universal solution. Second one, Teamworks configuration consists of about 12000 strings of different parameters. You have to extract the name of your environment from them. Is it rational? I think, no.