Re: Is there a way to read a string (version numbers) from a file into jenkins variable?

2012-04-05 Thread Pan Luo
Thanks Jan. The Envfile plugin doesn't work for me as it requires the
java property format. My version file is just 3 digits in the plain
text file.

I could go with the second option. I need the version number in
post-build action, where I'm sending the files to a remote server
using scp. I need the version number included in the remote path. Is
there a way I can run any script in post-build actions?

By build steps, you mean pre-build, build, post-build? So if I set any
environment variables using Ant (or Phing) in build step, it will not
exist in post-build actions? Thanks.

Cheers,
Pan



On Thu, Apr 5, 2012 at 1:10 AM, Jan Seidel wakkal...@gmail.com wrote:
 Hi,

 you could try the Jenkins Environment File Plugin
 https://wiki.jenkins-ci.org/display/JENKINS/Envfile+Plugin

 Else you would have to run some string manipulation to get the value
 into a file and execute it at each build step like you would assign an
 environment variable.
 In DOS it would be a content like: SET var_name=var_value.
 You have to execute it at each build step which needs the value as the
 variable is destroyed when the build step is done.

 Take care
 Jan

 On 5 Apr., 09:04, Pan Luo luopa...@gmail.com wrote:
 I have my version number stored in a file. I would like my jenkins job to
 read the version from that file and store it in a variable so that I can
 used it some publish task. Is there a way to do it? Thanks.


Re: Is there a way to read a string (version numbers) from a file into jenkins variable?

2012-04-05 Thread shanz
You could create another file with the version number in the java
property (key=value) format.
Then you can use the EnvInject plugin to inject the environment
variable (MY_NEW_VAR) into your job/build.
The advantage of this approach is that the variable can be visible
throughout the whole job/build.
You just enter the path/myVersion.txt in the Properties File field of
the plugin.

Alternatively just use DOS, eg: To place the first line of a file into
a variable, do this
Set /P MyVar=aFilename
The downside to this later approach is that you may have to repeat it
if you open several shells.