From 5e2479fd0557cd68f82b67853034fe05b8a08cbd Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: Dec 21 2020 09:35:33 +0000 Subject: fedpkg-build: ng with use of zuul-output-dir --- diff --git a/roles/fedpkg-build-ng/defaults/main.yaml b/roles/fedpkg-build-ng/defaults/main.yaml new file mode 100644 index 0000000..0746d0f --- /dev/null +++ b/roles/fedpkg-build-ng/defaults/main.yaml @@ -0,0 +1,4 @@ +scratch_build: True +target: rawhide +release: master +arches: x86_64 diff --git a/roles/fedpkg-build-ng/tasks/main.yaml b/roles/fedpkg-build-ng/tasks/main.yaml new file mode 100644 index 0000000..e62fcef --- /dev/null +++ b/roles/fedpkg-build-ng/tasks/main.yaml @@ -0,0 +1,66 @@ +- set_fact: + zuul_output_dir: "{{ ansible_user_dir }}/zuul-output" + +- set_fact: + repo_artifact_dir: "{{ zuul_output_dir }}/logs/repo" + +- file: + path: "{{ repo_artifact_dir }}" + state: directory + +- name: Install system dependencies + yum: + name: "fedpkg,koji,createrepo" + state: latest + become: true + +# In post-merge pipelines Zuul set explicitly the origin to /dev/null +- name: Set origin and tracking branch + command: "{{ item }}" + args: + chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}" + loop: + - git remote set-url origin https://src.fedoraproject.org/{{ zuul.project.name }} + - git branch -u origin/{{ release }} + when: not scratch_build + +- name: Build package in Fedora build system {% if scratch_build %}(scratch build){% endif %} + command: | + fedpkg --release {{ release }} build + {% if scratch_build %} --scratch --arches {{ arches }} --srpm {{ srpm }} {% endif %} + --target {{ target }} + args: + chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}" + register: fedpkg_build + failed_when: + - fedpkg_build is failure or + fedpkg_build.stdout is search("Server Error") or + fedpkg_build.stdout is search("ServerOffline") + retries: 3 + delay: 60 + until: + - fedpkg_build.stdout is not search("Server Error") + - fedpkg_build.stdout is not search("ServerOffline") + +- name: Get task ID + set_fact: + task_id: "{{ fedpkg_build.stdout | regex_replace('\n', ' ') | regex_replace('.*Created task: (\\d+).*$', '\\1') }}" + +- name: Download artifacts from Koji + command: | + koji download-task --logs {{ task_id }} + args: + chdir: "{{ repo_artifact_dir }}" + +- name: Create repository + command: createrepo . + args: + chdir: "{{ repo_artifact_dir }}" + +- name: Return repo url + zuul_return: + data: + zuul: + artifacts: + - name: repo + url: repo