title: How to override the environment variables for Jenkins slave when adding new slave
body: <p>Configured automatic slaves for couple jobs on Jenkins using <a href="https://wiki.jenkins-ci.org/display/JENKINS/Amazon+EC2+Plugin" rel="nofollow">ec2 plugin</a>. I need to override couple of environment variables for the slave before connecting to master. Here is the init script that used to run before it connect as slave. What am I doing wrong. Can someone please help me?</p>
  
  <p>PROBLEM:
  I'm able to launch a slave,But unable to set environment variables for that slave.</p>
  
  <p>GOAL:
  Install maven-3.2.5 (set home directory to /opt/apache-maven-3.2.5),
  Environment variables: (name: DISPLAY, value: :1),
                         (name: PATH, value: $PATH:/usr/local/bin)</p>
  
  <pre><code>#!/bin/sh
  
  sudo mkdir /opt/apache-maven-3.2.5
  if [ -d /opt/apache-maven-3.2.5 ]; then
      if [ ! -f /tmp/apache-maven-3.2.5-bin.tar.gz ]; then
          wget -nd -O /tmp/apache-maven-3.2.5-bin.tar.gz https://archive.apache.org/dist/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz
      fi
      tar -xvf /tmp/apache-maven-3.2.5-bin.tar.gz
      sudo mv apache-maven-3.2.5 /opt/
      sudo chown -R jenkins:jenkins /opt/apache-maven-3.2.5
  fi
  PATH=$PATH:/usr/local/bin
  DISPLAY=:1
  MAVEN_HOME=/opt/apache-maven-3.2.5
  </code></pre>
  
  <p>Jenkins version:1.656
  Amazon EC2 plugin:1.31</p>