来自Jenkins,我想获取最后一个提交代码来部署我的应用程序。我希望使用Git客户端插件执行此操作,但不要使用shell脚本执行此操作。有没有办法执行此操作。
Ex: - 我当前的头版本指向90696,我的旧头版本是38495.我想获取38495的头版本。
答案 0 :(得分:0)
您可以使用id
作为git插件分支说明符来获取一个提交。对于头部,只需使用$BRANCHNAME~1
E.g。在我的jenkins文件回购
HEAD~1
请注意,这适用于给定git checkout feature/jenkins-pipelines~1
Note: checking out 'feature/jenkins-pipelines~1'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at 7a4c357... updated jenkinsfile
的任何数字,将在头后面提交5个提交,依此类推。