【问题标题】:How to retrieve the commit message of the checked out code with Ansible?如何使用 Ansible 检索签出代码的提交消息?
【发布时间】:2016-09-29 16:22:03
【问题描述】:

我创建了一个 Ansible Playbook,用于从 Git 存储库中签出代码。

如何使用 Ansible 检索签出代码的最新提交消息?

【问题讨论】:

    标签: git ansible ansible-playbook


    【解决方案1】:

    您可以使用 git log 获取最后的提交消息并将它们保存在变量中。像这样的:

    - name: get latest commit message
      shell: "git log --pretty="%s" -n1"
      args:
        chdir: "{{ path }}"
      register: latest_commit_message
    

    然后你得到最新的提交并将它们保存在变量latest_commit_message中。

    使用--pretty,您可以定义所需的输出格式。

    【讨论】:

    • 它有效。但是,提交消息存储在latest_commit_message.stdout
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-22
    • 2013-08-09
    • 2011-04-19
    • 1970-01-01
    相关资源
    最近更新 更多