Skip to content

Commit

Permalink
release: Merge brew job with release job
Browse files Browse the repository at this point in the history
 - We decided to add brew into the release job,
since make sense to upload the metadata to brew everytime
we release something.
  • Loading branch information
ravanelli committed Jul 10, 2023
1 parent f467156 commit da989d6
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 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

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 @@ -275,6 +282,41 @@ 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 meta = readJSON(text: shwrapCapture("cosa meta --build=${params.VERSION} --arch=${arch} --dump"))
def state = false
if (meta["koji"]) {
def id = meta["koji"]["build_id"]
state = shwrapCapture("""
coreos-assembler koji-upload search \
--buildid ${id} \
--keytab "/run/kubernetes/secrets/brew-keytab/brew.keytab" \
--owner ${brew_principal} \
--profile ${brew_profile}
""")
}
// Check if no Brew upload was done yet
// State 1 means brew build complete
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}
""")
}
}
}
}
stage('Publish') {
pipeutils.withAWSBuildUploadCredentials() {
// Since some of the earlier operations (like AWS replication) only modify
Expand Down

0 comments on commit da989d6

Please sign in to comment.