【发布时间】:2020-04-14 21:58:01
【问题描述】:
这是我的 Dockerfile:
FROM node:alpine as builder
ENV GIT_SHA ${WhatToSetHere} <--------------------------- Would like to set gitSHA here
RUN printenv
RUN mkdir -p /app
WORKDIR /app
COPY package.json ./
RUN yarn install
COPY . .
COPY public ./public
# RUN ls -la /src/
RUN yarn run build
FROM node:alpine
RUN mkdir -p /app
WORKDIR /app
ENV NODE_ENV production
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/build ./build
EXPOSE 3000
CMD [ "yarn", "start:prod" ]
这是我的天蓝色管道:
trigger:
- master
pool:
vmImage: "ubuntu-latest"
variables:
buildConfiguration: "Release"
steps:
- task: GitVersion@5
- script: |
echo '##vso[task.setvariable variable=buildVersion]$(GitVersion.FullSemVer")'
- script: |
echo //registry.npmjs.org/:_authToken=$(NPM_TOKEN) > .npmrc
displayName: 'npm Authentication'
- task: Docker@2
inputs:
containerRegistry: acrXXX
repository: "XXX-client"
command: "buildAndPush"
Dockerfile: "**/Dockerfile"
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: "$(Build.SourcesDirectory)/deploy/XXX-client"
ArtifactName: "charts"
publishLocation: "Container"
如何从 jenkins 构建中获取提交 SHA 并将其设置为我的 dockerfile 中的 env 变量?您是否有任何文档可以指出构建中包含哪些值?
【问题讨论】:
-
我能否了解更多关于从 jenkins 构建中获取提交 SHA 的信息?提交在 Jenkins 中推送,然后在 azure devops 中触发 CI?
标签: docker azure-devops dockerfile