简体   繁体   English

我如何让Jenkins存档上一版本和最新版本之间的git差异?

[英]How can I get Jenkins to archive git difference between last build and latest one?

So basically I'm trying to get Jenkins to make an update.zip of all the changed files (including their path) between the last build git commit and the latest one. 因此,基本上我想让Jenkins对上次构建git commit和最新的git commit之间的所有更改文件(包括它们的路径)进行update.zip。

I have this script to make a full files zip and an update zip however if I make multiple commits and push, it will only make an archive of the latest commit. 我有此脚本来制作完整的文件zip和更新的zip,但是,如果我进行多次提交和推送,它将只保存最新提交的存档。

Is there any way I can get it to make an archive of all the changed and new files in the update zip from the previous build commit to the latest? 有什么办法可以使它从以前的版本提交到最新的更新zip中的所有更改文件和新文件的存档?

zip -r -9 $WORKSPACE/builds/full-files-$BUILD_NUMBER.zip files
git archive -o $WORKSPACE/builds/Update-$BUILD_NUMBER.zip HEAD $(git diff --name-only HEAD^)

(Hopefully I'm explaining this correctly) (希望我能正确解释)

Any help is much appreciated. 任何帮助深表感谢。

To do this, you need to be able to retrieve the last commit built. 为此,您需要能够检索上一次构建的提交。 According to the git plugin documentation , it should be available in the GIT_PREVIOUS_COMMIT environment variable. 根据git插件文档 ,它应该在GIT_PREVIOUS_COMMIT环境变量中可用。 Hence you could try getting the diff using 因此,您可以尝试使用

git diff --name-only $GIT_PREVIOUS_COMMIT

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我最近一次提交和最后一次提交之间的git diff - git diff between the latest commit and the last one I did 我可以让 Jenkins 从传入的参数中构建 git 标签吗? - Can I get Jenkins to build a git tag from a passed in parameter? 如何让Jenkins在推送到BitBucket git存储库的基础上构建? - How do I get Jenkins to build on push to a BitBucket git repository? 如何为特定的jenkins构建添加git标签? - How can I add a git tag for a specific jenkins build? 如何在Jenkins中构建最新的git flow release分支? - How to build the latest git flow release branch in Jenkins? git:如何将我的工作文件与最新的文件合并 - git: How can I merge my working file with the latest one 如何在TeamCity REST API中获取每个Git分支的最后构建列表? - How can I get a list of the last build for each Git branch in the TeamCity REST API? 如何从一个本地 git 存储库获得多个 Jenkins 构建? - How can I get multiple Jenkins builds to work from one local git repo? 自上次使用git / gerrit在Jenkins / Hudson中生成以来,如何获取已更改文件的列表 - How to get list of changed files since last build in Jenkins/Hudson with git/gerrit 如何在 Git 的当前分支中获取最新的标签名称? - How can I get the latest tag name in current branch in Git?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM