Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

[WIP] Add DCO check step to jenkins #1912

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
208 changes: 6 additions & 202 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if (shouldPublish()) {
def docker_image_dind = 'docker:18.06.0-ce-dind'
def docker_image = 'docker:18.06.0-ce'
def build_image = 'pegasyseng/pantheon-build:0.0.7-jdk11'
def python_image = 'edjojob/lftools'

def abortPreviousBuilds() {
Run previousBuild = currentBuild.rawBuild.getPreviousBuildInProgress()
Expand All @@ -54,210 +55,13 @@ if (!shouldPublish()) {

try {
timeout(time: 1, unit: 'HOURS') {
parallel UnitTests: {
def stage_name = "Unit tests node: "
parallel DCOCheck: {
def stage_name = "DCO tests node: "
node {
checkout scm
docker.image(docker_image_dind).withRun('--privileged') { d ->
docker.image(build_image).inside("--link ${d.id}:docker") {
try {
stage(stage_name + 'Prepare') {
sh './gradlew --no-daemon --parallel clean compileJava compileTestJava assemble'
}
stage(stage_name + 'Unit tests') {
sh './gradlew --no-daemon --parallel build'
}
} finally {
archiveArtifacts '**/build/reports/**'
archiveArtifacts '**/build/test-results/**'
archiveArtifacts 'build/reports/**'
archiveArtifacts 'build/distributions/**'

stash allowEmpty: true, includes: 'build/distributions/pantheon-*.tar.gz', name: 'distTarBall'

junit '**/build/test-results/**/*.xml'
}
}
}
}
}, ReferenceTests: {
def stage_name = "Reference tests node: "
node {
checkout scm
docker.image(docker_image_dind).withRun('--privileged') { d ->
docker.image(build_image).inside("--link ${d.id}:docker") {
try {
stage(stage_name + 'Prepare') {
sh './gradlew --no-daemon --parallel clean compileJava compileTestJava assemble'
}
stage(stage_name + 'Reference tests') {
sh './gradlew --no-daemon --parallel referenceTest'
}
} finally {
archiveArtifacts '**/build/reports/**'
archiveArtifacts '**/build/test-results/**'
archiveArtifacts 'build/reports/**'
archiveArtifacts 'build/distributions/**'

junit '**/build/test-results/**/*.xml'
}
}
}
}
}, IntegrationTests: {
def stage_name = "Integration tests node: "
node {
checkout scm
docker.image(docker_image_dind).withRun('--privileged') { d ->
docker.image(build_image).inside("--link ${d.id}:docker") {
try {
stage(stage_name + 'Prepare') {
sh './gradlew --no-daemon --parallel clean compileJava compileTestJava assemble'
}
stage(stage_name + 'Integration Tests') {
sh './gradlew --no-daemon --parallel integrationTest'
}
stage(stage_name + 'Check Licenses') {
sh './gradlew --no-daemon --parallel checkLicenses'
}
stage(stage_name + 'Check javadoc') {
sh './gradlew --no-daemon --parallel javadoc'
}
stage(stage_name + 'Compile Benchmarks') {
sh './gradlew --no-daemon --parallel compileJmh'
}
} finally {
archiveArtifacts '**/build/reports/**'
archiveArtifacts '**/build/test-results/**'
archiveArtifacts 'build/reports/**'
archiveArtifacts 'build/distributions/**'

junit '**/build/test-results/**/*.xml'
}
}
}
}
}, AcceptanceTests: {
def stage_name = "Acceptance tests node: "
node {
checkout scm
docker.image(docker_image_dind).withRun('--privileged') { d ->
docker.image(build_image).inside("--link ${d.id}:docker") {
try {
stage(stage_name + 'Prepare') {
sh './gradlew --no-daemon --parallel clean compileJava compileTestJava assemble'
}
stage(stage_name + 'Acceptance Tests') {
sh './gradlew --no-daemon --parallel acceptanceTest'
}
} finally {
archiveArtifacts '**/build/reports/**'
archiveArtifacts '**/build/test-results/**'
archiveArtifacts 'build/reports/**'
archiveArtifacts 'build/distributions/**'

junit '**/build/test-results/**/*.xml'
}
}
}
}
}

parallel DockerImage: {
def stage_name = 'Docker image node: '
def docker_folder = 'docker'
def reports_folder = docker_folder + '/reports'
def dockerfile = docker_folder + '/Dockerfile'
def version = ''
def image = ''
node {
checkout scm
docker.image(build_image).inside() {
stage(stage_name + 'Dockerfile lint') {
sh "docker run --rm -i hadolint/hadolint < ${dockerfile}"
}

stage(stage_name + 'Build image') {
sh './gradlew distDocker'
}

stage(stage_name + 'Calculate variables') {
def gradleProperties = readProperties file: 'gradle.properties'
version = gradleProperties.version
def imageRepos = 'pegasyseng'
image = "${imageRepos}/pantheon:${version}"
}

stage(stage_name + "Test image labels") {
shortCommit = sh(returnStdout: true, script: "git log -n 1 --pretty=format:'%h'").trim()
sh "docker image inspect \
--format='{{index .Config.Labels \"org.label-schema.vcs-ref\"}}' \
${image} \
| grep ${shortCommit}"
sh "docker image inspect \
--format='{{index .Config.Labels \"org.label-schema.version\"}}' \
${image} \
| grep ${version}"
}

try {
stage(stage_name + 'Test image') {
sh "mkdir -p ${reports_folder}"
sh "cd ${docker_folder} && bash test.sh ${image}"
}
} finally {
junit "${reports_folder}/*.xml"
sh "rm -rf ${reports_folder}"
}

if (shouldPublish()) {
def registry = 'https://registry.hub.docker.com'
def userAccount = 'dockerhub-pegasysengci'
stage(stage_name + 'Push image') {
docker.withRegistry(registry, userAccount) {
docker.image(image).push()

def additionalTags = []
if (env.BRANCH_NAME == 'master') {
additionalTags.add('develop')
}

if (! version ==~ /.*-SNAPSHOT/) {
additionalTags.add('latest')
additionalTags.add(version.split(/\./)[0..1].join('.'))
}

additionalTags.each { tag ->
docker.image(image).push tag.trim()
}
}
}
}
}
}
}, BintrayPublish: {
def stage_name = "Bintray publish node: "
node {
if (shouldPublish()) {
checkout scm

docker.image(docker_image_dind).withRun('--privileged') { d ->
docker.image(build_image).inside("--link ${d.id}:docker") {
stage(stage_name + 'Prepare') {
sh './gradlew --no-daemon --parallel clean assemble'
}
stage(stage_name + 'Publish') {
withCredentials([
usernamePassword(
credentialsId: 'pegasys-bintray',
usernameVariable: 'BINTRAY_USER',
passwordVariable: 'BINTRAY_KEY'
)
]) {
sh './gradlew --no-daemon --parallel bintrayUpload'
}
}
}
docker.image(python_image).inside() {
stage(stage_name + 'Check') {
lftools dco check
}
}
}
Expand Down