Hi Vincent,
Thanks for the reply!
Unfortunately hpi:run doesn't work well for me, just gives me weird Java
errors. Probably something with the network messed up, too much effort to
fix it anyways.
The weird thing is that buildEnvironmentFor() is never even executed, so
changing it to a log would not work...
I'll give the clean command a try tomorrow, see if it works. If not then
I'll have to give up on this...
Do you perhaps know when exactly this function is supposed to be called? Is
it called when a job is built, or when job configs is saved, or when the
global configs are saved? That might help me track it down :)
Thanks!
Thomas
Op dinsdag 21 augustus 2012 15:57:12 UTC+1 schreef ThomasBrouwer het
volgende:
>
> Hi there!
>
> I just cannot seem to be able to add environmental variables in my plugin.
> I made a separate class extending EnvironmentContributor:
>
> package hudson.plugins.throttleconcurrents;
>
> import hudson.EnvVars;
> import hudson.Extension;
> import hudson.model.EnvironmentContributor;
> import hudson.model.TaskListener;
> import hudson.model.Run;
>
> import java.io.IOException;
>
> @Extension
> public class ThrottleAddEnvVar extends EnvironmentContributor {
> // This class is for adding the environmental variable containing the
> assigned labels
> @Override
> public void buildEnvironmentFor(Run r, EnvVars envs, TaskListener
> listener) throws IOException, InterruptedException {
> ThrottleQueueTaskDispatcher.writeMessage("Running buildEnvironmentFor()!");
> //Put together category-labels string
> String labelEnvVar = "category1|label1<>category2|label2"; // String
> storing the LABELS environmental variable. Form is:
> category1|label1<>category2|label2<>...
> envs.put("LABELS", labelEnvVar);
> }
> }
>
> but this does not do anything at all. In fact,
> the ThrottleQueueTaskDispatcher.writeMessage() call is never made so
> buildEnvironmentFor() is simply never executed. When is this function
> supposed to be called?
> I've been noticing more often that having a class have @Extension does not
> mean it is picked up. What else, besides what is above, would be necessary?
> This generalizes to other extension points such as Builders and such.
>
> Help will be greatly appreciated!
> Thomas
>