blob: 2dd06b7b5f50503109ca56de5c566ec3408f79c2 [file] [log] [blame]
#!/usr/bin/env groovy
def initSourceTree(boardName, needsNative = false) {
sh """
apt-get update
apt-get -y install make python curl git qemu-user-static sudo
curl https://storage.googleapis.com/git-repo-downloads/repo > /usr/local/bin/repo
chmod a+x /usr/local/bin/repo
mkdir -p .repo/local_manifests
mkdir -p cache
chmod 777 cache
"""
timeout(time: 3, unit: 'MINUTES') {
checkout([$class: 'RepoScm',
currentBranch: true,
jobs: 24,
manifestRepositoryUrl: 'http://coral.googlesource.com/manifest',
manifestBranch: 'master',
manifestFile: "${boardName}.xml",
depth: 1,
quiet: true])
}
// Bring in the pbuilder tarballs.
//
// archiveArtifacts includes the relative path to the
// files we archive, so we don't have to specify cache/
// here in the target.
if (needsNative) {
copyArtifacts(projectName: 'global.pbuilder.native', filter: '**/*.tgz')
} else {
copyArtifacts(projectName: 'global.pbuilder.cross', filter: '**/*.tgz')
}
}
def buildTarget(targetName) {
sh "bash -c 'source build/setup.sh; m prereqs ${targetName}; exit \$?'"
}
def archivePackage(boardName, packageName, repoType) {
def outPath = repoType
def repoName = ""
if (repoType == "core") {
repoName = "core"
} else if (repoType == "bsp") {
repoName = "bsp-${boardName}"
} else {
error 'Unknown repoType ${repoType}'
}
sh """
mkdir -p pool/${repoName}
cp src/out/target/product/*/packages/${outPath}/${packageName}_* pool/${repoName}
"""
archiveArtifacts(
artifacts: "pool/${repoName}/*",
fingerprint: true)
}
def buildPackagePipeline(boardName, repoType, packageName, needsNative = false) {
def workspacePath = "/home/jenkins/workspace"
def buildLabel = "build-${packageName}-${UUID.randomUUID().toString()}"
def sourcePath = "${workspacePath}/src"
// FIXME(jtgans): Get rid of privileged! This is a security risk!
def jnlpContainer = containerTemplate(name: 'jnlp',
image: 'jenkins/jnlp-slave:alpine')
def debianContainer = containerTemplate(name: 'debian',
image: 'debian:buster-slim',
command: 'cat',
ttyEnabled: true,
privileged: true)
podTemplate(label: buildLabel, containers: [jnlpContainer, debianContainer], envVars: []) {
node(buildLabel) {
dir(sourcePath) {
stage('Init') {
container('debian') {
initSourceTree(boardName, needsNative)
}
}
stage('Build') {
container('debian') {
buildTarget(packageName)
}
}
}
dir(workspacePath) {
stage('Deploy') {
archivePackage(boardName, packageName, repoType)
}
}
}
}
}