diff --git a/roles/build-docker-image/tasks/build.yaml b/roles/build-docker-image/tasks/build.yaml index 99eac9b19..b0ba340f3 100644 --- a/roles/build-docker-image/tasks/build.yaml +++ b/roles/build-docker-image/tasks/build.yaml @@ -1,6 +1,6 @@ - name: Check sibling directory stat: - path: '{{ zuul_work_dir }}/.zuul-siblings' + path: '{{ zuul_work_dir }}/{{ item.context }}/.zuul-siblings' register: _dot_zuul_siblings # This should have been cleaned up; multiple builds may specify @@ -11,7 +11,7 @@ - name: Create sibling source directory file: - path: '{{ zuul_work_dir }}/.zuul-siblings' + path: '{{ zuul_work_dir }}/{{ item.context }}/.zuul-siblings' state: directory mode: 0755 when: item.siblings is defined @@ -19,7 +19,9 @@ # NOTE(ianw): could use recursive copy: with remote_src, but it's # Ansible 2.8 only. take the simple approach. - name: Copy sibling source directories - command: 'cp -r ~/src/{{ sibling }} {{ zuul_work_dir }}/.zuul-siblings/' + command: + cmd: 'cp --parents -r {{ sibling }} /home/zuul/{{ zuul_work_dir }}/{{ item.context }}/.zuul-siblings' + chdir: '~/src' loop: '{{ item.siblings }}' loop_control: loop_var: sibling diff --git a/test-playbooks/registry/docker-siblings/Dockerfile b/test-playbooks/registry/docker-siblings/Dockerfile new file mode 100644 index 000000000..8907b1e30 --- /dev/null +++ b/test-playbooks/registry/docker-siblings/Dockerfile @@ -0,0 +1,6 @@ +FROM docker.io/library/debian:testing +ARG ZUUL_SIBLINGS="" +RUN echo "Zuul siblings: ${ZUUL_SIBLINGS}" +COPY .zuul-siblings/opendev.org/project/fake-sibling/file /target +COPY .zuul-siblings/openstack.org/project/fake-sibling/file /target +CMD echo "Zuul container test"; sleep infinity diff --git a/test-playbooks/registry/test-registry.yaml b/test-playbooks/registry/test-registry.yaml index 408629c61..b45734ab8 100644 --- a/test-playbooks/registry/test-registry.yaml +++ b/test-playbooks/registry/test-registry.yaml @@ -125,23 +125,22 @@ - name: Create fake sibling projects command: >- - mkdir -p src/opendev.org/fake-sibling-1 && - mkdir -p src/opendev.org/fake-sibling-2 && - touch src/opendev.org/fake-sibling-1/file && - touch src/opendev.org/fake-sibling-2/file + mkdir -p src/opendev.org/project/fake-sibling && + mkdir -p src/openstack.org/project/fake-sibling && + touch src/opendev.org/project/fake-sibling/file && + touch src/openstack.org/project/fake-sibling/file - name: Build docker image include_role: name: "build-{{ (container_command == 'docker') | ternary('docker', 'container') }}-image" vars: docker_images: - - context: test-playbooks/registry/docker + - context: test-playbooks/registry/docker-siblings repository: downstream/image siblings: - - opendev.org/fake-sibling-1 - - opendev.org/fake-sibling-2 + - opendev.org/project/fake-sibling + - openstack.org/project/fake-sibling container_images: "{{ docker_images }}" - - hosts: executor name: Test pushing to the intermediate registry tasks: