I have the following code snippet in Java (run the project with Java 8 and apache-maven-3.6.3)
@ParameterizedTest
@ValueSource(strings = {"true"})
public void P34AMA_2837(String expected_result) throws Throwable {
Xray.setTestKey("P34AMA-2818");
assertEquals(expected_result, "true");
}
This code snippet works locally in my machinethrough the cmd (C:\work\apps\apache-maven-3.6.3\bin\mvn test -Dbusiness_date="20230124" ), but the Jira/Xray test ID is not integrated in Jira/Xray using the Jenkins Xray-connector plugin and the following Jenkins pipeline
def SOURCE_SYSTEM;
pipeline {
agent { label 'p34' }
parameters {
string(name: 'BUSINESS_DATE', defaultValue: '20230124', description: 'Choose a
BUSINESS_DATE')
}
stages {
stage('Clean Workspace') {
steps {
cleanWs()
}
}
stage('Clone Respository') {
steps {
script{
if ("${params.JIRA_ID}"){
bat "echo ${params.JIRA_ID}"
withCredentials([
string(credentialsId: 'df54e5bb-3330-4201-b699-644e5a609c4d', variable:
'TOKEN')]) {
bat "git -c http.sslVerify=false clone https://$TOKEN@bitbucket-
mut.d.bbg/scm/p34actzmad/actimizemse-batch-java.git"
dir("${WORKSPACE}/actimizemse-batch-java"){
bat "echo %JAVA_HOME%"
bat "git checkout origin/tests"
bat "C:/work/apps/apache-maven-3.6.3/bin/mvn test -
Dbusiness_date=${params.BUSINESS_DATE} "
bat "echo ${params.BUSINESS_DATE}"
}
}
} else {
if ("${params.ENTITY}.isEmpty()") {
echo 'No entities were chosen'
if ("${params.JIRA_ID}.isEmpty()") {
echo 'No jira_id were chosen'
withCredentials([
string(credentialsId: 'if54e5bb-3630-4209-b699-644e5a929c4v', variable: 'TOKEN')]) {
bat "git -c http.sslVerify=false clone https://$TOKEN@bitbucket-mut.d.bbg/scm/p34actzmad/actimizemse-batch-java.git"
dir("${WORKSPACE}/actimizemse-batch-java"){
bat "echo %JAVA_HOME%"
bat "git checkout origin/tests"
bat "C:/work/apps/apache-maven-3.6.3/bin/mvn test -Dbusiness_date=${params.BUSINESS_DATE} "
//bat "C:/work/apps/apache-maven-3.6.3/bin/mvn dependency:purge-local-repository -DactTransitively=false -U test -Dcurrency=\"EUR\""
//bat "echo %BUSINESS_DATE%"
bat "echo ${params.BUSINESS_DATE}"
}
}
}
}
}
}
}
}
stage ('Import Results into Jira') {
steps {
step([$class: 'XrayImportBuilder',
endpointName: '/junit',
importFilePath: '*/reports/*.xml',
projectKey: 'P34AMA',
importToSameExecution: 'false',
serverInstance: '3146a388-d399-4e35-ae28-8c65404d6f9d',
credentialId:'58287529-194d-4e91-9964-7d740d8d2f65',
fixVersion: 'MSE 3.3',
inputInfoSwitcher: 'fileContent',
inputTestInfoSwitcher: 'fileContent',
testImportInfo: '''{
"fields": {
"labels": ["Quotes"],
}}'''
])
}
}
}}
I am in the "tests" branch both locally and in the Jenkins pipeline.
Additionally, the Test Executions used to be created in Jira/Xray with the @XrayTest annotation and correctly linked to the Jira Test ID (using xray-junit-extension) .But now, using zebrunner agent core 1.7.2 , the Test Executions are no longer linked to the correct Test IDs.
I really need this syntaxe, since I don't want to use annotations. If I overcome this technical issue I'd like to input an array of undefined strings (resulting from another java method) that provide the Test IDs. This is the reason why I am using Zebrunner, since annotations can not be iterated.