From fedd5a496928ca023c22326669569055ac47259d Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: Feb 24 2020 16:34:57 +0000 Subject: copr-build: make artifact fetchinh optional --- diff --git a/roles/copr-build/defaults/main.yaml b/roles/copr-build/defaults/main.yaml index 5f538f9..42c036b 100644 --- a/roles/copr-build/defaults/main.yaml +++ b/roles/copr-build/defaults/main.yaml @@ -1,2 +1,3 @@ copr_cmd: copr-cli -project_name: demo-project +copr_repo: demo-project +copr_retreive_artifacts: true diff --git a/roles/copr-build/tasks/main.yaml b/roles/copr-build/tasks/main.yaml index 950e4b2..dbcf8bc 100644 --- a/roles/copr-build/tasks/main.yaml +++ b/roles/copr-build/tasks/main.yaml @@ -1,29 +1,41 @@ -- name: Build package in copr - command: | - {{ copr_cmd }} build {{ project_name }}.{{ zuul.change }}.{{ zuul.patchset }} {{ srpm }} - -- name: Get last build info - command: | - {{ copr_cmd }} list-packages {{ project_name }}.{{ zuul.change }}.{{ zuul.patchset }} --with-latest-build - register: info - -- set_fact: - build_data: "{{ info.stdout | from_json }}" - -- name: Get build id - set_fact: - build_id: "{{ build_data[0]['latest_build']['id'] }}" +- name: Install system dependencies + yum: + name: + - copr-cli + - createrepo + state: latest + become: true - name: Clean previously downloaded artifacts if exists file: - path: "{{ ansible_user_dir }}/copr_repos/{{ chroot_name }}" + path: "{{ ansible_user_dir }}/copr_repos" state: absent -- name: Fetch build artifacts from copr +- name: Build package in copr command: | - {{ copr_cmd }} download-build -d {{ ansible_user_dir }}/copr_repos {{ build_id }} + {{ copr_cmd }} build {% if copr_chroot_name is defined %}-r {{ copr_chroot_name }}{% endif %} {{ copr_repo }} {{ srpm }} + +- name: Fetch build artifacts + block: + - name: Get last build info + command: | + {{ copr_cmd }} list-packages {{ copr_repo }} --with-latest-build + register: info + + - set_fact: + build_data: "{{ info.stdout | from_json }}" + + - name: Get build id + set_fact: + build_id: "{{ build_data[0]['latest_build']['id'] }}" + + - name: Fetch build artifacts from copr + command: | + {{ copr_cmd }} download-build -d {{ ansible_user_dir }}/copr_repos {{ build_id }} -- name: Create repository - command: createrepo . - args: - chdir: "{{ ansible_user_dir }}/copr_repos/{{ chroot_name }}" + - name: Create repository + command: createrepo . + args: + chdir: "{{ ansible_user_dir }}/copr_repos/{{ copr_chroot_name }}" + when: copr_chroot_name + when: copr_retrieve_artifacts