Fail container job if command failed

When script fails, the job continues and passes.  Remove
unnecessary code saving and let the task to fail.
Make script to be generated for easier investigation what
command was running.
Change-Id: I1edce370458769a1479ee568b745e78ddcef693a
This commit is contained in:
Sagi Shnaidman 2019-03-20 13:00:02 +02:00
parent c90c4b02f6
commit 784f6c5286
3 changed files with 22 additions and 17 deletions

View File

@ -17,6 +17,7 @@
mv *.conf {{ workspace }}/conf/
mv *.log {{ workspace }}/logs/
mv *.sh {{ workspace }}/logs/
mv /tmp/kolla-* {{ workspace }}/logs/buildah-builds/ || true
rsync -var --no-links /var/log/ {{ workspace }}/logs/system/ || true
rsync -var --no-links /etc/docker/ {{ workspace }}/etc/docker/ || true

View File

@ -62,26 +62,17 @@
mode: 0644
force: yes
- name: Generate building script
template:
src: templates/build.sh.j2
dest: "{{ workspace }}/build_containers.sh"
mode: 0777
force: yes
- name: Run image build
args:
chdir: '{{ workspace }}'
shell: |
set -o pipefail
source {{ workspace }}/venv/bin/activate
TRIPLEO_COMMON_PATH="{{ openstack_git_root }}/tripleo-common"
openstack overcloud container image build \
--config-file $TRIPLEO_COMMON_PATH/container-images/overcloud_containers.yaml \
--kolla-config-file {{ workspace }}/kolla-build.conf \
{% for item in exclude_containers[ansible_pkg_mgr] %}
--exclude {{ item }} \
{% endfor %}
{% if use_buildah is defined and use_buildah %}
--use-buildah \
{% endif %}
2>&1 {{ timestamper_cmd }} > {{ workspace }}/build.log
RESULT=$?
exit $RESULT
shell: set -o pipefail && bash build_containers.sh 2>&1 {{ timestamper_cmd }} > {{ workspace }}/build.log
- name: Retrieve the images by version_hash and retag with tripleo-ci-testing if periodic
when:

View File

@ -0,0 +1,13 @@
#!/bin/bash -eux
source {{ workspace }}/venv/bin/activate
TRIPLEO_COMMON_PATH="{{ openstack_git_root }}/tripleo-common"
openstack overcloud container image build \
--config-file $TRIPLEO_COMMON_PATH/container-images/overcloud_containers.yaml \
--kolla-config-file {{ workspace }}/kolla-build.conf \
{% for item in exclude_containers[ansible_pkg_mgr] %}
--exclude {{ item }} \
{% endfor %}
{% if use_buildah is defined and use_buildah %}
--use-buildah \
{% endif %}