如何在 Jenkins 管道中使用 GitHub 提交消息和提交 ID? [英] How to use GitHub commit message and commit id inside Jenkins pipeline?

查看:17
本文介绍了如何在 Jenkins 管道中使用 GitHub 提交消息和提交 ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 DevOps 模型,我在其中构建了用于代码构建和部署的管道.在整个过程中,我想记录特定更改提交的 Git 提交 ID 和提交消息.

I am using DevOps model, where i have built a pipeline for code build and deploy. In the entire process i want to log the Git commit id and commit message for that specific change commits.

@shruthibhaskar
shruthibhaskar committed just now 
1 parent 51132c4 commit aedd3dc56ab253419194762d72f2376aede66a19

并提交如下消息和描述

test commit 3

test commit desc 3

我如何在我的 jenkins 管道中访问这些提交值,我在其中配置了一个用于 SCM 轮询的 webhook?

how do i access these values of commit inside my jenkins pipeline, where i have configured a webhook for SCM polling?

推荐答案

git log --format=format:%s -1 (最新提交)

git log --format=format:%s -1 ${GIT_COMMIT}(具体提交)

git --no-pager show -s --format='%s' ${GIT_COMMIT}

这篇关于如何在 Jenkins 管道中使用 GitHub 提交消息和提交 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