Created
December 26, 2017 17:43
-
-
Save vladzloteanu/7f5985d15aeb7f97d04c2555c338042d to your computer and use it in GitHub Desktop.
add git details.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Get hostname | |
shell: echo $HOSTNAME | |
register: local_hostname | |
delegate_to: localhost | |
- name: Get current user | |
shell: whoami | |
register: local_user | |
delegate_to: localhost | |
- name: Get git version | |
shell: "git log -n 1" | |
args: | |
chdir: "{{ base_tmp_dir }}projects/{{ project.name }}" | |
register: git_last_commit | |
delegate_to: localhost | |
- name: Get git hash | |
shell: "git rev-parse HEAD" | |
args: | |
chdir: "{{ base_tmp_dir }}projects/{{ project.name }}" | |
register: git_last_commit_hash | |
delegate_to: localhost | |
- name: Get git last commit message | |
shell: "git log -1 --pretty=%B" | |
args: | |
chdir: "{{ base_tmp_dir }}projects/{{ project.name }}" | |
register: git_last_commit_comment | |
delegate_to: localhost | |
- name: Add .DEPLOY_DETAILS | |
blockinfile: | |
dest: "{{ release_folder }}.DEPLOY_DETAILS" | |
create: yes | |
block: | | |
Local deploy from: {{ local_hostname.stdout }} | |
Local deploy user: {{ local_user.stdout }} | |
Timestamp: {{ ansible_date_time.iso8601_basic_short }} | |
Git log: | |
{{ git_last_commit.stdout }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment