That won't work because tasks you launch like this are being launched
directly, forked from the GoCD agent process. When you do this you're
setting the env vars for all processes that are launched from this process,
but not changing the agent process env itself. If this were allowed, it'd
create chaos as an agent can run many jobs.

So it is setting the PATH for the launch environment of the flutter process
itself, but that process would have to actually launch which is too late.

If you want to change the PATH like that youd need to do so via an
intermediary shell (sh -c 'flutter doctor') or use a shell script for all
of your steps. That way the path is passed into the shell and then used to
find things.

But personally I think there are probably better and less coupled ways to
manage versions for dev tools than the path that, e.g tools like sdkman or
mise where your agent could have pre-installed versions and consuming jobs
can use a version controlled config that defines the required versions and
then locates them dynamically (using shims or wrapping launchers).

-Chad

On Tue, 9 Jul 2024, 00:39 Pablo León, <[email protected]> wrote:

> Hi Jason:
>
> For testing purposes I have created a single job pipeline:
>
> [image: Captura de pantalla 2024-07-08 174021.png]
> with this single environment variable:
> [image: Captura de pantalla 2024-07-08 174219.png]
>
> and this is the log I get when I run the pipeline:
> [image: Captura de pantalla 2024-07-08 174302.png]
>
> which shows an interesting [Debug information] ...
>
> If I change the path in
> /usr/share/go-agent/wrapper-config/wrapper-properties.conf, then the
> pipeline runs fine.
>
> With respect to changing JAVA_HOME environment variable, I can't make this
> work without changing the PATH ...
>
>     [pablo.leon@devel ~]$ export JAVA_HOME=/usr/lib/jvm/java-11-openjdk
>     [pablo.leon@devel ~]$ java -version
>     openjdk version "21.0.3" 2024-04-16 LTS
>
> El lunes, 8 de julio de 2024 a las 17:13:14 UTC+2, Jason Smyth escribió:
>
> Hi Pablo,
>
> Why do you feel that the PATH variable is not being honoured? You provide
> two examples of details that suggest that it _should_ be working, but
> assert that is not. What behaviour are you seeing that gives you that
> impression?
>
> With that said, I'm not sure that overriding the PATH is the best way to
> accomplish your objective. I think using the Java-specific variables like
> JAVA_HOME would be a cleaner way to handle your example case of multiple
> Java versions.
>
> I'm struggling to imagine a scenario where completely overriding the PATH
> isn't more trouble than its worth, though of course that doesn't mean that
> such a use case doesn't exist.
>
> Hope this helps.
>
> Cheers,
> Jason Smyth
>
>
> On Monday 8 July 2024 at 08:53:41 UTC-4 Pablo León wrote:
>
> Hi,
>
> I have configured a PATH environment variable in my pipeline,
> I see an "overriding environment variable 'PATH' with value
> '/usr/lib/jvm/java-11-openjdk:/usr/bin'" line in the logs, I even can see
> the new value of PATH in an "printenv" task.
>
> However, this value doesn't seems to be honoured as a search path!
>
> What is the recommend way to change the search path in go-cd?
>
> I know I can change this in the 
> /usr/share/go-agent/wrapper-config/wrapper-properties.conf
> file, but what if I need a different paths for each job? (for example for
> different java versions)
>
> Cheers!
>
> --
> You received this message because you are subscribed to the Google Groups
> "go-cd" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/go-cd/5228fbee-b5db-41c9-b0ad-92d8daa2116dn%40googlegroups.com
> <https://groups.google.com/d/msgid/go-cd/5228fbee-b5db-41c9-b0ad-92d8daa2116dn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/go-cd/CAA1RwH-XwtSGif7an6KJswjvikTKoY-MhSs1Xq4iBGwCXd7NMA%40mail.gmail.com.

Reply via email to