Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

How use the variables mentioned in the .env file using environmentConfig ?

aflorence
aflorence Posts: 7

I want to use different environment file for each environment. I have exported the file(smoke.env) and placed in 3 different folders(DEV,SIT,PAT). The values of each environment variables vary as per the environment. I want to execute the script from .cli mode. Wen I tried to use -environmentConfig "Path of .env file" from .bat file, its not picking the actual value that is needed for the environment. Instead it is picking up the default environment available in the script. Could you please help me how to use -environmentConfig instead of -environment

Thank you!

Comments

  • jakubiak
    jakubiak Posts: 795 admin

    Configure your test suite with each of the three environments, by creating an environment reference that points to the exported file. Then from the command line using the -environment argument to choose the environment you wish to use, as described here: https://docs.parasoft.com/display/SOA9106/Automated+Testing+as+a+Nightly+Process#AutomatedTestingasaNightlyProcess-ApplyinganEnvironmentConfigurationtoaRegressionTestfromtheCommandLine

    -environmentConfig requires the file to be in a different format than the format of the exported environment file and is not really what you want in this case.

  • aflorence
    aflorence Posts: 7

    Thank you for your response. I am aware that the above steps mentioned by you works well. But my need is -environmentConfig. This is for CI process to execute the test script from jenkins pipeline

    !/usr/bin/env bash

    WORKSPACE="SOAWorkspace"
    PROJECT="SOATest"
    TEST="smoke"
    ENV_CONFIG="SOAWorkspace/SOATest/Tools/PAT/smoke.env"
    CONFIG="user://Example Configuration"
    LOCALSETTINGS="/opt/parasoft/soatest/9.10/localsettings.properties"
    SOATESTCLI="/opt/parasoft/soatest/9.10/soatestcli"
    **sed -i "s/{{hostname}}/$1/g" ${ENV_CONFIG}
    **${SOATESTCLI} -data ${WORKSPACE} -import "${WORKSPACE}/${PROJECT}"
    ${SOATESTCLI} -data ${WORKSPACE} -resource "${PROJECT}/${TEST}.tst" -environmentConfig ${ENV_CONFIG} -config "${CONFIG}" -localsettings "${LOCALSETTINGS}" -report "reports/sit/${TEST}_report.html" -fail
    sed -i "s/$1/{{hostname}}/g" ${ENV_CONFIG}

  • jakubiak
    jakubiak Posts: 795 admin

    Both -environment and -environmentConfig are supported from SOAtest CLI, and will work from the jenkins pipeline. If you want to use -environmentConfig for some reason, you will need to create the file manually in the correct format and with the correct values.

  • aflorence
    aflorence Posts: 7

    if we export the file from the environment. then by default it will be in the xml format right?
    Or is there something else i need to update in the file. Please attach one sample file along with its actual extension.

  • jakubiak
    jakubiak Posts: 795 admin

    If you export the file from the environment, it will be in an XML format but it will be the format required to create a referenced environment in SOAtest, which you can then specify to use by passing -environment. There is no export function which extracts the values into the format required by -environmentConfig.