我为项目的每个分支运行了一个Docker Hub autobuild项目。这些构建运行良好。
我想扩展这个autobuild配置,为这些分支的选定拉取请求构建图像。
以下文档表明DockerHub autobuild中应该有一个名为DOCKER_TAG的变量。
https://docs.docker.com/docker-hub/builds/advanced/#environment-variables-for-building-and-testing
我想以下面的方式配置我的自动构建。
如果我尝试构建名为“pr1234”的标记,那么我的构建将在运行构建之前覆盖PR#1234的代码。
# Assign the env variable DOCKER_TAG to an arg of the same name
ARG DOCKER_TAG=${DOCKER_TAG}
...
# if DOCKER_TAG is in the format prNNNN then merge code for that PR on top of the current branch
RUN PRNUM=`echo ${DOCKER_TAG}| egrep "^pr([0-9]+)$" | sed -e s/pr//` && \
if [ -n "$PRNUM" ]; \
then echo "Merging $PRNUM"; \
curl -o /tmp/pr.patch -L https://github.com/DSpace/DSpace/pull/$PRNUM.diff; \
git apply /tmp/pr.patch; \
fi
如果我在本地运行我的构建,我可以设置此变量,我的docker构建运行我想要的。
docker build -t dspace/dspace:pr1234 -f Dockerfile.jdk8-test --build-arg DOCKER_TAG=pr1234 .
当我尝试从Dockerhub运行它时,DOCKER_TAG变量似乎是空白的,所以我假设DOCKER_TAG没有像我预期的那样设置。
您能否建议一种方法来访问此变量或完成所选PR的自动构建?