d6d835e414
When there is no commit since the tag, we don't want the scm_sha part of project_ver, but just the scm_tag. This patch fix the logic. Change-Id: I89e59049fe65ebc49fc03f205affa68b8fa5beb9
69 lines
1.9 KiB
YAML
69 lines
1.9 KiB
YAML
- name: Get SCM_SHA info
|
|
command: git rev-parse --short HEAD
|
|
failed_when: false
|
|
register: scm_sha_output
|
|
args:
|
|
chdir: "{{ zuul_work_dir }}"
|
|
# ANSIBLE0006: Skip linting since it triggers on the "git" command,
|
|
# but rev-parse is not supported by ansible git module.
|
|
tags:
|
|
- skip_ansible_lint
|
|
|
|
- name: Set scm_sha fact
|
|
set_fact:
|
|
scm_sha: "{{ scm_sha_output.stdout }}"
|
|
|
|
- name: Get SCM_TAG info
|
|
command: git describe --abbrev=0 --tags
|
|
failed_when: false
|
|
register: scm_tag_output
|
|
when: zuul.tag is not defined
|
|
args:
|
|
chdir: "{{ zuul_work_dir }}"
|
|
# ANSIBLE0006: Skip linting since it triggers on the "git" command,
|
|
# but describe is not supported by ansible git module.
|
|
tags:
|
|
- skip_ansible_lint
|
|
|
|
- name: Set scm_sha fact from output
|
|
set_fact:
|
|
scm_tag: "{{ scm_tag_output.stdout }}"
|
|
when: zuul.tag is not defined and scm_tag_output.stdout
|
|
|
|
- name: Set scm_tag fact from zuul
|
|
set_fact:
|
|
scm_tag: "{{ zuul.tag }}"
|
|
when: zuul.tag is defined
|
|
|
|
- name: Use git sha if there is no tag
|
|
set_fact:
|
|
scm_tag: "{{ scm_sha }}"
|
|
when: zuul.tag is not defined and not scm_tag_output.stdout
|
|
|
|
- name: Get commits since tag
|
|
# assumes format is like this '0.0.4-2-g135721c'
|
|
shell: |
|
|
git describe | awk '{split($0,a,"-"); print a[2]}'
|
|
failed_when: false
|
|
register: commits_since_tag_output
|
|
args:
|
|
chdir: "{{ zuul_work_dir }}"
|
|
# ANSIBLE0006: Skip linting since it triggers on the "git" command,
|
|
# but describe is not supported by ansible git module.
|
|
tags:
|
|
- skip_ansible_lint
|
|
|
|
- name: Set commits_since_tag fact
|
|
set_fact:
|
|
commits_since_tag: "{{ commits_since_tag_output.stdout }}"
|
|
|
|
- name: Set project_ver to scm_tag if there are no commits
|
|
when: not commits_since_tag
|
|
set_fact:
|
|
project_ver: "{{ scm_tag }}"
|
|
|
|
- name: Set project_ver if there are commits since the tag
|
|
when: commits_since_tag
|
|
set_fact:
|
|
project_ver: "{{ scm_tag }}.{{ commits_since_tag }}.{{ scm_sha }}"
|