在 google 云构建中获取最后 push/merge 的提交
getting commit of last push/merge in google cloud build
我正在使用 Cloud Build 来触发 docker 构建,每当有人将更改推送到云源代码库上的分支时。我正在尝试将此行为更改为仅在 docker 文件发生更改时才构建图像。
在 github 操作上做类似的事情需要我 运行 类似 git diff --name-only ${{ github.event.before }}..${{ github.sha }}
的事情来获取在上次 push/merge 和 push/merge 之间更改的文件列表最新的提交,但是对于 cloudbuild,似乎没有等同于 {{ github.event.before }}
的东西。我很高兴听到您关于如何实现这一目标的建议。
更新:使用包含的文件过滤器似乎是一个可行的解决方案
Included files (optional): Changes affecting at least one of these files will invoke a build. You can use glob strings to specify multiple files with wildcard characters. Acceptable wildcard characters include the characters supported by Go Match, **, and alternation[0].
[0] https://cloud.google.com/build/docs/automating-builds/create-manage-triggers
使用包含的文件过滤器似乎是一个可行的解决方案
Included files (optional): Changes affecting at least one of these files will invoke a build. You can use glob strings to specify multiple files with wildcard characters. Acceptable wildcard characters include the characters supported by Go Match, **, and alternation[0].
[0] https://cloud.google.com/build/docs/automating-builds/create-manage-triggers
我正在使用 Cloud Build 来触发 docker 构建,每当有人将更改推送到云源代码库上的分支时。我正在尝试将此行为更改为仅在 docker 文件发生更改时才构建图像。
在 github 操作上做类似的事情需要我 运行 类似 git diff --name-only ${{ github.event.before }}..${{ github.sha }}
的事情来获取在上次 push/merge 和 push/merge 之间更改的文件列表最新的提交,但是对于 cloudbuild,似乎没有等同于 {{ github.event.before }}
的东西。我很高兴听到您关于如何实现这一目标的建议。
更新:使用包含的文件过滤器似乎是一个可行的解决方案
Included files (optional): Changes affecting at least one of these files will invoke a build. You can use glob strings to specify multiple files with wildcard characters. Acceptable wildcard characters include the characters supported by Go Match, **, and alternation[0].
[0] https://cloud.google.com/build/docs/automating-builds/create-manage-triggers
使用包含的文件过滤器似乎是一个可行的解决方案
Included files (optional): Changes affecting at least one of these files will invoke a build. You can use glob strings to specify multiple files with wildcard characters. Acceptable wildcard characters include the characters supported by Go Match, **, and alternation[0].
[0] https://cloud.google.com/build/docs/automating-builds/create-manage-triggers