[GRADLE-1652] Environment not working Created: 01/Jul/11  Updated: 04/Jan/13  Resolved: 09/Nov/11

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-milestone-3
Fix Version/s: None

Type: Bug
Reporter: Donald Kwakkel Assignee: Unassigned
Resolution: Not A Bug Votes: 0


I tried setting environment for an exec task, but it seems not to work:

task test {

{ commandLine = ['echo', '\$TEST'] environment 'TEST': 'OK' }




gradle --version

Gradle 1.0-milestone-3

Gradle build time: Monday, 25 April 2011 5:40:11 PM EST
Groovy: 1.7.10
Ant: Apache Ant(TM) version 1.8.2 compiled on December 20 2010
Ivy: 2.2.0
JVM: 1.6.0_24 (Sun Microsystems Inc. 19.1-b02)
OS: Linux 2.6.38-8-generic amd64

Kind Regards, Donald

Comment by Adam Murdoch [ 03/Jul/11 ]

The exec action does not execute a shell, so environment variable substitution is not going to work. You'll need to do something like this, instead:


{ commandLine 'bash', '-c', 'echo', '$TEST' environment ... }
Generated at Wed Jun 30 12:01:00 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.