54077ba1e1
This should be the negation of the condition above, not exactly the same but double negated. Change-Id: I24e5f73480c83777f8dcb5ca71283afe5565212f
90 lines
2.6 KiB
YAML
90 lines
2.6 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
|
|
when: commits_since_tag_output.rc == 0
|
|
set_fact:
|
|
commits_since_tag: "{{ commits_since_tag_output.stdout }}"
|
|
|
|
# Some repos, like storyboard-webclient, do not have any tags. git describe
|
|
# throws an error in those repos. To be consistent, do a commit count the
|
|
# hard way.
|
|
- when: commits_since_tag_output.rc != 0
|
|
block:
|
|
|
|
- name: Get commits since the beginning
|
|
command: git rev-list HEAD --count
|
|
register: commits_since_beginning
|
|
args:
|
|
chdir: "{{ zuul_work_dir }}"
|
|
# ANSIBLE0006: Skip linting since it triggers on the "git" command,
|
|
# but rev-list is not supported by ansible git module.
|
|
tags:
|
|
- skip_ansible_lint
|
|
|
|
- name: Set commits_since_tag fact
|
|
set_fact:
|
|
commits_since_tag: "{{ commits_since_beginning.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 }}"
|