Jenkins has the ability to install tools for you automatically, including
Maven.  If a job needs that tool on a slave which does not have the tool
yet, Jenkins installs the tool and initializes the environment so the tool
can be used.

I've used that technique successfully with various JDK versions, maven
versions, and ant versions.

If you still want to use your technique, then I've asked a few questions
inside the script.

Mark Waite

On Thu, Jun 23, 2016 at 4:14 PM praveen kumar jogi <
jogi.praveenkuma...@gmail.com> wrote:

> Configured automatic slaves for couple jobs on Jenkins using ec2 plugin
> <https://wiki.jenkins-ci.org/display/JENKINS/Amazon+EC2+Plugin>. 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?
>
>
> PROBLEM: I'm able to launch a slave,But unable to set environment
> variables for that slave.
>
>
> 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)
>
>
>
> #!/bin/sh
>
> sudo mkdir /opt/apache-maven-3.2.5
> if [ -d /opt/apache-maven-3.2.5 ]; then
>
>
Isn't the sense of that conditional incorrect?  I think you want to take
the actions below only if the directory does not exist.

>
>     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
>
> Don't you want to place your Maven installation directory early in the
PATH so that the shell will find your freshly installed maven?

>
> DISPLAY=:1
> MAVEN_HOME=/opt/apache-maven-3.2.5
>
>
> Jenkins version:1.656
> Amazon EC2 plugin:1.31
>
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/c7d0d440-7103-4230-ab0b-6cce01b2aec6%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-users/c7d0d440-7103-4230-ab0b-6cce01b2aec6%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtGB4r0g372cK4-73eoaTrnUoYJpcTgDf6pSV9Qkn7Dxmw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to