Skip to content
This repository was archived by the owner on Apr 26, 2019. It is now read-only.
This repository was archived by the owner on Apr 26, 2019. It is now read-only.

How do I set environment variables to agent (like /etc/default/go-agent) #74

@MPV

Description

@MPV

What I'd like to do:
Run scripts that set environment variables, which become available to my agents.

Steps I've done:

  1. I've created a Docker image based on this image (gocd/gocd-agent-docker-dind specifically).
  2. I've added some scripts I'd like to run in /etc/profile.d/, for example this one:
$ cat /etc/profile.d/add-python-scripts-to-path.sh
#!/bin/false

export PATH="/home/go/.local/bin:$PATH"
  1. I've created the /etc/default/go-agent file, and have it load /etc/profile:
$ cat /etc/default/go-agent
. /etc/profile
  1. ...and /etc/profile in turn should load the files in /etc/profile.d:
$ tail -n5 /etc/profile
for script in /etc/profile.d/*.sh ; do
        if [ -r $script ] ; then
                . $script
        fi
done

...however when I run jobs using this image, my scripts haven't been run, and the environment variables aren't set.

Questions:

  1. Am I configuring the right file? (/etc/default/go-agent)
  2. Am I running without service_mode? I suppose I am (?) — and then my guess (judging from /go-agent/agent.sh) is that maybe my file won't be loaded:
$ grep "/etc/default" -B 1 -A 5 /go-agent/agent.sh
if [ "$2" == "service_mode" ]; then
  if [ -f /etc/default/${SERVICE_NAME} ]; then
    . /etc/default/${SERVICE_NAME}
  fi

  # no point in not daemonizing the service
  DAEMON=Y
fi
  1. If that's the case, is there another way I should be telling the gocd agent to run my files for setting environment variables etc?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions