blob: b5cc6bbf468482f03148e2f5c521bedb4cb41ef8 [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 python3 python3-pip
curl https://storage.googleapis.com/git-repo-downloads/repo > /usr/local/bin/repo
chmod a+x /usr/local/bin/repo
git clone https://gerrit.googlesource.com/gcompute-tools /tmp/gcompute-tools
/tmp/gcompute-tools/git-cookie-authdaemon
pip3 install aptly-ctl==0.9
git config --global url.https://aiyprojects.googlesource.com/.insteadOf sso://aiyprojects/
mkdir -p .repo/local_manifests
mkdir -p cache
chmod 777 cache .repo/local_manifests
"""
timeout(time: 20, unit: 'MINUTES') {
checkout([$class: 'RepoScm',
currentBranch: true,
jobs: 24,
manifestRepositoryUrl: 'http://coral.googlesource.com/manifest',
manifestBranch: 'master',
manifestFile: "${boardName}.xml",
manifestGroup: "default,internal",
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.arm64', filter: '**/*.tgz')
copyArtifacts(projectName: 'global.pbuilder.armhf', 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 nameFromRepoType(repoType, boardName) {
if (repoType == "core") {
return "core"
} else if (repoType == "bsp") {
return "bsp-${boardName}"
} else {
error 'Unknown repoType ${repoType}'
}
}
def uploadAllGeneratedPackages(repoType, boardName) {
def outPath = repoType
def repoName = nameFromRepoType(repoType, boardName)
sh """
aptly-ctl -C url=http://aptly-api/api \
-C signing.gpgkey=none \
-C signing.passphrase=none \
put unstable-${repoName} src/out/target/product/*/packages/${outPath}/*
"""
}
def buildPackagePipeline(boardName, repoType, packageName, needsNative = false) {
def workspacePath = "/home/jenkins/workspace"
def buildLabel = "${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',
args: '',
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') {
uploadAllGeneratedPackages(repoType, boardName)
}
}
}
}
}