How can I set environment variables in a GitLab CI docker runner?

2

We need to set a company proxy to reach the internet from within our network. This is needed for the build-process (to fetch dependencies).

I have added the appropriate lines into /etc/bash.bashrc in our docker image.

When manually running the image with:

docker run --rm -ti bboss/python:3 /bin/bash

and then executing

export

I can see the variables.

However, when I define a GitLab CI task based on that image and add a section like:

test-job:
    script:
        - export

I don't see any variables.

It seems like the entries in /etc/bash.bashrc are not taken into consideration.

How can I make that work?

exhuma

Posted 2017-12-22T14:20:23.060

Reputation: 847

Answers

1

try

test-job:
    script:
        - env

mmccabe

Posted 2017-12-22T14:20:23.060

Reputation: 111

2Thank you for your contribution? Can you provide an explanation? – bertieb – 2018-04-17T22:30:40.833

Items listed after the 'script:' tag are executed in the default underlying shell. 'env' is a utility (typically found in sh, bsh, zsh, etc... ) that prints the current environment variables. 'export' is a command that is built in to the shell. It is possible that gitlab is not handling the 'export' command correctly. I recently used 'env' command in this way, so I know it works as expected. See 'man export' and 'man env' for more details. – mmccabe – 2018-04-18T05:32:49.080