jobs: added artifact deployment to nexus

Signed-off-by: Marc Mattmüller <marc.mattmueller@netmodule.com>
This commit is contained in:
Marc Mattmüller 2023-06-19 18:33:08 +02:00
parent 974b77234d
commit 1aea7bf218
2 changed files with 45 additions and 3 deletions

View File

@ -80,9 +80,9 @@ pipeline {
script {
dir("${env.YOCTO_REPO_DIR}") {
common.buildTheYoctoPackage()
def artifactName = "NWL-${machine}.zip"
env.ARTIFACT_NAME = "NWL-${machine}.zip"
common.collectingPackageArtifacts("${env.MACHINE}")
common.packAndArchiveArtifacts("${env.MACHINE}", artifactName)
common.packAndArchiveArtifacts("${env.MACHINE}", "${env.ARTIFACT_NAME}")
}
println "TODO: sync sstate-cache to the server"
}
@ -93,7 +93,7 @@ pipeline {
when { expression { return common.isCurrentJobSuccess() } }
steps {
script {
println "TODO: Deploy artifacts"
deployToArtifactory(common)
}
}
}
@ -162,3 +162,15 @@ def setupEnvironment(commonHelpers) {
commonHelpers.setupBuildEnvironment(machine, nwlBranch, nwlRepoDir, params.DEBUGGING)
commonHelpers.printEnvironmentParameters()
}
//---------------------------------------------------------------------------------------------------------------------
def deployToArtifactory(commonHelpers) {
def artifactFilepath = "${env.DEPLOY_CONTENT_DIR}/${env.ARTIFACT_NAME}"
def nexusGroupId = "nwl.${env.CI_IMAGE}"
def nexusArtifactId = "${env.MACHINE}"
def nexusVersion = "latest"
println "deploying ${artifactFilepath} as ${nexusGroupId}.${nexusArtifactId} to Nexus..."
commonHelpers.deployArtifactToNexusArtifactory(artifactFilepath, "zip", nexusGroupId, nexusArtifactId, nexusVersion)
}

View File

@ -24,6 +24,15 @@ env.YOCTO_RELEASE = 'kirkstone'
env.CI_IMAGE = "nwl-image-testable"
// Artifactory
//----------------------------
env.NEXUS_URL = "artifactory.gad.local:443"
env.NEXUS_VERSION = "nexus3"
env.NEXUS_PROTOCOL = "https"
env.NEXUS_REPOSITORY = "maven-releases"
env.NEXUS_ARTIFACT_COPIER_URL = "${env.NEXUS_PROTOCOL}://${env.NEXUS_URL}/repository/${env.NEXUS_REPOSITORY}"
// Methods declared in external code are accessible
// directly from other code in the external file
// indirectly via the object created by the load operation
@ -320,6 +329,27 @@ def packAndArchiveArtifacts(machine, pkgArchiveName) {
}
//-----------------------------------------------------------------------------
// deploy an artifact to the Nexus Artifactory
def deployArtifactToNexusArtifactory(artifactPathname, artifactType, groupId, artifactId, version) {
nexusArtifactUploader(
nexusVersion: "${env.NEXUS_VERSION}",
protocol: "${env.NEXUS_PROTOCOL}",
nexusUrl: "${env.NEXUS_URL}",
groupId: "${groupId}",
version: "${version}",
repository: "${env.NEXUS_REPOSITORY}",
credentialsId: "nexus_uploader_credentials",
artifacts: [
[artifactId: "${artifactId}",
classifier: "",
file: "${artifactPathname}",
type: "${artifactType}"]
]
);
}
// !!Important Boilerplate!!
// The external code must return it's contents as an object
return this;