TestNG TestLink Jenkins Ant cannot find results - ant

I've just began to work with TestLink but I cannot see the results of the executions: on my Jenkins I have an ANT build file which runs a TestNG suite, and it began to work writting that he had found 1 result. (In spanish:
Ejecutado por el programador
Ejecutando remotamente en qaie9 en el espacio de trabajo c:\jenkins\jobs\COMPLEMENTARIO
Preparando la API cliente del TestLink
Utilizando la siguiente URL del TestLink: http://XXX.XXX.XXX.XXX/testlink/lib/api/xmlrpc.php
Ha encontrado 1 resultados de pruebas.
Ordenando casos de prueba automatizados por el orden de ejecuci?n del plano de pruebas del Testlink.
Ejecutando Build Steps unitarios.
[COMPLEMENTARIO] $ cmd.exe /C '"C:\apache-ant-1.8.3\bin\ant.bat testBasicoAgenda && exit %%ERRORLEVEL%%"'
Buildfile: c:\jenkins\jobs\COMPLEMENTARIO\build.xml
testBasicoAgenda:.....
But at the end of the log, it says that he found 0 results:
BUILD SUCCESSFUL
Total time: 1 minute 54 seconds
Ejecutando Build Steps iterativos.
Buscando por los Resultados de Pruebas de los Casos de Prueba del Testlink.
Looking for test results in TestNG methods by its name and data provider name.
Ha encontrado 0 resultados de pruebas.
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern: **/test-output/testng-results.xml
Saving reports...
Processing 'C:\Documents and Settings\usuarioqa\.jenkins\jobs\AGENDA - PLAN BASICO\builds\2013-03-21_17-30-44\testng\testng-results.xml'
TestNG Reports Processing: FINISH
Finished: SUCCESS
I mean, why doesn't it look for any TestNG results? The path for the results is test-output/*.xml. I've read another issue where somebody says It worked with success results and not for failed results but in my case it doesn't work with any! Can anyone help me please? I don't know what's wrong with it.

The result found is the test case (with automated execution) in testLink.
Plz give your entire configuration of jenkins and your folder architecture.

Related

Update parameters dinamically Jenkins pipeline

I'm using this Jenkins pipeline to create parameters from a list of directories in a Gitlab repository. New folders are constantly being uploaded to this repository, but i forced to execute this Pipeline each time that commit is executed (I want execute Jenkins pipeline manually and select an specific directory). How can I update parameters list without run pipeline job?
node {
checkout scm
def backups = sh(returnStdout: true, script: "ls $WORKSPACE")
backups.split().each {
backupArray << it
}
}
pipeline {
parameters { choice(name: 'BACKUP', choices: backupArray, description: 'Selecciona el backup para realizar el Rollback') }
agent any
stages {
stage('Realizando el Rollback con el Backup seleccionado') {
steps {
script {
sh "echo Se realiza el Rollback con el Backup $params.BACKUP"
withCredentials([string(credentialsId: 'ID', variable: 'VARIABLE')]) {
sh "script.sh $params.BACKUP"
}
}
}
}
}
post {
always {
script {
sh 'rm -rf *'
}
}
}
}
I don’t believe you can do that without executing the job at all since Jenkins needs to retrieve the latest Jenkinsfile in order to know about any updates to the parameters.
This solution could be helpful.
Basically, you set a Boolean parameter for the job and then if that is true the job will execute but all stages would be skipped. Thus the parameters of the job will get updated and the job will complete quickly.

jenkins pipeline how to change a stage result base on a % of the test results

jenkins pipeline junit use a weird metric for the health of a job,
https://www.jenkins.io/doc/pipeline/steps/junit/ and if one test fail will mark the stage/job unstable
is it possible to tell the stage if 20% of the test fail then mark it as unstable else is sucesfull?
i created a python script that read the result xml, and got the failed test and the totals
and run pytest inside a python script and not from the cli, that way i can control the error code. since junit addon will mark it unstable if some tests fail since the error code will be other than zero, so my script
pytest_result = pytest.main([my tests, "--junitxml", f"{args.reports_folder}/xml/*name*.xml", "-o", "junit_suite_name=*name*"] )
parse the xml with import xml.etree.ElementTree as ET to get the amount of fail and total amount of tests
percentage_fail = (failed_tests/total_tests)*100
after i compare it to the threshold
if percentage_fail > threshold:
raise SystemExit(1)
else:
print("All test working")
raise SystemExit(0)
junit will not let you change the status of the build if become 'UNSTABLE' the trick is control the error code that comes from running the tests. before passing the report.xml to junit

