diff --git a/Jenkinsfile b/Jenkinsfile index 13eea5e..0476b36 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ properties( $class: 'ActiveMQSubscriberProviderData', name: 'Red Hat UMB', overrides: [topic: 'Consumer.rh-jenkins-ci-plugin.f88e907e-04c5-11e9-8eb2-f2801f1b9fd1.VirtualTopic.eng.brew.>'], - selector: 'name = \'ansible\' AND type = \'Tag\' AND tag LIKE \'ansible-%-rhel-7-candidate\'', + selector: 'name = \'ansible\' AND type = \'Tag\' AND tag LIKE \'ansible-%-rhel-%-candidate\'', timeout: null ] ] @@ -31,7 +31,7 @@ properties( name: 'LIBRARIES_REPO' ), string( - defaultValue: 'v1.2.1', + defaultValue: 'v1.2.2', description: 'Git reference to the branch or tag of shared libraries.', name: 'LIBRARIES_REF' ), @@ -60,6 +60,16 @@ properties( description: 'Build task ID for which to run the pipeline', name: 'TASK_ID' ), + string( + defaultValue: 'RHEL-ALT-7.5', + description: 'RHEL 7 distribution.', + name: 'RHEL7_DISTRO' + ), + string( + defaultValue: 'RHEL-8.0.0-20190129.1', + description: 'RHEL 8 distribution.', + name: 'RHEL8_DISTRO' + ), string( defaultValue: 'jpoulin; mclay', description: 'Semi-colon delimited list of email notification recipients.', @@ -76,15 +86,82 @@ library( retriever: modernSCM([$class: 'GitSCMSource',remote: "${params.LIBRARIES_REPO}"]) ) -List arches = params.ARCHES.tokenize(',') +// MACIT configuration def errorMessages = '' def config = MAQEAPI.v1.getProvisioningConfig(this) config.installRhpkg = true -config.mode = 'JNLP' -MAQEAPI.v1.runParallelMultiArchTest( +// Get build information +Map message = [:] +String taskId = '' +String nvr = '' + +// Required host information +List arches = params.ARCHES.tokenize(',') +String os = '' +String distro = '' +String variant = '' + +// Lookup the build information +MAQEAPI.v1.testWrapper(this, config) { + node ("provisioner-${config.version}"){ + // Message + message = getCIMessage(params.CI_MESSAGE) + + // Task ID + taskId = message && message.build && message.build.task_id ?: params.TASK_ID + if (!taskId) { + error("Invalid brew task ID for CI_MESSAGE: ${params.CI_MESSAGE} and TASK_ID: ${params.TASK_ID}.") + } + + // NVR + nvr = sh(script:"brew taskinfo ${taskId} | grep 'Build:' | cut -d' ' -f2", returnStdout:true) + if (!nvr) { + error("Invalid nvr: ${nvr}.") + } + + // OS + os = sh( + script: """ + brew buildinfo \ + \$(brew taskinfo ${taskId} | grep 'Build:' | cut -d '(' -f 2 | cut -d ')' -f 1) | \ + grep 'Volume:' | cut -d ' ' -f 2 + """, + returnStdout: true + ).trim() + if (!os || !(['rhel-7', 'rhel-8'].contains(os))) { + error("Invalid OS version: ${os}.") + } + + // Distro + distro = (os == 'rhel-8') ? params.RHEL8_DISTRO : params.RHEL7_DISTRO + if (!distro) { + error("Invalid distro: ${distro}.") + } + + // Variant + variant = (os == 'rhel-8') ? 'BaseOS' : 'Server' + if (!variant) { + error("Invalid variant: ${variant}.") + } + } +} + +def targetHosts = [] +for (String arch in arches) { + def targetHost = MAQEAPI.v1.newTargetHost() + targetHost.arch = arch + targetHost.distro = distro + targetHost.variant = variant + if (os == 'rhel-8') { + targetHost.inventoryVars = [ ansible_python_interpreter:'/usr/libexec/platform-python' ] + } + targetHosts.push(targetHost) +} + +MAQEAPI.v1.runTest( this, - arches, + targetHosts, config, { host -> /*********************************************************/ @@ -101,20 +178,12 @@ MAQEAPI.v1.runParallelMultiArchTest( runTests(config, host) } - stage ('Archive Test Output') { - archiveOutput() - } - /*****************************************************************/ /* END TEST BODY */ /* Do not edit beyond this point */ /*****************************************************************/ }, { Exception exception, def host -> - stage ('Archive Failed Test Output') { - archiveOutput() - } - def error = "Exception ${exception} occured on ${host.arch}\n" errorMessages += error if (host.arch.equals("x86_64") || host.arch.equals("ppc64le")) { @@ -129,26 +198,11 @@ MAQEAPI.v1.runParallelMultiArchTest( errorMessages += "Exception ${e} occured while unarchiving artifacts\n" } - String nvr = '' - if (params.CI_MESSAGE) { - final String CI_MESSAGE_FILE = 'message.json' - writeFile(file:CI_MESSAGE_FILE, text:params.CI_MESSAGE) - Map json = readJSON(file:CI_MESSAGE_FILE) - nvr = json['build'].nvr - } else { - sh(''' - yum install -y yum-utils; - yum-config-manager --add-repo http://download.devel.redhat.com/rel-eng/RCMTOOLS/rcm-tools-rhel-7-server.repo; - yum install -y koji brewkoji - ''') - nvr = sh(script:"brew taskinfo ${params.TASK_ID} | grep 'Build:' | cut -d' ' -f2", returnStdout:true) - } - def emailBody = "Results for ${env.JOB_NAME} - Build #${currentBuild.number}\n\nResult: ${currentBuild.currentResult}\nNVR: ${nvr}\nURL: $BUILD_URL" if (errorMessages) emailBody += "\nErrors: " + errorMessages emailext( - subject: "${env.JOB_NAME} (#${currentBuild.number}) - ${nvr ? nvr + ' - ': ''}${currentBuild.currentResult}", + subject: "${nvr ? nvr + ' - ': ''}${currentBuild.currentResult} - ${env.JOB_NAME} (#${currentBuild.number})", body: emailBody, from: 'multiarch-qe-jenkins', replyTo: 'multiarch-qe', diff --git a/tests/scripts/example-test/test.sh b/tests/scripts/example-test/test.sh deleted file mode 100644 index 9b42239..0000000 --- a/tests/scripts/example-test/test.sh +++ /dev/null @@ -1 +0,0 @@ -echo "This is a shell script test" diff --git a/tests/scripts/example-test2/test.sh b/tests/scripts/example-test2/test.sh deleted file mode 100644 index 95290cf..0000000 --- a/tests/scripts/example-test2/test.sh +++ /dev/null @@ -1 +0,0 @@ -echo "This test should run too" diff --git a/tests/scripts/rhel-system-roles/test.sh b/tests/scripts/rhel-system-roles/test.sh index 777f93a..31586cc 100644 --- a/tests/scripts/rhel-system-roles/test.sh +++ b/tests/scripts/rhel-system-roles/test.sh @@ -2,19 +2,14 @@ # # Attempts to clone down the test package and run it -# Ensure Ansible gets installed from task repo -sudo yum remove ansible -y -sudo yum install ansible -y --disablerepo epel -sudo yum-config-manager --save --setopt epel.exclude=ansible* - cd "$(dirname ${BASH_SOURCE[0]})" workdir=$(pwd) rhpkg --verbose --user=jenkins clone tests/rhel-system-roles cd rhel-system-roles git checkout CoreOS-rhel-system-roles-Sanity-Upstream-testsuite-multiarch-ci-1_1-1 cd Sanity/Upstream-testsuite-multiarch-ci -output_dir="$workdir/artifacts/rhel-system-roles" -output_file="$output_dir/$(arch).txt" +output_dir="$workdir/artifacts/rhel-system-roles/results" +output_file="$output_dir/$(arch)-test-output.txt" mkdir -p $output_dir sudo make &> $output_file run grep "OVERALL RESULT" $output_file | grep "PASS"