Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass environment variables to Ant build.xml from Jenkins?

I am using Jenkins as CI. I have an build.xml. Build.xml has code like below.

<property name="environment" value="$environment}" />

How can i pass value to build.xml from Jenkins ? Can i pass it through environment variables?

like image 627
user755806 Avatar asked Dec 07 '22 01:12

user755806


1 Answers

Your environment variables are available via the environment property. In the example below, the environment variable VIEW is printed from the simple hello world ant script via ${env.VIEW}. Change VIEW to the name of the environment variable of interest.

<?xml version="1.0" encoding="UTF-8"?>
<project name="Hello World" default="Hello" basedir=".">
    <property environment="env"/>
    <property name="HelloText" value="Hello"/>
    <target name="Hello">
        <echo>VIEW=${env.VIEW}</echo>
    </target>
</project> 

IMPORTANT! Note that this line is needed in order for env.VIEW to be understood by ant:

<property environment="env"/>
like image 145
Straff Avatar answered Dec 30 '22 15:12

Straff