-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ask koji to scratch-build pagure pull requests
Signed-off-by: Michal Srb <[email protected]>
- Loading branch information
Showing
4 changed files
with
76 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,41 +84,31 @@ pipeline { | |
environment { | ||
KOJI_KEYTAB = credentials('fedora-keytab') | ||
KRB_PRINCIPAL = 'bpeck/[email protected]' | ||
REPO_FULL_NAME = "${params.REPO_FULL_NAME}" | ||
SOURCE_REPO_FULL_NAME = "${sourceRepo}" | ||
REPO_NAME = "${params.REPO_FULL_NAME.split('/')[1]}" | ||
RELEASE_ID = "${releaseId}" | ||
PR_ID = "${params.PR_ID}" | ||
PR_UID = "${params.PR_UID}" | ||
PR_COMMIT = "${params.PR_COMMIT}" | ||
PR_COMMENT = "${params.PR_COMMENT}" | ||
RAWHIDE_RELEASE_ID = "${FEDORA_CI_RAWHIDE_RELEASE_ID}" | ||
} | ||
|
||
steps { | ||
script { | ||
timeout(time: 240, unit: 'MINUTES') { | ||
// lock buildroot | ||
lock("${env.NODE_NAME}-mock-buildroot") { | ||
def rc = sh(returnStatus: true, script: './pullRequest2scratchBuild.sh') | ||
if (fileExists('koji_url')) { | ||
kojiUrl = readFile("${env.WORKSPACE}/koji_url").trim() | ||
} | ||
if (fileExists('task_id')) { | ||
taskId = readFile("${env.WORKSPACE}/task_id").trim() | ||
} | ||
if (!kojiUrl || !taskId) { | ||
error('Failed to submit a scratch-build') | ||
def rc = sh(returnStatus: true, script: "./scratch-build.sh koji ${releaseId}-candidate git+https://src.fedoraproject.org/${sourceRepo}.git#${params.PR_COMMIT}") | ||
if (fileExists('koji_url')) { | ||
kojiUrl = readFile("${env.WORKSPACE}/koji_url").trim() | ||
} | ||
if (fileExists('task_id')) { | ||
taskId = readFile("${env.WORKSPACE}/task_id").trim() | ||
} | ||
catchError(buildResult: 'UNSTABLE') { | ||
if (rc != 0) { | ||
error('Failed to scratch build the pull request.') | ||
} | ||
} | ||
} | ||
sendMessage(type: 'running', artifactId: artifactId, pipelineMetadata: pipelineMetadata, dryRun: isPullRequest(), runUrl: kojiUrl) | ||
sendMessage(type: 'running', artifactId: artifactId, pipelineMetadata: pipelineMetadata, dryRun: isPullRequest(), runUrl: kojiUrl) | ||
|
||
// Wait for the scratch-build to finish | ||
def rc = sh(returnStatus: true, script: "./wait-build.sh ${taskId}") | ||
catchError(buildResult: 'UNSTABLE') { | ||
if (rc != 0) { | ||
error("Scratch-build failed in Koji") | ||
// Wait for the scratch-build to finish | ||
rc = sh(returnStatus: true, script: "./wait-build.sh ${taskId}") | ||
catchError(buildResult: 'UNSTABLE') { | ||
if (rc != 0) { | ||
error("Scratch-build failed in Koji") | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -130,6 +120,16 @@ pipeline { | |
success { | ||
sendMessage(type: 'complete', artifactId: artifactId, pipelineMetadata: pipelineMetadata, dryRun: isPullRequest(), runUrl: kojiUrl) | ||
|
||
// Run dist-git tests on the scratch build, and report results back to the pull request | ||
build( | ||
wait: false, | ||
job: 'fedora-ci/dist-git-pipeline/master', | ||
parameters: [ | ||
string(name: 'ARTIFACT_ID', value: "(koji-build:${taskId})->${artifactId}"), | ||
string(name: 'TEST_PROFILE', value: releaseId) | ||
] | ||
) | ||
|
||
// Run the installability test on the scratch build, and report results back to the pull request | ||
build( | ||
wait: false, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
# dist-git build pipeline | ||
|
||
This pipeline is responsible for scratch-building dist-git pull requests. | ||
|
||
It creates an SRPM and sends it to Koji where the actual magic happens. | ||
This pipeline scratch-builds dist-git pull requests. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
# Scratch-build pull requests in Koji. | ||
|
||
# Required environment variables: | ||
# KOJI_KEYTAB - path to the keytab that can be used to build packages in Koji | ||
# KRB_PRINCIPAL - kerberos principal | ||
|
||
workdir=${PWD} | ||
|
||
if [ $# -ne 3 ]; then | ||
echo "Usage: $0 <koji-profile> <target> <scm-url>" | ||
exit 101 | ||
fi | ||
|
||
koji_log=${workdir}/koji.log | ||
koji_url=${workdir}/koji_url | ||
task_id_file=${workdir}/task_id | ||
|
||
set -e | ||
set -x | ||
|
||
rm -f ${koji_log} | ||
rm -f ${koji_url} | ||
rm -f ${task_id_file} | ||
|
||
profile=${1} | ||
target=${2} | ||
source_url=${3} | ||
|
||
if [ -z "${KOJI_KEYTAB}" ]; then | ||
echo "Missing keytab, cannot continue..." | ||
exit 101 | ||
fi | ||
|
||
if [ -z "${KRB_PRINCIPAL}" ]; then | ||
echo "Missing kerberos principal, cannot continue..." | ||
exit 101 | ||
fi | ||
|
||
kinit -k -t ${KOJI_KEYTAB} ${KRB_PRINCIPAL} | ||
|
||
koji -p ${profile} build --scratch --fail-fast --nowait ${target} ${source_url} > ${koji_log} | ||
cat ${koji_log} | ||
|
||
cat ${koji_log} | grep '^Task info: ' | awk '{ print $3 }' > ${koji_url} | ||
|
||
task_id=$(cat ${koji_log} | grep '^Created task: ' | awk '{ print $3 }' | tee ${task_id_file}) |