Skip to content

Promote min and bundle artifacts to release-candidate after every bundle build #1378

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

Merged
merged 20 commits into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
31 changes: 29 additions & 2 deletions src/jenkins/BuildManifest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,29 @@ class BuildManifest implements Serializable {
}
}

class Components implements Serializable {
String dist

Components(Map data) {
this.dist = data.artifacts.dist
}

String getDistPackageLocation() {
try {
return this.dist[0]
} catch (Exception e) {
echo "Exception: ${e}"
}

}
}

Build build
Components components

BuildManifest(Map data) {
this.build = new BuildManifest.Build(data.build)
this.components = new BuildManifest.Components(data.components)
}

public String getArtifactRoot(String jobName, String buildNumber) {
Expand All @@ -49,6 +68,14 @@ class BuildManifest implements Serializable {
this.getArtifactRoot(jobName, buildNumber)
].join('/')
}
}


public String getPackageName() {
String packagePrefix = [
this.buid.getFilename(),
this.build.version,
this.build.platform,
this.build.architecture,
].join('-')
return packagePrefix + '.tar.gz'
}
}
12 changes: 10 additions & 2 deletions vars/uploadArtifacts.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ void call(Map args = [:]) {
def lib = library(identifier: 'jenkins@20211123', retriever: legacySCM(scm))

def buildManifest = lib.jenkins.BuildManifest.new(readYaml(file: args.manifest))
def fileLocation = buildManifest.components.getDistPackageLocation()
def productName = buildManifest.build.getFilename()
def fileName = buildManifest.getPackageName()

def artifactPath = buildManifest.getArtifactRoot("${JOB_NAME}", "${BUILD_NUMBER}")
echo "Uploading to s3://${ARTIFACT_BUCKET_NAME}/${artifactPath}"
Expand All @@ -11,10 +14,15 @@ void call(Map args = [:]) {
s3Upload(file: 'dist', bucket: "${ARTIFACT_BUCKET_NAME}", path: "${artifactPath}/dist")
}

withAWS(role: "${ARTIFACT_PROMOTION_ROLE_NAME}", roleAccount: "${AWS_ACCOUNT_PUBLIC_REAL}", duration: 900, roleSessionName: 'jenkins-session') {
s3Upload(file: "builds/test-release-candidates/core/${productName}/${buildManifest.build.version}", bucket: "${ARTIFACT_PUBLIC_BUCKET_NAME}", path: "${artifactPath}/builds/${productName}/${fileLocation}")
s3Upload(file: "builds/test-release-candidates/bundle/${productName}/${buildManifest.build.version}", bucket: "${ARTIFACT_PUBLIC_BUCKET_NAME}", path: "${artifactPath}/dist/${productName}/${fileName}")
}

def baseUrl = buildManifest.getArtifactRootUrl("${PUBLIC_ARTIFACT_URL}", "${JOB_NAME}", "${BUILD_NUMBER}")
lib.jenkins.Messages.new(this).add("${STAGE_NAME}", [
"${baseUrl}/builds/${buildManifest.build.getFilename()}/manifest.yml",
"${baseUrl}/dist/${buildManifest.build.getFilename()}/manifest.yml"
"${baseUrl}/builds/${productName}/manifest.yml",
"${baseUrl}/dist/${productName}/manifest.yml"
].join('\n')
)
}