zuul-jobs/roles/upload-docker-image/tasks/main.yaml
James E. Blair 3e3f836435 docker: add ability to restrict repository names
This allows us to construct a job which allows users to pass in a
secret (via pass-to-parent) which includes not only the user/pass,
but also a restriction for what docker image repositories may be
accessed using that user/pass.  This allows an operator to create
one credential, and then use that credential in multiple secrets
for multiple projects, each with a distinct restriction on where
images may be uploaded.

Change-Id: I7a3cf97a16d34c76df8601990954e1f2b0e498f5
2019-01-18 09:43:11 -08:00

14 lines
558 B
YAML

- name: Verify repository names
when: |
docker_credentials.repository is defined
and not item.repository | regex_search(docker_credentials.repository)
loop: "{{ docker_images }}"
fail:
msg: "{{ item.repository }} not permitted by {{ docker_credentials.repository }}"
- name: Log in to dockerhub
command: "docker login -u {{ docker_credentials.username }} -p {{ docker_credentials.password }}"
no_log: true
- name: Upload to dockerhub
command: "docker push {{ item.repository }}:change_{{ zuul.change }}"
loop: "{{ docker_images }}"