Replace awk with ansible regex_search on build-test-packages
Some jobs[1] are not working with current awk command to get a substring from rdopkg output. This patch replaces with ansible regex_search instead. This patch also fix the 'host' value extract from zuul vars. The previous value is invalid as host when cloning code with git module. This git checkout isn't failing since the previous step, that copies cloned code from zuul working dir is always executed with success. [1] https://logserver.rdoproject.org/46/46046/26/check/periodic-tripleo-ci-build-containers-ubi-9-quay-push-wallaby/1cc4376/job-output.txt Change-Id: I5efc6adf0c8039f6a618b3ae1e1e8184304465d1
This commit is contained in:
parent
a21d6b35ab
commit
7c1510421a
|
@ -68,7 +68,7 @@
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- name: Map project name to DLRN project name
|
- name: Map project name to DLRN project name
|
||||||
register: project_name_mapped
|
register: project_name_mapped_output
|
||||||
shell:
|
shell:
|
||||||
chdir: '{{ build_repo_dir }}/DLRN'
|
chdir: '{{ build_repo_dir }}/DLRN'
|
||||||
cmd: |
|
cmd: |
|
||||||
|
@ -77,29 +77,31 @@
|
||||||
# {{ rdoinfo_repo_name }}/{{ rdoinfo_repo_name.split('info')[0] }}-full.yml will
|
# {{ rdoinfo_repo_name }}/{{ rdoinfo_repo_name.split('info')[0] }}-full.yml will
|
||||||
# return rdo-full.yml and for downstream is osp-full.yml.
|
# return rdo-full.yml and for downstream is osp-full.yml.
|
||||||
rdopkg findpkg -s '{{ artg_change.project | basename }}' \
|
rdopkg findpkg -s '{{ artg_change.project | basename }}' \
|
||||||
-i {{ rdoinfo_repo_name }}/{{ rdoinfo_repo_name.split('info')[0] }}-full.yml | \
|
-i {{ rdoinfo_repo_name }}/{{ rdoinfo_repo_name.split('info')[0] }}-full.yml
|
||||||
awk '/^name/{print $2}; {print "findpkg: " $0 > "/dev/stderr"}'
|
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: project_name_mapped.rc != 0 or not project_name_mapped.stdout
|
failed_when: project_name_mapped_output.rc != 0 or not project_name_mapped_output.stdout
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
project_name_mapped: "{{ project_name_mapped_output.stdout | regex_search('name:(.+)', '\\1') | first | trim }}"
|
||||||
|
|
||||||
rescue:
|
rescue:
|
||||||
- debug:
|
- debug:
|
||||||
msg: |
|
msg: |
|
||||||
WARNING: Got {{ project_name_mapped.rc }} result code trying to build {{ artg_change.project }}
|
WARNING: Got {{ project_name_mapped_output.rc }} result code trying to build {{ artg_change.project }}
|
||||||
--- STDERR ---
|
--- STDERR ---
|
||||||
{{ project_name_mapped.stderr }}
|
{{ project_name_mapped_output.stderr }}
|
||||||
--- STDOUT ---
|
--- STDOUT ---
|
||||||
{{ project_name_mapped.stdout }}
|
{{ project_name_mapped_output.stdout }}
|
||||||
|
|
||||||
- when: project_name_mapped is success
|
- when: project_name_mapped is defined
|
||||||
block:
|
block:
|
||||||
- name: Append project name to package list
|
- name: Append project name to package list
|
||||||
set_fact:
|
set_fact:
|
||||||
artg_rdo_packages: '{{ artg_rdo_packages }} + {{ [ project_name_mapped.stdout ] }}'
|
artg_rdo_packages: '{{ artg_rdo_packages }} + {{ [ project_name_mapped ] }}'
|
||||||
|
|
||||||
- name: Check if project {{ project_name_mapped.stdout }} source already exist
|
- name: Check if project {{ project_name_mapped }} source already exist
|
||||||
stat:
|
stat:
|
||||||
path: '{{ build_repo_dir }}/DLRN/data/{{ project_name_mapped.stdout }}/.git'
|
path: '{{ build_repo_dir }}/DLRN/data/{{ project_name_mapped }}/.git'
|
||||||
register: repo_status
|
register: repo_status
|
||||||
|
|
||||||
- name: Create data directory if doesn't exist yet
|
- name: Create data directory if doesn't exist yet
|
||||||
|
@ -110,7 +112,7 @@
|
||||||
- name: Copy from ready directories if configured
|
- name: Copy from ready directories if configured
|
||||||
command: >
|
command: >
|
||||||
cp -raf {{ artg_repos_dir | dirname }}/{{ artg_change.project }}
|
cp -raf {{ artg_repos_dir | dirname }}/{{ artg_change.project }}
|
||||||
{{ build_repo_dir }}/DLRN/data/{{ project_name_mapped.stdout }}
|
{{ build_repo_dir }}/DLRN/data/{{ project_name_mapped }}
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: copy_dir
|
register: copy_dir
|
||||||
when: artg_repos_dir is defined
|
when: artg_repos_dir is defined
|
||||||
|
@ -118,7 +120,7 @@
|
||||||
- name: Clone the gated change
|
- name: Clone the gated change
|
||||||
git:
|
git:
|
||||||
repo: '{{ artg_change.host }}/{{ artg_change.project }}'
|
repo: '{{ artg_change.host }}/{{ artg_change.project }}'
|
||||||
dest: '{{ build_repo_dir }}/DLRN/data/{{ project_name_mapped.stdout }}'
|
dest: '{{ build_repo_dir }}/DLRN/data/{{ project_name_mapped }}'
|
||||||
refspec: '{{ artg_change.refspec }}'
|
refspec: '{{ artg_change.refspec }}'
|
||||||
version: 'FETCH_HEAD'
|
version: 'FETCH_HEAD'
|
||||||
when:
|
when:
|
||||||
|
@ -128,7 +130,7 @@
|
||||||
|
|
||||||
- name: Cleanup and checkout the relevant branch
|
- name: Cleanup and checkout the relevant branch
|
||||||
vars:
|
vars:
|
||||||
git_path: '{{ build_repo_dir }}/DLRN/data/{{ project_name_mapped.stdout }}'
|
git_path: '{{ build_repo_dir }}/DLRN/data/{{ project_name_mapped }}'
|
||||||
git_branch: '{{ artg_change.branch }}'
|
git_branch: '{{ artg_change.branch }}'
|
||||||
shell: |
|
shell: |
|
||||||
set -eu
|
set -eu
|
||||||
|
@ -140,13 +142,13 @@
|
||||||
|
|
||||||
- name: Ensure distgit repo is absent, DLRN takes care of cloning based on config
|
- name: Ensure distgit repo is absent, DLRN takes care of cloning based on config
|
||||||
file:
|
file:
|
||||||
path: "{{ build_repo_dir }}/DLRN/data/{{ project_name_mapped.stdout }}_distro"
|
path: "{{ build_repo_dir }}/DLRN/data/{{ project_name_mapped }}_distro"
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Clone the distgit change
|
- name: Clone the distgit change
|
||||||
git:
|
git:
|
||||||
repo: '{{ artg_change.distgit.host }}/{{ artg_change.distgit.project }}'
|
repo: '{{ artg_change.distgit.host }}/{{ artg_change.distgit.project }}'
|
||||||
dest: '{{ build_repo_dir }}/DLRN/data/{{ project_name_mapped.stdout }}_distro'
|
dest: '{{ build_repo_dir }}/DLRN/data/{{ project_name_mapped }}_distro'
|
||||||
refspec: '{{ artg_change.distgit.refspec }}'
|
refspec: '{{ artg_change.distgit.refspec }}'
|
||||||
version: 'FETCH_HEAD'
|
version: 'FETCH_HEAD'
|
||||||
accept_hostkey: true
|
accept_hostkey: true
|
||||||
|
@ -162,7 +164,7 @@
|
||||||
|
|
||||||
- name: Print info about building
|
- name: Print info about building
|
||||||
debug:
|
debug:
|
||||||
msg: "Building change for {{ project_name_mapped.stdout|default('unknown') }}"
|
msg: "Building change for {{ project_name_mapped|default('unknown') }}"
|
||||||
|
|
||||||
- name: Run DLRN
|
- name: Run DLRN
|
||||||
shell: >
|
shell: >
|
||||||
|
|
|
@ -186,7 +186,7 @@
|
||||||
# 2. project name should be present in zuul processed change list
|
# 2. project name should be present in zuul processed change list
|
||||||
- name: construct zuul deps list but don't cache it so it can be reprepared during upgrades
|
- name: construct zuul deps list but don't cache it so it can be reprepared during upgrades
|
||||||
set_fact:
|
set_fact:
|
||||||
artg_change_list_prep: "{{ artg_change_list_prep|default([]) + [{'host': item.change_url.rpartition('/')[0],
|
artg_change_list_prep: "{{ artg_change_list_prep|default([]) + [{'host': item.change_url | regex_search('(^https?://.*?)/', '\\1') | first,
|
||||||
'project': item.project.name,
|
'project': item.project.name,
|
||||||
'branch': item.branch,
|
'branch': item.branch,
|
||||||
'refspec': '/'.join(['refs', 'changes',
|
'refspec': '/'.join(['refs', 'changes',
|
||||||
|
|
|
@ -3,7 +3,7 @@ set +e
|
||||||
cd {{ build_repo_dir }}/DLRN
|
cd {{ build_repo_dir }}/DLRN
|
||||||
source {{ build_repo_dir }}/dlrn-venv/bin/activate;
|
source {{ build_repo_dir }}/dlrn-venv/bin/activate;
|
||||||
{% if artg_build_one|bool %}
|
{% if artg_build_one|bool %}
|
||||||
export PKG={{ project_name_mapped.stdout }}
|
export PKG={{ project_name_mapped }}
|
||||||
{% else %}
|
{% else %}
|
||||||
export PKG="{{ artg_rdo_packages|join(' --package-name ') }}"
|
export PKG="{{ artg_rdo_packages|join(' --package-name ') }}"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in New Issue