Fix publish charm job

When there are no charms as artifacts in gate
pipeline, the publish charm variable charm_channels
is not defaulted to empty dictionary.
Set charm_channels default value to empty dictionary
wherever the variable is used.

Change-Id: I4fda23b2f103f168b85635bf1d9786cf62d845fb
This commit is contained in:
Hemanth Nakkina 2023-12-01 14:11:59 +05:30
parent 7503f5cdba
commit 7a3ccdb004
No known key found for this signature in database
GPG Key ID: 2E4970F7B143168E

View File

@ -30,7 +30,12 @@
chdir: "{{ zuul.project.src_dir }}"
executable: /bin/bash
shell: |
ls *.charm | cut -d"." -f 1
charms=$(ls *.charm | cut -d"." -f 1)
if [[ $? != 0 ]]; then
echo ""
else
echo $charms | tr ' ' '\n'
fi
register: built_charms
- name: Prepare charm channel dict for downloaded charms
@ -41,13 +46,13 @@
- name: Print charm channel dict
debug:
msg: "Charms to be published: {{ charm_channels }}"
msg: "Charms to be published: {{ charm_channels | default({}) }}"
- name: Publish charms in a loop
include_tasks: "publish.yaml"
vars:
charm_build_name: "{{ channel.key }}"
publish_channel: "{{ channel.value }}"
loop: "{{ charm_channels|dict2items }}"
loop: "{{ charm_channels | default({}) | dict2items }}"
loop_control:
loop_var: channel