From f405e52b4211ea3181454e06bdf3ca71ea13676e Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Aug 14 2025 10:16:12 +0000 Subject: Try to use the source PR The check that creates the message "Could not execute build: ..." comes from `pyrpkg/__init__.py ` and there seems to be no good way to disable it other than patching that usage. Second best thing we could do is to assume that the scratch builds are only run in PRs, which should be the current state of the zuul infrastructure, in which case we can get the source git url and branch to satisfy the check. --- diff --git a/roles/fedpkg-build-ng/tasks/main.yaml b/roles/fedpkg-build-ng/tasks/main.yaml index 674b2c9..fa0ea4c 100644 --- a/roles/fedpkg-build-ng/tasks/main.yaml +++ b/roles/fedpkg-build-ng/tasks/main.yaml @@ -15,25 +15,36 @@ become: true # In post-merge pipelines Zuul set explicitly the origin to /dev/null -- name: Set origin +- name: Set origin and tracking branch for non-scratch builds command: "{{ item }}" args: chdir: "{{ 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: Get PR information + uri: + url: https://src.fedoraproject.org/api/0/{{ zuul.project.name }}/pull-request/{{ zuul.change }} + return_content: true + status_code: 200 + register: pr_info + when: scratch_build -- name: Set tracking branch +- name: Set origin and tracking branch for scratch builds command: "{{ item }}" args: chdir: "{{ zuul.project.src_dir }}" loop: - - git branch -u origin/{{ release }} - when: not scratch_build + - git remote set-url origin {{ pr_info.json.repo_from.full_url }} + - git branch -u origin/{{ pr_info.json.branch_from }} + when: 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 }} --background {% endif %} + {% if scratch_build %} --scratch --arches {{ arches }} --skip-nvr-check --background {% endif %} --target {{ target }} args: chdir: "{{ zuul.project.src_dir }}"