Issue in Jenkins integration with GitHub and Ionic project

I am trying to integrate ionic application with Jenkins and i am using GitHub as a repository. When i run the Multibranch pipeline job manually, the Jenkin is displaying below error.
Does anyone know what can be possible issue ? I am trying to learn how CI/CD works with this demo experiment.
I am referring this Youtube video : https://www.youtube.com/watch?v=q5voVJb3rHI&t=605s
Started by user admin
13:42:45 Connecting to https://api.github.com using PrashobThekkyal/*****
Obtained Jenkinsfile from a85fffb01a96c5c5d550326873047c6071557aff
Running in Durability level: MAX_SURVIVABILITY
GitHub has been notified of this commit’s build result
java.lang.IllegalArgumentException: Unsupported class file major version 57
at org.kohsuke.asm6.ClassReader.<init>(ClassReader.java:176)
at org.kohsuke.asm6.ClassReader.<init>(ClassReader.java:158)
at org.kohsuke.asm6.ClassReader.<init>(ClassReader.java:146)
at org.jenkinsci.bytecode.helper.ClassLoadingReferenceTypeHierachyReader.reader(ClassLoadingReferenceTypeHierachyReader.java:64)
at org.jenkinsci.bytecode.helper.TypeHierarchyReader.hierarchyOf(TypeHierarchyReader.java:176)
at org.jenkinsci.bytecode.helper.ClassLoadingReferenceTypeHierachyReader.hierarchyOf(ClassLoadingReferenceTypeHierachyReader.java:39)
at org.jenkinsci.bytecode.helper.TypeHierarchyReader$TypeHierarchy.isAssignableFrom(TypeHierarchyReader.java:321)
at org.jenkinsci.bytecode.helper.TypeHierarchyReader$TypeHierarchy.isAssignableFromAnyInterfaceImplementedBy(TypeHierarchyReader.java:329)
at org.jenkinsci.bytecode.helper.TypeHierarchyReader$TypeHierarchy.isAssignableFrom(TypeHierarchyReader.java:311)
at org.jenkinsci.bytecode.helper.TypeHierarchyReader.isAssignableFrom(TypeHierarchyReader.java:124)
at org.jenkinsci.bytecode.helper.ClassLoadingReferenceTypeHierachyReader.isAssignableFrom(ClassLoadingReferenceTypeHierachyReader.java:39)
at org.jenkinsci.bytecode.helper.TypeHierarchyReader.getCommonSuperClass(TypeHierarchyReader.java:131)
at org.jenkinsci.bytecode.helper.ClassLoadingReferenceTypeHierachyReader.getCommonSuperClass(ClassLoadingReferenceTypeHierachyReader.java:39)
at org.jenkinsci.bytecode.NonClassLoadingClassWriter.getCommonSuperClass(NonClassLoadingClassWriter.java:72)
at org.kohsuke.asm6.SymbolTable.addMergedType(SymbolTable.java:1209)
at org.kohsuke.asm6.Frame.merge(Frame.java:1293)
at org.kohsuke.asm6.Frame.merge(Frame.java:1238)
at org.kohsuke.asm6.MethodWriter.computeAllFrames(MethodWriter.java:1604)
at org.kohsuke.asm6.MethodWriter.visitMaxs(MethodWriter.java:1540)
at org.kohsuke.asm6.tree.MethodNode.accept(MethodNode.java:807)
at org.kohsuke.asm6.commons.JSRInlinerAdapter.visitEnd(JSRInlinerAdapter.java:150)
at org.jenkinsci.bytecode.Transformer$1$1.visitEnd(Transformer.java:109)
at org.kohsuke.asm6.MethodVisitor.visitEnd(MethodVisitor.java:783)
at org.kohsuke.asm6.ClassReader.readMethod(ClassReader.java:1278)
at org.kohsuke.asm6.ClassReader.accept(ClassReader.java:679)
at org.kohsuke.asm6.ClassReader.accept(ClassReader.java:391)
at org.jenkinsci.bytecode.Transformer.transform(Transformer.java:115)
at hudson.ClassicPluginStrategy$AntClassLoader2.defineClassFromData(ClassicPluginStrategy.java:706)
at jenkins.util.AntClassLoader.getClassFromStream(AntClassLoader.java:1310)
at jenkins.util.AntClassLoader.findClassInComponents(AntClassLoader.java:1363)
at jenkins.util.AntClassLoader.findClass(AntClassLoader.java:1326)
at jenkins.util.AntClassLoader.loadClass(AntClassLoader.java:1079)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at org.jenkinsci.plugins.workflow.cps.CpsScript.<init>(CpsScript.java:69)
at WorkflowScript.<init>(WorkflowScript)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:166)
at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:404)
at java.base/java.lang.Class.newInstance(Class.java:591)
at org.codehaus.groovy.runtime.InvokerHelper.createScript(InvokerHelper.java:434)
Caused: groovy.lang.GroovyRuntimeException: Failed to create Script instance for class: class WorkflowScript. Reason
at org.codehaus.groovy.runtime.InvokerHelper.createScript(InvokerHelper.java:466)
at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:142)
at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:561)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:522)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:327)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Finished: FAILURE
Jenkinsfile
pipeline {
agent any
stages {
stage ('Build') {
steps {
echo "Building Multibranch Pipeline"
}
}
stage ('Testing') {
steps {
echo "Testing Multibranch Pipeline"
}
}
stage ('Deployment') {
steps {
echo "False Deploying Multibranch Pipeline"
}
}
}
}
Jenkins Job configuration:
After days of analysis finally I have found the solution. I have did a very basic mistake of not reading version requirement to run Jenkins.
Java requirement to run Jenkins job
As mentioned in above URL, under the section 'Running Jenkins', they have clearly mentioned the support versions of java to run Jenkins job. So I checked java version and it was running on Java 13-a, yes that was stupid, because the Jenkins job will only run with java version 8 and 11.
So degrade your java version to 8 or 11 and it will work smoothly.
Proof
I thought to delete my stupid question, but later I thought to keep it, if in case it could help somebody. Kindly please don't give any kind of (+ve or -vew) points to this post, as it doesn't make any sense.

