设置PATH变量并在Dockerfile中获取环境

I've written a Dockerfile to create containers that have Golang installed. I have a goss test running the go version command, but the test is failing because the path variable (in the Dockerfile)--for some reason--doesn't stay set.

I've also tried sourcing the .env for go from inside the Dockerfile, but that doesn't seem to work either.

Dockerfile

ENV GIMME_VERSION "v1.4.0"
ENV GO_VERSION "1.4"
ENV JENKINS_HOME "/opt/jenkins"
ENV PATH="~/bin:${PATH}"
ENV PATH=“/opt/jenkins/.gimme/versions/go1.4.linux.amd64/bin:${PATH}“
ENV GOROOT="/opt/jenkins/.gimme/versions/go${GO_VERSION}.linux.amd64"

USER root

RUN yum -y install git && \
    yum -y clean all && \
    rm -rf /var/cache/yum

WORKDIR $JENKINS_HOME

USER jenkins

RUN mkdir ~/bin && \
    curl -sL -o ~/bin/gimme https://raw.githubusercontent.com/travis-
    ci/gimme/${GIMME_VERSION}/gimme && \
    chmod +x ~/bin/gimme && \
    gimme ${GO_VERSION}

USER root

RUN source /opt/jenkins/.gimme/envs/go${GO_VERSION}.linux.amd64.env

Goss Yaml

file:
  /opt/jenkins/.gimme:
    exists: true
    filetype: directory
  /opt/jenkins/.gimme/envs/go1.4.env:
    exists: true
    filetype: file
  /opt/jenkins/.gimme/versions/go1.4.linux.amd64:
    exists: true
    filetype: directory
  /opt/jenkins/.gimme/versions/go1.4.linux.amd64/bin/go:
    exists: true
    filetype: file
  /opt/jenkins/.gimme/versions/go1.4.linux.amd64/pkg:
    exists: true
    filetype: directory
  /opt/jenkins/.gimme/versions/go1.4.linux.amd64/src:
    exists: true
    filetype: directory
  /opt/jenkins/bin/gimme:
    filetype: file
    exists: true
    mode: '0755'
command:
  'gimme version':
  exit-status: 0
  'go version':
  exit-status: 0

It's not very clear at a first glance, but your double quotes around PATH are not the good unicode character. You should replace them by the usual ", not (Unicode UTF8 codepoint U+201C)

Demo: not the same:

$ od -c <<< \"
0000000   "  

0000002
$ od -c <<< \“
0000000 342 200 234  

0000004