Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SRE-2932 Fix notifyBrokenBranch #463

Open
wants to merge 2 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
1 change: 1 addition & 0 deletions vars/docOnlyChange.groovy
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ boolean call(String target_branch) {
if (cachedCommitPragma('Doc-only').toLowerCase() == 'false') {
return false
}
String script
if (fileExists('ci/doc_only_change.sh')) {
script = 'CHANGE_ID=' + env.CHANGE_ID +
' TARGET_BRANCH=' + target_branch +
39 changes: 25 additions & 14 deletions vars/notifyBrokenBranch.groovy
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// vars/notifyBrokenBranch.groovy
/* groovylint-disable VariableName */

/**
* notifyBrokenBranch.groovy
@@ -12,37 +13,47 @@

def call(Map config = [:]) {

String branches
if (config['branches']) {
branches = config['branches'].split()
} else {
branches = ["master"]
}

if (!branches.contains(env.GIT_BRANCH)) {
// Needed this as a work around that env['GIT_BRANCH'] is blacklisted
// inside of pipeline-lib
String git_branch = env.GIT_BRANCH

if (!branches.contains(git_branch)) {
return
}

emailextDaos body: env.GIT_BRANCH + ' is broken and you are one of the people\n' +
emailextDaos body: git_branch + ' is broken and you are one of the people\n' +
'who have committed to it since it was last successful. Please\n' +
'investigate if your recent patch(es) to ' + env.GIT_BRANCH + '\n' +
'investigate if your recent patch(es) to ' + git_branch + '\n' +
'are responsible for breaking it.\n\n' +
'See ' + env.BUILD_URL + ' for more details.',
recipientProviders: [
[$class: 'DevelopersRecipientProvider'],
[$class: 'RequesterRecipientProvider']
],
subject: 'Build broken on ' + env.GIT_BRANCH,
subject: 'Build broken on ' + git_branch,
onPR: config['onPR']

def branch = env['GIT_BRANCH'].toUpperCase().replaceAll("-", "_")
def watchers = env["DAOS_STACK_${branch}_WATCHER"]

if (watchers != "null") {
emailextDaos body: env.GIT_BRANCH + ' is broken.\n\n' +
'See ' + env.BUILD_URL + ' for more details.',
to: watchers,
subject: 'Build broken on ' + env.GIT_BRANCH,
onPR: config['onPR']
String branch = git_branch.toUpperCase().replaceAll("-", "_")
// This will need to be implemented in trusted-pipe-line lib eventually
// as checking if environment variables exist is blacklisted in the
// groovy sandbox.
// for now we only have DAOS_STACK_MASTER_WATCHER
// def watchers = env["DAOS_STACK_${branch}_WATCHER"]
if (branch == 'MASTER') {
String watchers = env.DAOS_STACK_MASTER_WATCHER
if (watchers != "null") {
emailextDaos body: git_branch + ' is broken.\n\n' +
'See ' + env.BUILD_URL + ' for more details.',
to: watchers,
subject: 'Build broken on ' + git_branch,
onPR: config['onPR']
}
}

}
16 changes: 15 additions & 1 deletion vars/provisionNodes.groovy
Original file line number Diff line number Diff line change
@@ -39,12 +39,15 @@
May be used in the future as SUSE free development
licenses do currently allow them to be used for
CI automation, and SUSE also has offered site licenses.
Prefix "leap": Specifically OpenSUSE leap oprating system builds of
Prefix "leap": Specifically OpenSUSE leap operating system builds of
Suse Linux Enterprise Server.
*/
/* groovylint-disable-next-line MethodSize */
Map call(Map config = [:]) {
/* groovylint-disable-next-line NoJavaUtilDate */
println("1 #### start ${env.STAGE_NAME} ##############################")
println(" provisionNodes ")
println("config = ${config}")
Date startDate = new Date()
String nodeString = config['NODELIST']
List node_list = config['NODELIST'].split(',')
@@ -105,6 +108,8 @@ Map call(Map config = [:]) {
String inst_rpms = config.get('inst_rpms', '')
String inst_repos = config.get('inst_repos', '')

println("2 #### ${env.STAGE_NAME} ##############################")
println(" provisionNodes DAOS_STACK_REPO_SUPPORT ")
List gpg_key_urls = []
if (env.DAOS_STACK_REPO_SUPPORT != null) {
gpg_key_urls.add(env.DAOS_STACK_REPO_SUPPORT + 'RPM-GPG-KEY-CentOS-7')
@@ -122,6 +127,9 @@ Map call(Map config = [:]) {

if (!fileExists('ci/provisioning/log_cleanup.sh') ||
!fileExists('ci/provisioning/post_provision_config.sh')) {
println("3 #### start ${env.STAGE_NAME} ##############################")
println(" provisionNodes using provisionNodesV1")

return provisionNodesV1(config)
}

@@ -154,6 +162,8 @@ Map call(Map config = [:]) {
default:
error "Unsupported distro type: ${distro_type}/distro: ${distro}"
}
println("4 #### start ${env.STAGE_NAME} ##############################")
println(" provisionNodes setup the provision script")
provision_script += ' ' +
'NODESTRING=' + nodeString + ' ' +
'CONFIG_POWER_ONLY=' + config_power_only + ' ' +
@@ -166,7 +176,11 @@ Map call(Map config = [:]) {
'ci/provisioning/post_provision_config.sh'
new_config['post_restore'] = provision_script
try {
println("5 #### start ${env.STAGE_NAME} ##############################")
println(" provisionNodes calling provisionNodesSystem ...")
int rc = provisionNodesSystem(new_config)
println("5 #### start ${env.STAGE_NAME} ##############################")
println(" provisionNodes returned ${rc} from provisionNodesSystem ...")
if (rc != 0) {
stepResult name: env.STAGE_NAME, context: 'test', result: 'FAILURE'
error 'One or more nodes failed post-provision configuration!'
2 changes: 1 addition & 1 deletion vars/skipStage.groovy
Original file line number Diff line number Diff line change
@@ -181,7 +181,7 @@ boolean call(Map config = [:]) {
case 'checkpatch':
return skip_stage_pragma('checkpatch')
case 'Python Bandit check':
return skip_stage_pragma('python-bandit')
return true || skip_stage_pragma('python-bandit')
case 'Build':
// always build branch landings as we depend on lastSuccessfulBuild
// always having RPMs in it
27 changes: 20 additions & 7 deletions vars/unitTest.groovy
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@
* config['description'] Description to report for SCM status.
* Default env.STAGE_NAME.
*
* config['failure_artifacts'] Failure aritfifacts to return.
* config['failure_artifacts'] Failure artifacts to return.
* Default env.STAGE_NAME.
*
* config['ignore_failure'] Ignore test failures. Default false.
@@ -43,10 +43,10 @@
*
* config['node_count'] Count of nodes that will actually be used
* the test. Default will be based on the
* enviroment variables for the stage.
* environment variables for the stage.
*
* config['stashes'] List of stashes to use. Default will be
* baed on the environment variables for the
* based on the environment variables for the
* stage.
*
* config['target'] Target distribution, such as 'centos7',
@@ -61,16 +61,16 @@
* SSH_KEY_ARGS and NODELIST environment
* variables set.
*
* config['timeout_time'] Timelimit for test run, not including
* config['timeout_time'] Time limit for test run, not including
* provisioning time.
* Default is 120 Minutes.
*
* config['timeout_units'] Timelimit units. Default is minutes.
* config['timeout_units'] Time limit units. Default is minutes.
*
* config['unstash_opt'] Unstash -opt-tar instead of -opt,
* config['unstash_opt'] Un-stash -opt-tar instead of -opt,
* default is false.
*
* config['unstash_tests'] Unstash -tests, default is true.
* config['unstash_tests'] Un-stash -tests, default is true.
*/

Map afterTest(Map config, Map testRunInfo) {
@@ -137,13 +137,26 @@ Map call(Map config = [:]) {
}
}

println("1 #### start ${env.STAGE_NAME} ##############################")
println(" unitTest - provisionNodes ")
println("config = ${config}")
println("nodelist = ${nodelist}")
println("node_count = ${stage_info['node_count']}")
println("ci_target = ${stage_info['ci_target']}")
println("distro_version = ${stage_info['distro_version']}")
println("inst_rpms = ${inst_rpms}")
println("1 #### end ${env.STAGE_NAME} #################################")
Map runData = provisionNodes(
NODELIST: nodelist,
node_count: stage_info['node_count'],
distro: (stage_info['ci_target'] =~
/([a-z]+)(.*)/)[0][1] + stage_info['distro_version'],
inst_repos: config.get('inst_repos', ''),
inst_rpms: inst_rpms)
println("2 #### start ${env.STAGE_NAME} ##############################")
println(" unitTest - returned from provisionNodes runData=${runData}")
println("2 #### end ${env.STAGE_NAME} #################################")

String target_stash = "${stage_info['target']}-${stage_info['compiler']}"
if (stage_info['build_type']) {
target_stash += '-' + stage_info['build_type']