Using waitForQualityGate in a Jenkins declarative pipeline

The following SonarQube (6.3) analysis stage in a declarative pipeline in Jenkins 2.50 is failing with this error in the console log: http://pastebin.com/t2ja23vC. More specifically:
SonarQube installation defined in this job (SonarGate) does not match any configured installation. Number of installations that can be configured: 1.
Update: after changing "SonarQube" to "SonarGate" in the Jenkins settings (under SonarQube servers, so it'll match the Jenkinsfile), I get a different error: http://pastebin.com/HZZ6fY6V
java.lang.IllegalStateException: Unable to get SonarQube task id and/or server name. Please use the 'withSonarQubeEnv' wrapper to run your analysis.
The stage is a modification of the example from the SonarQube docs: https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Jenkins#AnalyzingwithSonarQubeScannerforJenkins-AnalyzinginaJenkinspipeline
stage ("SonarQube analysis") {
steps {
script {
STAGE_NAME = "SonarQube analysis"
if (BRANCH_NAME == "develop") {
echo "In 'develop' branch, don't analyze."
}
else { // this is a PR build, run sonar analysis
withSonarQubeEnv("SonarGate") {
sh "../../../sonar-scanner-2.9.0.670/bin/sonar-scanner"
}
}
}
}
}
stage ("SonarQube Gatekeeper") {
steps {
script {
STAGE_NAME = "SonarQube Gatekeeper"
if (BRANCH_NAME == "develop") {
echo "In 'develop' branch, skip."
}
else { // this is a PR build, fail on threshold spill
def qualitygate = waitForQualityGate()
if (qualitygate.status != "OK") {
error "Pipeline aborted due to quality gate coverage failure: ${qualitygate.status}"
}
}
}
}
}
I also created a webhook, sonarqube-webhook, with the URL http://****/sonarqube-webhook/. Should it be like that, or http://****/sonarqube/sonarqube-webhook? To access the server dashboard I use http://****/sonarqube.
In SonarQube's Quality Gates section I created a new quality gate:
I am not sure if the setting in SonarGate is correct. I do use jenkins-mocha to generate an lcov.info file that is used in Sonar to generate the coverage data.
Perhaps the quality gate setting is the wrong setting to do? The end result is to fail the job in Jenkins if coverage % is not met.
Finally, I am not sure if the following configurations in the Jenkins system configuration are at all required:
And
(It's 9000 not 900... cut text in the screen shot)
The SonarQube Jenkins plugin scans the build output for two specific lines, which it uses to get the SonarQube report task properties and project URL. If your invocation of sonar-scanner does not output these lines, the waitForQualityGate() call won't have the task ID to look them up. So you will have to figure out the correct settings to make it more verbose.
See the extractSonarProjectURLFromLogs and extractReportTask methods in the SonarUtils class of the plugin to understand how they work:
ANALYSIS SUCCESSFUL, you can browse <project URL> is used to add a link to the badge (in the build history)
Working dir: <dir with report-task.txt> is used to pass the task ID to the waitForQualityGate step
This was discovered to be a bug in the SonarQube scanner for Jenkins, when using a Jenkins slave for jobs (if the job is run on the master, it'd work). You can read more here: https://jira.sonarsource.com/browse/SONARJNKNS-282
I have tested this using a test build of v2.61 of the scanner plug-in and found it working.
The solution is to upgrade to v2.61 when released.
This stage will then work:
stage ("SonarQube analysis") {
steps {
withSonarQubeEnv('SonarQube') {
sh "../../../sonar-scanner-2.9.0.670/bin/sonar-scanner"
}
def qualitygate = waitForQualityGate()
if (qualitygate.status != "OK") {
error "Pipeline aborted due to quality gate coverage failure: ${qualitygate.status}"
}
}
}
If you're running SonarCube in a docker container check that the memory isn't exhausted. We were maxing out. Which seemed to be the issue.

Jenkins deploy WAR in glassfish

I want deploy in Glassfish a WAR using these batch commands from Jenkins. :
This is how I deploy a WAR with Batch command :
H:\workspace\xxxx>"C:\glassfish3\glassfish\bin\asadmin.bat" "undeploy"
Enter the value for the name operand> xxxx
H:\workspace\xxxx>"C:\glassfish3\glassfish\bin\asadmin.bat" "deploy"
Enter the value for the path operand> H:\xxxx-sources\xxxx.war
Application deployed with name xxxx.
Command deploy executed successfully.
In Jenkins , I add a batch command in my build with that :
cd "C:\glassfish3\glassfish\bin\"
asadmin.bat "undeploy"
XXXX
asadmin.bat "deploy"
H:\XXXX sources\XXXX.war
I have this error :
Démarré par l'utilisateur anonymous Building on master in workspace
C:\Documents and
Settings\XXXX.XXXX.jenkins\jobs\deployerXXXXCore\workspace
[workspace] $ sh -xe
C:\DOCUME~1\XXXX~1.XXXX\LOCALS~1\Temp\hudson2065869118895930371.sh
The system cannot find the file specified FATAL: L'exécution de la
commande a échoué. java.io.IOException: Cannot run program "sh" (in
directory "C:\Documents and
Settings\XXXX.XXXX.jenkins\jobs\deployerXXXX\workspace"):
CreateProcess error=2, The system cannot find the file specified at
java.lang.ProcessBuilder.start(ProcessBuilder.java:460) at
hudson.Proc$LocalProc.(Proc.java:244) at
hudson.Proc$LocalProc.(Proc.java:216) at
hudson.Launcher$LocalLauncher.launch(Launcher.java:802) at
hudson.Launcher$ProcStarter.start(Launcher.java:380) at
hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:97)
at
hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at
hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770)
at hudson.model.Build$BuildExecution.build(Build.java:199) at
hudson.model.Build$BuildExecution.doRun(Build.java:160) at
hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:533)
at hudson.model.Run.execute(Run.java:1759) at
hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at
hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240) Caused by:
java.io.IOException: CreateProcess error=2, The system cannot find the
file specified at java.lang.ProcessImpl.create(Native Method) at
java.lang.ProcessImpl.(ProcessImpl.java:81) at
java.lang.ProcessImpl.start(ProcessImpl.java:30) at
java.lang.ProcessBuilder.start(ProcessBuilder.java:453) ... 15 more
Build step 'Exécuter un script shell' marked build as failure
Finished: FAILURE
It seems that you are trying to execute your scripts in Jenkins using shell script execution,which works only on unix-like systems. Try doing the same with Windows batch execution in the Jenkins job.
You should select 'Execute Windows batch command' according to Jenkins guide.

Resources