I am very new to gradle and trying to write a gradle task to generate and open allure report. I am trying to use gradle node plugin(com.moowork.node) to use the "allure-commandline" nodejs package. The report runs fine when I have a custom node script but not when doing the same thing from gradle from the default allure-commandline script.The report process I think works in background and thus ie does not open.
task allure(type: NodeTask){
script =file('node_modules/allure-commandline/index.js')
args = ["allure","generate","allureResults","--clean","-o","allureReport"]
args = ["allure","open","allureReport"]
}
This Node task works:
task nodeAllure(type: NodeTask){
script =file('allure.js')
}
My allure.js:
var allure = require('allure-commandline');
// returns ChildProcess instance
var generation = allure(['generate', 'reports/allure-results','--clean','-o','allure-report']);
generation.on('exit', function(exitCode) {
allure(['open','allure-report']);
});
There is Allure Gradle plugin available that will handle all the work for you. See the docs for more details https://docs.qameta.io/allure/2.0/#_gradle_3
Related
I was trying to run the test from CI/CD gitlab runner file but it is causing issue while executing from gitlab.
I have sucessfully executed the test locally using the karate option
Working fine in Local Run:
mvn test -Dkarate.env=stg +-DKarate.options=--tags #Ui" -Dtest.run.mode=localtest -Dtest.run.group=OKCUtest -Dtest=OKCUtest -Dtest.gitlabRunner=false -DbuildDirectory=stg-target/OKCUtest -Dtest.run.testSource=localtest
There are 5 test feature files which were executed using the #Api tags and now I have identified that one should be #Ui and changed the respective feature file and created the new pipeline OKCU-UI and have updated the command line syntax to address #Ui tests.
can you try this command ?
mvn test -Dkarate.options="--tags ~#Ui"
if still not try same command with version 0.9.6.RC3
I have android project using java which uses a nodejs server hosted on heruko. What I want is to run a local server before androidTest(instrument test), I have tried writing batch(bash*) file and running my server as an external tool.
That doesn't work async and stops the test. Any help with this would be highly appreciated.
This is how serverScript.bat looks:
cd C:\intern.apply
start node server test
Update v1:
I found a way to run my bash* file from gradle. But there is 1 problem, it always run, I want it to run only when someone runs androidTests (robitium/acceptance tests) from android studio. Right now I have this task in gradle.build (Project:AppName)
task mytask() {
ant.exec(
executable: 'serverScript.bat',
spawn: true
)
}
In your bash (not batch) file, have you tried running the server in background?
run_server & --> will be processed in background and the script continues
run_tests
stop_server
I'm writing Jenkins job using job DSL. It looks like:
job(jobName) {
description("This is my Jenkins job.")
steps {
// Executing some shell here.
}
scm {
// Checking out some branch from Git.
}
triggers {
bitbucketPush()
scm ''
}
}
It works fine, but for some reason, executing my shell script it fails with an errors:
/usr/lib/git-core/git-pull: 83: /usr/lib/git-core/git-sh-setup: sed: not found
basename: write error: Broken pipe
/usr/lib/git-core/git-pull: 299: /usr/lib/git-core/git-sh-setup: uname: not found
etc.
As far as I understand, the issue is with PATH variable. When I'm fixing it in Jenkins from UI (in Configure section) it works fine. (adding something like this: PATH=/usr/local/bin:/usr/bin
As I'm creating a lot of job, it would great to fix this PATH during creation process in my DSL scripts.
How it may be added into my DSL?
The problem is not related to Job DSL. Try to configure the job manually and fix all problems. Then translate you configuration to Job DSL.
In this case there is something wrong with the environment on you build agent, e.g. git is not installed properly.
I have following code in my script:
def ant_fs = (new AntBuilder())
def fs = ant_fs.fileset( dir: <path> )
fs.each{
println( "Fileset item: $it" )
}
When I launch it from Maven (mvn ... in command line) or from Intellij IDEA I see that fileset object is initialized successfully (I see correct files' pathes).
When I launch this code via Jenkins I see that fs object is not created but I do not see any exception in output.
Could you please help me resolve the issue?
Thanks In Advcance!
Note: I have surefire plugin for Maven2.
Looks like this issue was caused by incorrect user Jenkins Agent settings.
I setup user into Jenkins Service (Win host) as Administrator and my script started to work. It was caused because I work with shared folder on another host which required authentification. I setup authentification on that host for Administrator account, but Jenkins by default launches test as System account.
Is there a way I can force a gradle task to run again, or reset all tasks back to the not UP-TO-DATE state?
Try to run your build with -C rebuild that rebuilds Gradle's cache.
In newer versions of Gradle, use --rerun-tasks
If you want just a single task to always run, you can set the outputs property inside of the task.
outputs.upToDateWhen { false }
Please be aware that if your task does not have any defined file inputs, Gradle may skip the task, even when using the above code. For example, in a Zip or Copy task there needs to be at least one file provided in the configuration phase of the task definition.
You can use cleanTaskname
Let's say you have
:someproject:sometask1 UP-TO-DATE
:someproject:sometask2 UP-TO-DATE
:someproject:sometask3 UP-TO-DATE
And you want to force let's say sometask2 to run again you can
someproject:cleanSometask2
before you run the task that runs it all.
Apparently in gradle, every task that understands UP-TO-DATE also understand how to clean itself.
I had a tough case where setting outputs.upToDateWhen { false } inside the task or adding the flag --rerun-tasks didn't help since the task's setOnlyIf kept being set to false each time I ran it.
Adding the following to build.gradle forced the execution of myTask:
gradle.taskGraph.whenReady { taskGraph ->
def tasks = taskGraph.getAllTasks()
tasks.each {
def taskName = it.getName()
if(taskName == 'myTask') {
println("Found $taskName")
it.setOnlyIf { true }
it.outputs.upToDateWhen { false }
}
}
}
You can run:
./gradlew clean
It will force the gradle to rebuild.