Need to run Exec task of gradle for different environments

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Need to run Exec task of gradle for different environments

This post has NOT been accepted by the mailing list yet.

I am new to gradle and learning it gradually.
I need to run my python integration tests via gradle on local environment and also dev env.
Goal is to run my tests from commandline against a particular env. Such as:
gradle -Penv=local pythontest

With above command, my python tests need to run on local env, url: localhost:8665/local

gradle -Penv=qa pythontest

My python tests need to run on QA env: url:

I so far have a task setup:

task pythontest (type: Exec) {
        workingDir './API'
        commandLine 'nosetests', '-v', ''
        if (project.hasProperty("env")) {
            args = [env]

Not able to figure out how to set my urls inside this task. Also not sure if python tests can accept the url from here.

This is different from Java tests, where it was relatively easier to set the -Penv, via testng and made changes to my 'test' task:
test {
            useDefaultListeners = true
            ignoreFailures = true
            jvmArgs '-Xmx3048m', '-XX:MaxPermSize=256m'
            includeGroups 'fast'
                ext.testngfile = "src/test/resources/" + "$env"  + "_testng.xml"
             } else {
                ext.testngfile = "src/test/resources/local_testng.xml"
            //setup the testng.xml file with env

I have files, qa_testng.xml and local_testng.xml