Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: Merge brew job with release job #886

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 58 additions & 2 deletions jobs/release.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ node {
libcloud = load("libcloud.groovy")
}

def brew_principal = pipecfg.brew.principal
def brew_profile = pipecfg.brew.profile
ravanelli marked this conversation as resolved.
Show resolved Hide resolved

properties([
pipelineTriggers([]),
parameters([
Expand Down Expand Up @@ -84,7 +87,10 @@ currentBuild.description = "${build_description} Waiting"
def locks = basearches.collect{[resource: "release-${params.VERSION}-${it}"]}
lock(resource: "release-${params.STREAM}", extra: locks) {
cosaPod(cpu: "1", memory: "1Gi", image: cosa_img,
serviceAccount: "jenkins") {
serviceAccount: "jenkins",
secrets: ["brew-keytab", "brew-ca:ca.crt:/etc/pki/ca.crt",
"koji-conf:koji.conf:/etc/koji.conf",
"krb5-conf:krb5.conf:/etc/krb5.conf"]) {
try {

currentBuild.description = "${build_description} Running"
Expand All @@ -101,7 +107,8 @@ lock(resource: "release-${params.STREAM}", extra: locks) {
cosa init --branch ${ref} ${variant} ${pipecfg.source_config.url}
cosa buildfetch --build=${params.VERSION} \
--arch=all --url=s3://${s3_stream_dir}/builds \
--aws-config-file \${AWS_BUILD_UPLOAD_CONFIG}
--aws-config-file \${AWS_BUILD_UPLOAD_CONFIG} \
--file "coreos-assembler-config-git.json"
""")
}

Expand Down Expand Up @@ -279,6 +286,55 @@ lock(resource: "release-${params.STREAM}", extra: locks) {
}
}

if (brew_profile) {
stage('Brew Upload') {
def tag = pipecfg.streams[params.STREAM].brew_tag
for (arch in basearches) {
def state = false
// The koji/brew NVR is constructed like so:
// Name = "rhcos-$arch", like `rhcos-x86_64`
// Version = Everything before `-` in RHCOS version
// Release = Everything after `-` in RHCOS version
//
// Example: RHCOS Build ID: 414.92.202307170903-0 for x86_64
// Name = rhcos-x86_64
// Version = 414.92.202307170903
// Release = 0
// NVR = rhcos-x86_64-414.92.202307170903-0
def nvr = "rhcos-${arch}-${params.VERSION}"
state = shwrapCapture("""
coreos-assembler koji-upload search \
--nvr ${nvr} \
--keytab "/run/kubernetes/secrets/brew-keytab/brew.keytab" \
--owner ${brew_principal} \
--profile ${brew_profile} \
--build ${params.VERSION}
""")
// Check if no Brew upload was done yet
// State 1 means brew build complete
ravanelli marked this conversation as resolved.
Show resolved Hide resolved
// See for more build state info:
// https://pagure.io/koji/blob/master/f/www/kojiweb/builds.chtml#_27
// https://pagure.io/koji/blob/master/f/tests/test_cli/test_import.py#_73
if (state != "1") {
shwrap("""
coreos-assembler koji-upload \
upload --reserve-id \
--keytab "/run/kubernetes/secrets/brew-keytab/brew.keytab" \
--build ${params.VERSION} \
--retry-attempts 6 \
--buildroot builds \
--owner ${brew_principal} \
--profile ${brew_profile} \
--tag ${tag} \
--arch ${arch}
""")
}
else {
echo("Skipping Brew Upload. Brew build ${nvr} found")
}
}
}
}
stage('Publish') {
pipeutils.withAWSBuildUploadCredentials() {
// Since some of the earlier operations (like AWS replication) only modify
Expand Down
135 changes: 0 additions & 135 deletions jobs/upload-brew.Jenkinsfile

This file was deleted.