mirror of
https://github.com/falcosecurity/falco.git
synced 2025-09-01 22:58:12 +00:00
Add jenkins checks (#584)
* Supporting files to build/test via jenkins Changes to build/test via jenkins, which also means running all tests in a container instead of directly on the host: - Jenkinsfile controls the stages, build.sh does the build and run-tests.sh does the regression tests. - Create a new container falcosecurity/falco-tester that includes the dependencies required to run the regression tests. This is a different image than falco-builder because it doesn't need to be centos 6 based, doesn't install any compiler/etc, and installs the test running framework we use (avocado). We now use a newer version of avocado, which resulted in some small changes to how it is run and how yaml options are parsed. - Modify run_regression_tests.sh to download trace files to the build directory and only if not present. Also honor BUILD_TYPE/BUILD_DIR, which is provided via the docker run cmd. - The package tests are now moved to a separate falco_tests_package.yaml file. They will use rpm installs by default instead of debian packages. Also add the ability to install rpms in addition to debian packages. - Automate the process of creating the docker local package by: 1) Adding CMake rules to copy the Dockerfile, entrypoint to the build directory and 2) Copy test trace files and rules into the build directory. This allows running the docker build command from build/docker/local instead of the source directory. - Modify the way the container test is run a bit to use the trace files/rules copied into the container directly instead of host-mounted trace files. * Use container builder + tester for travis We'll probably be using jenkins soon, but this will allow switching back to travis later if we want. * Use download.draios.com for binutils packages That way we won't be dependent on snapshot.debian.org.
This commit is contained in:
71
scripts/jenkins/build-pipeline/Jenkinsfile
vendored
Normal file
71
scripts/jenkins/build-pipeline/Jenkinsfile
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
void setBuildStatus(String context, String message, String state) {
|
||||
step([
|
||||
$class: "GitHubCommitStatusSetter",
|
||||
reposSource: [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/falcosecurity/falco"],
|
||||
contextSource: [$class: "ManuallyEnteredCommitContextSource", context: context],
|
||||
errorHandlers: [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]],
|
||||
statusResultSource: [ $class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: state]] ]
|
||||
]);
|
||||
}
|
||||
|
||||
pipeline {
|
||||
agent { label "agent-docker-builder" }
|
||||
stages {
|
||||
stage("Check out dependencies") {
|
||||
steps {
|
||||
dir("falco") {
|
||||
checkout([$class: "GitSCM",
|
||||
branches: [[name: "refs/heads/"+env.BRANCH_NAME]],
|
||||
doGenerateSubmoduleConfigurations: false,
|
||||
extensions: [],
|
||||
submoduleCfg: [],
|
||||
userRemoteConfigs: [[credentialsId: "github-jenkins-user-token", url: "https://github.com/draios/falco"]]])
|
||||
}
|
||||
dir("sysdig") {
|
||||
checkout([$class: "GitSCM",
|
||||
branches: [[name: "dev"]],
|
||||
doGenerateSubmoduleConfigurations: false,
|
||||
extensions: [],
|
||||
submoduleCfg: [],
|
||||
userRemoteConfigs: [[credentialsId: "github-jenkins-user-token", url: "https://github.com/draios/sysdig"]]])
|
||||
}
|
||||
}
|
||||
}
|
||||
stage("Build") {
|
||||
steps {
|
||||
script{
|
||||
sh("./falco/scripts/jenkins/build-pipeline/build.sh")
|
||||
}
|
||||
}
|
||||
post {
|
||||
success {
|
||||
setBuildStatus("Build", "Build Successful", "SUCCESS")
|
||||
}
|
||||
failure {
|
||||
setBuildStatus("Build", "Build Failed", "FAILURE")
|
||||
}
|
||||
}
|
||||
}
|
||||
stage("Run tests") {
|
||||
steps {
|
||||
script{
|
||||
sh("./falco/scripts/jenkins/build-pipeline/run-tests.sh")
|
||||
}
|
||||
}
|
||||
post {
|
||||
success {
|
||||
setBuildStatus("Run tests", "All tests passed", "SUCCESS")
|
||||
}
|
||||
failure {
|
||||
setBuildStatus("Run tests", "One or more tests failed", "FAILURE")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
11
scripts/jenkins/build-pipeline/build.sh
Executable file
11
scripts/jenkins/build-pipeline/build.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -xeuo pipefail
|
||||
|
||||
export FALCO_VERSION=0.1.$((2700+BUILD_NUMBER))dev
|
||||
|
||||
rm -rf ${WORKSPACE}/build
|
||||
mkdir ${WORKSPACE}/build
|
||||
|
||||
docker run --user $(id -u):$(id -g) -v /etc/passwd:/etc/passwd:ro -e FALCO_VERSION=${FALCO_VERSION} -e MAKE_JOBS=4 -v ${WORKSPACE}:/source -v ${WORKSPACE}/build:/build falcosecurity/falco-builder cmake
|
||||
docker run --user $(id -u):$(id -g) -v /etc/passwd:/etc/passwd:ro -e FALCO_VERSION=${FALCO_VERSION} -e MAKE_JOBS=4 -v ${WORKSPACE}:/source -v ${WORKSPACE}/build:/build falcosecurity/falco-builder package
|
10
scripts/jenkins/build-pipeline/run-tests.sh
Executable file
10
scripts/jenkins/build-pipeline/run-tests.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -xeuo pipefail
|
||||
|
||||
export FALCO_VERSION=0.1.$((2700+BUILD_NUMBER))dev
|
||||
|
||||
docker pull falcosecurity/falco-tester
|
||||
docker run -v /boot:/boot:ro -v /var/run/docker.sock:/var/run/docker.sock -v /etc/passwd:/etc/passwd:ro -e FALCO_VERSION=${FALCO_VERSION} -v ${WORKSPACE}:/source -v ${WORKSPACE}/build:/build falcosecurity/falco-tester
|
||||
|
||||
exit 0
|
Reference in New Issue
Block a user