Skip to content

Commit

Permalink
sendMessage: add nvr param
Browse files Browse the repository at this point in the history
Related: OSCI-6166

Signed-off-by: Michal Srb <[email protected]>
  • Loading branch information
msrb committed Jan 23, 2024
1 parent 8309f3e commit 6c4a270
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 24 deletions.
2 changes: 2 additions & 0 deletions docs/steps/sendMessage.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ This step requires the [JMS Messaging plugin](https://wiki.jenkins.io/display/JE
* **testType**: string; (optional) test type (e.g.: "tier0")
* **testResult**: string; (optional) test result (e.g.: "passed", "needs_inspection")
* **testProfile**: string: (optional) name of the test profile
* **nvr**: string: (optional) Report results for this NVR, instead of the artifact Id


## Example Usage

Expand Down
28 changes: 16 additions & 12 deletions src/org/fedoraproject/jenkins/messages/MessageBuilder.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ def buildMessageQueued(
String runLog,
String scenario,
String testType,
String testProfile
String testProfile,
String nvr
) {
def msg

if (artifactType in ['koji-build', 'brew-build']) {
msg = new RpmBuildMessageBuilder().buildMessageQueued(
artifactType, taskId, pipelineMetadata, scenario, testType, testProfile
artifactType, taskId, pipelineMetadata, scenario, testType, testProfile, nvr
)
} else if (artifactType == 'fedora-dist-git') {
msg = new PullRequestMessageBuilder().buildMessageQueued(
Expand All @@ -56,7 +57,7 @@ def buildMessageQueued(
)
} else if (artifactType == 'redhat-module') {
msg = new ModuleMessageBuilder().buildMessageQueued(
artifactType, taskId, pipelineMetadata, scenario, testType, testProfile
artifactType, taskId, pipelineMetadata, scenario, testType, testProfile, nvr
)
} else if (artifactType == 'fedora-update') {
msg = new FedoraUpdateMessageBuilder().buildMessageQueued(
Expand Down Expand Up @@ -93,13 +94,14 @@ def buildMessageRunning(
String runLog,
String scenario,
String testType,
String testProfile
String testProfile,
String nvr
) {
def msg

if (artifactType in ['koji-build', 'brew-build']) {
msg = new RpmBuildMessageBuilder().buildMessageRunning(
artifactType, taskId, pipelineMetadata, scenario, testType, testProfile
artifactType, taskId, pipelineMetadata, scenario, testType, testProfile, nvr
)
} else if (artifactType == 'fedora-dist-git') {
msg = new PullRequestMessageBuilder().buildMessageRunning(
Expand All @@ -111,7 +113,7 @@ def buildMessageRunning(
)
} else if (artifactType == 'redhat-module') {
msg = new ModuleMessageBuilder().buildMessageRunning(
artifactType, taskId, pipelineMetadata, scenario, testType, testProfile
artifactType, taskId, pipelineMetadata, scenario, testType, testProfile, nvr
)
} else if (artifactType == 'fedora-update') {
msg = new FedoraUpdateMessageBuilder().buildMessageRunning(
Expand Down Expand Up @@ -153,13 +155,14 @@ def buildMessageComplete(
String scenario,
String testType,
String testProfile,
String testResult
String testResult,
String nvr
) {
def msg

if (artifactType in ['koji-build', 'brew-build']) {
msg = new RpmBuildMessageBuilder().buildMessageComplete(
artifactType, taskId, pipelineMetadata, xunit, xunitUrls, isSkipped, note, scenario, testType, testProfile
artifactType, taskId, pipelineMetadata, xunit, xunitUrls, isSkipped, note, scenario, testType, testProfile, nvr
)
} else if (artifactType == 'fedora-dist-git') {
msg = new PullRequestMessageBuilder().buildMessageComplete(
Expand All @@ -171,7 +174,7 @@ def buildMessageComplete(
)
} else if (artifactType == 'redhat-module') {
msg = new ModuleMessageBuilder().buildMessageComplete(
artifactType, taskId, pipelineMetadata, xunit, xunitUrls, isSkipped, note, scenario, testType, testProfile
artifactType, taskId, pipelineMetadata, xunit, xunitUrls, isSkipped, note, scenario, testType, testProfile, nvr
)
} else if (artifactType == 'fedora-update') {
msg = new FedoraUpdateMessageBuilder().buildMessageComplete(
Expand Down Expand Up @@ -217,13 +220,14 @@ def buildMessageError(
String scenario,
String errorReason,
String testType,
String testProfile
String testProfile,
String nvr
) {
def msg

if (artifactType in ['koji-build', 'brew-build']) {
msg = new RpmBuildMessageBuilder().buildMessageError(
artifactType, taskId, pipelineMetadata, xunit, scenario, errorReason, testType, testProfile
artifactType, taskId, pipelineMetadata, xunit, scenario, errorReason, testType, testProfile, nvr
)
} else if (artifactType == 'fedora-dist-git') {
msg = new PullRequestMessageBuilder().buildMessageError(
Expand All @@ -235,7 +239,7 @@ def buildMessageError(
)
} else if (artifactType == 'redhat-module') {
msg = new ModuleMessageBuilder().buildMessageError(
artifactType, taskId, pipelineMetadata, xunit, scenario, errorReason, testType, testProfile
artifactType, taskId, pipelineMetadata, xunit, scenario, errorReason, testType, testProfile, nvr
)
} else if (artifactType == 'fedora-update') {
msg = new FedoraUpdateMessageBuilder().buildMessageError(
Expand Down
28 changes: 24 additions & 4 deletions src/org/fedoraproject/jenkins/messages/ModuleMessageBuilder.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def buildMessageQueued(
Map pipelineMetadata,
String scenario,
String testType,
String testProfile
String testProfile,
String nvr
) {
def msgTemplate

Expand Down Expand Up @@ -46,6 +47,10 @@ def buildMessageQueued(
msgTemplate['artifact']['stream'] = moduleInfo.get('stream')
msgTemplate['artifact']['version'] = moduleInfo.get('version')

if (nvr) {
msgTemplate['artifact']['nvr'] = nvr
}

// test section
msgTemplate['test']['type'] = testType ?: pipelineMetadata['testType']
msgTemplate['test']['category'] = pipelineMetadata['testCategory']
Expand All @@ -72,7 +77,8 @@ def buildMessageRunning(
Map pipelineMetadata,
String scenario,
String testType,
String testProfile
String testProfile,
String nvr
) {
def msgTemplate

Expand Down Expand Up @@ -105,6 +111,10 @@ def buildMessageRunning(
msgTemplate['artifact']['stream'] = moduleInfo.get('stream')
msgTemplate['artifact']['version'] = moduleInfo.get('version')

if (nvr) {
msgTemplate['artifact']['nvr'] = nvr
}

// test section
msgTemplate['test']['type'] = testType ?: pipelineMetadata['testType']
msgTemplate['test']['category'] = pipelineMetadata['testCategory']
Expand Down Expand Up @@ -135,7 +145,8 @@ def buildMessageComplete(
String note,
String scenario,
String testType,
String testProfile
String testProfile,
String nvr
) {
def msgTemplate

Expand All @@ -162,6 +173,10 @@ def buildMessageComplete(
msgTemplate['artifact']['stream'] = moduleInfo.get('stream')
msgTemplate['artifact']['version'] = moduleInfo.get('version')

if (nvr) {
msgTemplate['artifact']['nvr'] = nvr
}

// test section
def result = 'needs_inspection'
if (isSkipped) {
Expand Down Expand Up @@ -220,7 +235,8 @@ def buildMessageError(
String scenario,
String errorReason,
String testType,
String testProfile
String testProfile,
String nvr
) {
def msgTemplate

Expand All @@ -247,6 +263,10 @@ def buildMessageError(
msgTemplate['artifact']['stream'] = moduleInfo.get('stream')
msgTemplate['artifact']['version'] = moduleInfo.get('version')

if (nvr) {
msgTemplate['artifact']['nvr'] = nvr
}

// test section
msgTemplate['test']['type'] = testType ?: pipelineMetadata['testType']
msgTemplate['test']['category'] = pipelineMetadata['testCategory']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def buildMessageQueued(
Map pipelineMetadata,
String scenario,
String testType,
String testProfile
String testProfile,
String nvr
) {
def msgTemplate

Expand Down Expand Up @@ -43,6 +44,10 @@ def buildMessageQueued(
msgTemplate['artifact']['scratch'] = taskInfo.scratch
msgTemplate['artifact']['type'] = artifactType

if (nvr) {
msgTemplate['artifact']['nvr'] = nvr
}

// test section
msgTemplate['test']['type'] = testType ?: pipelineMetadata['testType']
msgTemplate['test']['category'] = pipelineMetadata['testCategory']
Expand Down Expand Up @@ -71,7 +76,8 @@ def buildMessageRunning(
Map pipelineMetadata,
String scenario,
String testType,
String testProfile
String testProfile,
String nvr
) {
def msgTemplate

Expand Down Expand Up @@ -102,6 +108,10 @@ def buildMessageRunning(
msgTemplate['artifact']['source'] = taskInfo.source.raw ?: ''
msgTemplate['artifact']['type'] = artifactType

if (nvr) {
msgTemplate['artifact']['nvr'] = nvr
}

// test section
msgTemplate['test']['type'] = testType ?: pipelineMetadata['testType']
msgTemplate['test']['category'] = pipelineMetadata['testCategory']
Expand Down Expand Up @@ -134,7 +144,8 @@ def buildMessageComplete(
String note,
String scenario,
String testType,
String testProfile
String testProfile,
String nvr
) {
def msgTemplate

Expand All @@ -160,6 +171,10 @@ def buildMessageComplete(
msgTemplate['artifact']['source'] = taskInfo.source.raw ?: ''
msgTemplate['artifact']['type'] = artifactType

if (nvr) {
msgTemplate['artifact']['nvr'] = nvr
}

// test section
def result = 'needs_inspection'
if (isSkipped) {
Expand Down Expand Up @@ -222,7 +237,8 @@ def buildMessageError(
String scenario,
String errorReason,
String testType,
String testProfile
String testProfile,
String nvr
) {
def msgTemplate

Expand All @@ -247,6 +263,10 @@ def buildMessageError(
msgTemplate['artifact']['source'] = taskInfo.source.raw ?: ''
msgTemplate['artifact']['type'] = artifactType

if (nvr) {
msgTemplate['artifact']['nvr'] = nvr
}

// test section
msgTemplate['test']['type'] = testType ?: pipelineMetadata['testType']
msgTemplate['test']['category'] = pipelineMetadata['testCategory']
Expand Down
13 changes: 9 additions & 4 deletions vars/sendMessage.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def call(Map params = [:]) {
def testResult = params.get('testResult') ?: ''
def testProfile = params.get('testProfile') ?: ''
def xunitUrls = params.get('xunitUrls') ?: []
def nvr = params.get('nvr') ?: ''

// isInfo is an alias for isSkipped
isSkipped = isSkipped || isInfo
Expand Down Expand Up @@ -103,7 +104,8 @@ def call(Map params = [:]) {
runLog,
scenario,
testType,
testProfile
testProfile,
nvr
)
}

Expand All @@ -117,7 +119,8 @@ def call(Map params = [:]) {
runLog,
scenario,
testType,
testProfile
testProfile,
nvr
)
}

Expand All @@ -136,7 +139,8 @@ def call(Map params = [:]) {
scenario,
testType,
testProfile,
testResult
testResult,
nvr
)
}

Expand All @@ -152,7 +156,8 @@ def call(Map params = [:]) {
scenario,
errorReason,
testType,
testProfile
testProfile,
nvr
)
}

Expand Down

0 comments on commit 6c4a270

Please sign in to comment.