Skip to content

Commit

Permalink
Build and test base image
Browse files Browse the repository at this point in the history
- Use make if cmake not installed

Signed-off-by: Chris Yan <[email protected]>
  • Loading branch information
CyanDevs committed Oct 26, 2021
1 parent 1f5ba85 commit 97256fd
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ library "OpenEnclaveJenkinsLibrary@${params.OECI_LIB_VERSION}"

pipeline {
agent {
label globalvars.AGENTS_LABELS["ubuntu-nonsgx"]
label globalvars.AGENTS_LABELS["acc-ubuntu-18.04"]
}
options {
timeout(time: 240, unit: 'MINUTES')
}
parameters {
string(name: "SGX_VERSION", description: "Intel SGX version to install (Ex: 2.15.100). For versions see: https://download.01.org/intel-sgx/sgx_repo/ubuntu/apt_preference_files/")
string(name: "REPOSITORY_NAME", defaultValue: "openenclave/openenclave", description: "GitHub repository to checkout")
string(name: "BRANCH_NAME", defaultValue: "master", description: "The branch used to checkout the repository")
string(name: "DOCKER_TAG", defaultValue: "standalone-linux-build", description: "The tag for the new Docker images")
Expand All @@ -22,6 +23,7 @@ pipeline {
environment {
INTERNAL_REPO_CREDS = 'oejenkinscidockerregistry'
DOCKERHUB_REPO_CREDS = 'oeciteamdockerhub'
BASE_DOCKERFILE_DIR = ".jenkins/infrastructure/docker/dockerfiles/linux/base/"
LINUX_DOCKERFILE = ".jenkins/infrastructure/docker/dockerfiles/linux/Dockerfile"
}
stages {
Expand All @@ -34,27 +36,70 @@ pipeline {
userRemoteConfigs: [[url: "https://github.com/${params.REPOSITORY_NAME}"]]])
}
}
stage("Build") {
stage("Base Image") {
stages {
stage('Build Base') {
steps {
dir(env.BASE_DOCKERFILE_DIR) {
sh """
chmod +x ./build.sh
mkdir build
cd build
../build.sh -v "${params.SGX_VERSION}" -u "18.04" -t "${params.DOCKER_TAG}"
../build.sh -v "${params.SGX_VERSION}" -u "20.04" -t "${params.DOCKER_TAG}"
"""
}
}
}
stage('Test Base') {
parallel {
stage("Test Base - 18.04") {
steps {
script {
def image = docker.image("openenclave-bionic:${params.DOCKER_TAG}")
image.inside("--user root:root --cap-add=SYS_PTRACE --device /dev/sgx:/dev/sgx --volume /var/run/aesmd/aesm.socket:/var/run/aesmd/aesm.socket") {
sh """
apt update
apt install -y build-essential open-enclave libssl-dev
"""
helpers.TestSamplesCommand(false, "open-enclave")
}
}
}
}
stage("Test Base - 20.04") {
steps {
script {
def image = docker.image("openenclave-focal:${params.DOCKER_TAG}")
image.inside("--user root:root --cap-add=SYS_PTRACE --device /dev/sgx:/dev/sgx --volume /var/run/aesmd/aesm.socket:/var/run/aesmd/aesm.socket") {
sh """
apt update
apt install -y build-essential open-enclave libssl-dev
"""
helpers.TestSamplesCommand(false, "open-enclave")
}
}
}
}
}
}
}
}
stage("Full CI/CD Image") {
parallel {
stage("Build Ubuntu 18.04 Docker Image") {
steps {
script {
docker.withRegistry(params.INTERNAL_REPO, env.INTERNAL_REPO_CREDS) {
buildArgs = common.dockerBuildArgs("UID=\$(id -u)", "UNAME=\$(id -un)",
"GID=\$(id -g)", "GNAME=\$(id -gn)")
oe1804 = common.dockerImage("oetools-18.04:${params.DOCKER_TAG}", env.LINUX_DOCKERFILE, "${buildArgs} --build-arg ubuntu_version=18.04")
puboe1804 = common.dockerImage("oeciteam/oetools-18.04:${params.DOCKER_TAG}", env.LINUX_DOCKERFILE, "${buildArgs} --build-arg ubuntu_version=18.04")
}
oe1804 = common.dockerImage("oetools-18.04:${DOCKER_TAG}", LINUX_DOCKERFILE, "--build-arg ubuntu_version=18.04")
puboe1804 = common.dockerImage("oeciteam/oetools-18.04:${DOCKER_TAG}", LINUX_DOCKERFILE, "--build-arg ubuntu_version=18.04")
}
}
}
stage("Build Ubuntu 20.04 Docker Image") {
steps {
script {
buildArgs = common.dockerBuildArgs("UID=\$(id -u)", "UNAME=\$(id -un)",
"GID=\$(id -g)", "GNAME=\$(id -gn)")
oe2004 = common.dockerImage("oetools-20.04:${params.DOCKER_TAG}", env.LINUX_DOCKERFILE, "${buildArgs} --build-arg ubuntu_version=20.04")
puboe2004 = common.dockerImage("oeciteam/oetools-20.04:${params.DOCKER_TAG}", env.LINUX_DOCKERFILE, "${buildArgs} --build-arg ubuntu_version=20.04")
oe2004 = common.dockerImage("oetools-20.04:${DOCKER_TAG}",LINUX_DOCKERFILE, "--build-arg ubuntu_version=20.04")
puboe2004 = common.dockerImage("oeciteam/oetools-20.04:${DOCKER_TAG}", LINUX_DOCKERFILE, "--build-arg ubuntu_version=20.04")
}
}
}
Expand All @@ -77,11 +122,11 @@ pipeline {
stage("Push to OE Docker Hub Registry") {
steps {
script {
docker.withRegistry('', env.DOCKERHUB_REPO_CREDS) {
if(params.PUBLISH_DOCKER_HUB == "true") {
docker.withRegistry('', DOCKERHUB_REPO_CREDS) {
if(PUBLISH_DOCKER_HUB == "true") {
common.exec_with_retry { puboe1804.push() }
common.exec_with_retry { puboe2004.push() }
if(params.TAG_LATEST == "true") {
if(TAG_LATEST == "true") {
common.exec_with_retry { puboe1804.push('latest') }
common.exec_with_retry { puboe2004.push('latest') }
}
Expand All @@ -91,4 +136,13 @@ pipeline {
}
}
}
post {
always {
emailext(
subject: "Jenkins: ${env.JOB_NAME} [#${env.BUILD_NUMBER}] status is ${currentBuild.currentResult}",
body: "See build log for details: ${env.BUILD_URL}",
recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']]
)
}
}
}
38 changes: 30 additions & 8 deletions .jenkins/library/vars/helpers.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,37 @@ def testSamplesLinux(boolean lvi_mitigation, String oe_package) {
cp -r /opt/openenclave/share/openenclave/samples ~/
cd ~/samples
. /opt/openenclave/share/openenclave/openenclaverc
if hash cmake 2> /dev/null; then
echo "INFO: Using cmake to build"
export BUILD_SYSTEM=CMAKE
elif hash make 2> /dev/null; then
echo "INFO: Using make to build"
export BUILD_SYSTEM=MAKE
fi
if [[ -z \${BUILD_SYSTEM+x} ]]; then
echo "Error: cmake and make not found. Please install either one to proceed"
exit 1
fi
for i in *; do
if [[ -d \${i} ]] && [[ -f \${i}/CMakeLists.txt ]]; then
cd \${i}
mkdir build
cd build
cmake .. ${lvi_args}
make
make run
cd ~/samples
if [[ \${BUILD_SYSTEM} == "CMAKE" ]]; then
if [[ -d \${i} ]] && [[ -f \${i}/CMakeLists.txt ]]; then
cd \${i}
mkdir build
cd build
cmake .. ${lvi_args}
make
make run
cd ~/samples
fi
elif [[ \${BUILD_SYSTEM} == "MAKE" ]]; then
if [[ -d \${i} ]] && [[ -f \${i}/Makefile ]]; then
cd \${i}
make build
make run
fi
else
echo "Error: unrecognized build system. Either cmake or make must be installed."
exit 1
fi
done
cd ~
Expand Down

0 comments on commit 97256fd

Please sign in to comment.