[英]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.