gpt4 book ai didi

git - 如何使用 jenkins 在 git 中获取更改的文件列表

转载 作者:行者123 更新时间:2023-12-05 03:03:37 25 4
gpt4 key购买 nike

我有一个 git 仓库。当 Jenkins 构建完成时,我需要以 json 格式或任何文件格式获取更改的文件

最佳答案

你也可以这样做:git diff --name-only $GIT_PREVIOUS_COMMIT $GIT_COMMIT 在您的构建脚本中,将其通过管道传输到一个文件,您应该拥有在该特定构建中已更改的所有文件的列表。这是假设您使用的是 Git Plugin for Jenkins .

The git plugin sets several environment variables you can use in your scripts:

GIT_COMMIT - SHA of the current GIT_BRANCH - Name of the remote repository (defaults to origin), followed by name of the branch currently being used, e.g. "origin/master" or "origin/foo"

GIT_LOCAL_BRANCH - Name of the branch on Jenkins. When the "checkout to specific local branch" behavior is configured, the variable is published. If the behavior is configured as null or **, the property will contain the resulting local branch name sans the remote name.

GIT_PREVIOUS_COMMIT - SHA of the previous built commit from the same branch (not set on first build on a branch)

如果您希望此文件成为构建工件,您可以使用 Archive Artifacts 构建后步骤。

关于git - 如何使用 jenkins 在 git 中获取更改的文件列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53650949/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com