Skip to content
Open
45 changes: 32 additions & 13 deletions vars/buildRpmPost.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,19 @@
*
* config['rpmlint'] Whether to run rpmlint on resulting RPMs.
* Default false.
*
* config['new_rpm'] Whether we are using new RPM or not
* Default false
* Default false.
* Deprecated, use config['productNames'] instead.
*
* config['productNames'] List of product names and artifact directories to publish.
* Default is to publish the whole target directory.
*
* config['unsuccessful_script'] Script to run if build is not successful.
* Default 'ci/rpm/build_unsuccessful.sh'
*/

/* groovylint-disable-next-line MethodSize */
void call(Map config = [:]) {
Map stage_info = parseStageInfo(config)

Expand Down Expand Up @@ -89,24 +95,37 @@ void call(Map config = [:]) {
includes: rpm_version_file
}

List<String> productNames = config.get('productNames', [])
// Backwards compatibility for new_rpm parameter.
if (!productNames && config.get('new_rpm', false)) {
productNames = ['daos', 'deps']
}

String product = config.get('product', 'daos-stack')
String artdir = 'artifacts/' + target
if (config.get('new_rpm', false)) {
String deps_dir = 'artifacts/' + target + '/deps'
if (fileExists(deps_dir)) {
publishToRepository product: 'deps',
Map<String, String> productArtifacts = [:]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So config['productArtifacts'] is a list but we are also defining this local variable of the same name, but it is a map?
Should we change config['productArtifacts'] -> config['productNames'] so productArtifacts is not overloaded?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 206dda9

for (String name : productNames) {
if (name == 'daos') {
// Use the product name for daos
productArtifacts[product] = "artifacts/${target}/${name}"
} else {
// Use the specified name or other products, e.g. deps
productArtifacts[name] = "artifacts/${target}/${name}"
}
}
if (!productArtifacts) {
// Publish the whole target directory if no productArtifacts are specified
productArtifacts[product] = "artifacts/${target}"
}
for (String key in productArtifacts.keySet()) {
String artifactDir = productArtifacts[key]
if (fileExists(artifactDir)) {
publishToRepository product: key,
format: repo_format,
maturity: 'stable',
tech: target,
repo_dir: deps_dir
repo_dir: artifactDir
}
artdir = 'artifacts/' + target + '/daos'
}
publishToRepository product: product,
format: repo_format,
maturity: 'stable',
tech: target,
repo_dir: artdir

if (config.get('rpmlint', false)) {
rpmlintMockResults(sh(label: 'Get chroot name',
Expand Down
12 changes: 11 additions & 1 deletion vars/functionalTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,21 @@
*
* config['ftest_arg'] Functional test launch.py arguments.
* Default determined by parseStageInfo().
*
* config['coverage_stash'] Name to stash coverage artifacts.
* Default is empty string, which will result in no stashing.
*
* config['bullseye'] Set to true to use bullseye-sepecific repo.
* Default false.
*/

Map call(Map config = [:]) {
long startDate = System.currentTimeMillis()
String nodelist = config.get('NODELIST', env.NODELIST)
String context = config.get('context', 'test/' + env.STAGE_NAME)
String description = config.get('description', env.STAGE_NAME)
String coverage_stash = config.get('coverage_stash', '')
Boolean bullseye = config.get('bullseye', false)

Map stage_info = parseStageInfo(config)

Expand Down Expand Up @@ -93,7 +101,8 @@ Map call(Map config = [:]) {
node_count: stage_info['node_count'],
distro: image_version,
inst_repos: config.get('inst_repos', ''),
inst_rpms: stage_inst_rpms)
inst_rpms: stage_inst_rpms,
bullseye: bullseye)

List stashes = []
if (config['stashes']) {
Expand All @@ -113,6 +122,7 @@ Map call(Map config = [:]) {
run_test_config['ftest_arg'] = config.get('ftest_arg', stage_info['ftest_arg'])
run_test_config['context'] = context
run_test_config['description'] = description
run_test_config['coverage_stash'] = coverage_stash

Map runtestData = [:]
if (config.get('test_function', 'runTestFunctional') ==
Expand Down
13 changes: 11 additions & 2 deletions vars/getFunctionalTestStage.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
* '.el9', '.suse.lp156', etc. If not specified, it will be determined by
* rpmDistValue(distro)
* base_branch if specified, checkout sources from this branch before running tests
* inst_rpms space-separated string of RPM packages to install on the test nodes;
* exclusive of next_version, rpm_distro, and other_packages.
* other_packages space-separated string of additional RPM packages to install
* bullseye whether or not to use the bullseye-sepecific repo for provisioning
* node_count number of nodes to provision and use for the stage; overrides the count
* that would otherwise be inferred from the stage name by parseStageInfo()
* runStage whether or not to run the stage; overrides skipFunctionalTestStage()
* run_if_pr whether or not the stage should run for PR builds
* run_if_landing whether or not the stage should run for landing builds
* job_status Map of status for each stage in the job/build
* coverage_stash name of stash to include code coverage results from the tests
* @return a scripted stage to run in a pipeline
*/
/* groovylint-disable-next-line MethodSize */
Expand All @@ -48,7 +52,9 @@ Map call(Map kwargs = [:]) {
String image_version = kwargs.get('image_version', null)
String rpm_distro = kwargs.get('rpm_distro', null)
String base_branch = kwargs.get('base_branch')
String inst_rpms = kwargs.get('inst_rpms', null)
String other_packages = kwargs.get('other_packages', '')
Boolean bullseye = kwargs.get('bullseye', false)
Integer node_count = kwargs.get('node_count') as Integer
Boolean run_if_pr = kwargs.get('run_if_pr', false)
Boolean run_if_landing = kwargs.get('run_if_landing', false)
Expand All @@ -61,6 +67,7 @@ Map call(Map kwargs = [:]) {
String runStage = kwargs.get('runStage', 'undefined')

Map job_status = kwargs.get('job_status', [:])
String coverage_stash = kwargs.get('coverage_stash', '')

if (!name) {
error("getFunctionalTestStage() requires a stage 'name' argument")
Expand Down Expand Up @@ -113,7 +120,7 @@ Map call(Map kwargs = [:]) {
Map ftestConfig = [
image_version: image_version,
inst_repos: daosRepos(distro),
inst_rpms: functionalPackages(
inst_rpms: inst_rpms ?: functionalPackages(
clientVersion: 1,
nextVersion: next_version,
addDaosPkgs: 'tests-internal',
Expand All @@ -124,7 +131,9 @@ Map call(Map kwargs = [:]) {
nvme: nvme,
default_nvme: default_nvme,
provider: provider)['ftest_arg'],
test_function: 'runTestFunctionalV2']
test_function: 'runTestFunctionalV2',
bullseye: bullseye,
coverage_stash: coverage_stash]
if (node_count != null) {
ftestConfig['node_count'] = node_count
}
Expand Down
3 changes: 3 additions & 0 deletions vars/provisionNodes.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
* config['timeout'] Timeout in minutes. Default 30.
* config['inst_repos'] DAOS stack repos that should be configured.
* config['inst_rpms'] DAOS stack RPMs that should be installed.
* config['bullseye'] Set to true to use bullseye-specific repo. Default false.
*
* if timeout is <= 0, then will not wait for provisioning.
* if power_only is specified, the nodes will be rebooted and the
* provisioning information ignored.
Expand Down Expand Up @@ -175,6 +177,7 @@ Map call(Map config = [:]) {
// https://issues.jenkins.io/browse/JENKINS-55819
'CI_RPM_TEST_VERSION="' + (params.CI_RPM_TEST_VERSION ?: '') + '" ' +
'CI_PR_REPOS="' + (params.CI_PR_REPOS ?: '') + '" ' +
'CI_BULLSEYE="' + (config.get('bullseye', false) ? 'true' : 'false') + '" ' +
((env.DAOS_HTTPS_PROXY ?: env.HTTPS_PROXY) ?
'HTTPS_PROXY="' + (env.DAOS_HTTPS_PROXY ?: env.HTTPS_PROXY) + '" ' : '') +
'ci/provisioning/post_provision_config.sh'
Expand Down
20 changes: 12 additions & 8 deletions vars/runTestFunctionalV2.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,18 @@ Map call(Map config = [:]) {
// Restore the ignore failure setting
config['ignore_failure'] = ignore_failure

String coverageFile = 'test.cov'
if (!fileExists('test.cov')) {
coverageFile += '_not_done'
fileOperations([fileCreateOperation(fileName: coverageFile,
fileContent: '')])
// Stash code coverage file if it exists
String coverage_stash = config.get('coverage_stash', '')
if (coverage_stash) {
try {
stash name: coverage_stash, includes: '**/test.cov'
println("[${env.STAGE_NAME}] Stashed code coverage file in ${coverage_stash}")
} catch (hudson.AbortException e) {
println(
"[${env.STAGE_NAME}] Failed to stash code coverage file in ${coverage_stash}: " +
"${e.message}")
}
}
String name = 'func' + stage_info['pragma_suffix'] + '-cov'
stash name: config.get('coverage_stash', name),
includes: coverageFile

return runData
}
86 changes: 86 additions & 0 deletions vars/scriptedDockerStage.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/* groovylint-disable NestedBlockDepth */
// vars/scriptedDockerStage.groovy

import org.jenkinsci.plugins.pipeline.modeldefinition.Utils

/**
* scriptedDockerStage
*
* Get a docker stage in scripted syntax.
*
* @param kwargs Map containing the following optional arguments (empty strings yield defaults):
* name the docker stage name
* runStage optional additional condition to determine if the stage runs
* jobStatus Map of status for each stage in the job/build
* dockerTag the docker image tag to use for the build
* dockerBuildArgs optional docker build arguments
* stepMethod method to call to run the stage
* archiveArtifactsArgs optional arguments to pass to archiveArtifacts()
* @return a scripted stage to run in a pipeline
*/
/* groovylint-disable-next-line MethodSize */
Map call(Map kwargs = [:]) {
String name = kwargs.get('name', null)
Boolean runStage = kwargs.get('runStage', true)
Map jobStatus = kwargs.get('jobStatus', null) ?: [:]
String dockerTag = kwargs.get('dockerTag', null)
String dockerBuildArgs = kwargs.get('dockerBuildArgs', '')
Closure stepMethod = kwargs.get('stepMethod')
Map archiveArtifactsArgs = kwargs.get('archiveArtifactsArgs', null) ?: [:]

if (!name) {
error("scriptedDockerStage() requires a stage 'name' argument")
}
if (!dockerTag) {
error("scriptedDockerStage() requires a 'dockerTag' argument")
}

return {
stage("${name}") {
if (!runStage) {
println("[${name}] Marking docker stage as skipped")
Utils.markStageSkippedForConditional("${name}")
return
}
node('docker_runner') {
println("[${name}] Check out from version control")
checkoutScm(pruneStaleBranch: true)

Throwable tryError = null
/* groovylint-disable-next-line NoDef, VariableTypeRequired */
def dockerImage = docker.build(dockerTag, dockerBuildArgs)
try {
dockerImage.inside {
println("[${name}] Running stepMethod: ${stepMethod?.getClass()?.name}")
jobStatusUpdate(jobStatus, name, stepMethod.call())
}
/* groovylint-disable-next-line CatchException */
} catch (Exception e) {
tryError = e
println("[${name}] Caught exception in try: ${tryError}")
jobStatusUpdate(jobStatus, name, 'FAILURE')
throw tryError
} finally {
// Cleanup actions
try {
if (archiveArtifactsArgs) {
println("[${name}] Running archiveArtifacts()")
archiveArtifacts(archiveArtifactsArgs)
}
jobStatusUpdate(jobStatus, name)
/* groovylint-disable-next-line CatchException */
} catch (Exception finallyError) {
println("[${name}] Caught exception in finally: ${finallyError}")
/* groovylint-disable-next-line DuplicateStringLiteral */
jobStatusUpdate(jobStatus, name, 'FAILURE')
if (tryError == null) {
/* groovylint-disable-next-line ThrowExceptionFromFinallyBlock */
throw finallyError
}
}
}
}
println("[${name}] Finished with ${jobStatus}")
}
}
}
Loading