Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Hudson "Parameterized Build" values in an email

We are running a Hudson build server internally on a project. We send out email every time the server deploys new version.

I would like this email to contain more information, including a username and a reason for the build.

From hudsons documentation on Parameterized builds, have added text parameters to the build. I am trying here with two different ones (in order to see what works):

In job configuration This build is parameterized i added the following two variables

Name:          USER 
Default value: userCAPITALIZED

Name:          user
Default value: userstandard

See screenshot of parameterized settings
(source: justaddwater.dk)
.

Now, down in the bottom section "Editable Email Notification" i have tried EVERYTHING to retrieve these values.

What works: All standard Hudson build variables work. Like $CHANGES, $SVN_REVISION, etc.

But I have tried the to access the variables user and USER without any luck. Here is a list of what is not working:

subject: test of parametrized mail 1user:${env.user}, 2USER:${USER}, 3$USER, 4${ENV, USER}, 5%USER%,stop

more tests
${env, user}
${env, USER}
${ENV, user}
${ENV, USER}
${user}
${USER}
${env.user}
${ENV.user}
${env.USER}
${ENV.USER}
$user
$USER
%user%
%USER%

changes $CHANGES
changes ${CHANGES}
subversion revision: $SVN_REVISION
subversion revision: ${SVN_REVISION}

Screenshot of email configuration
(source: justaddwater.dk)

This merely results in an email with this content:

test of parametrized mail 1user:${env.user}, 2USER:${USER}, 3$USER, 4${ENV, USER}, 5%USER%,stop

more tests
${env, user}
${env, USER}
${ENV, user}
${ENV, USER}
${user}
${USER}
${env.user}
${ENV.user}
${env.USER}
${ENV.USER}
$user
$USER
%user%
%USER%

changes
changes
subversion revision: 400
subversion revision: 400

As you can see, only the subversion revision expands correctly. The changes is empty for this particular job, so ignore that.

How do YOU define parameters in email? Any suggestions? I am using Hudson version 1.395

like image 941
Jesper Rønn-Jensen Avatar asked Mar 03 '11 13:03

Jesper Rønn-Jensen


2 Answers

You need to use a parameter like this one: ${ENV, var="USER"}

And 'USER' is the same as 'user' - you need to give then different names.

like image 104
Rene Larsen Avatar answered Sep 26 '22 12:09

Rene Larsen


On top of what Rene suggests (that is, to use ${ENV, var="USER"}) I believe you need to install yet another plugin called 'email-ext'. I found that information in some other question (there's no accepted answer though).

like image 38
Grzegorz Oledzki Avatar answered Sep 25 '22 12:09

Grzegorz Oledzki