Forum Discussion

mjlamora's avatar
mjlamora
New Contributor
2 years ago

Excluding project-level properties from source control

I have a project-level property that is a unique value across various team members and needs to be frequently updated. I am trying to exclude this value from our source control, which is managed via git integration. ReadyAPI saves the property and its value in settings.xml.

 

Other properties (test suite level, or test case level) have a checkbox to store the values locally per user, which exactly meets my needs -- BUT this checkbox is disabled for project-level properties. (See image attached.)

 

 

I would set the property at the test suite level, but the value varies by environment, which is a distinction that is only made at the Project level.

 

I've considered adding settings.xml to a .gitignore file, but there are other values within that file that we'd like to maintain in source control.

 

Any suggestions on a clean solution for this?

Thanks in advanced for the review and input.

1 Reply

  • JoostDG's avatar
    JoostDG
    Frequent Contributor

    Hi mjlamora .

     

    I think your issue has already been addressed in this forum previously. See this post : https://community.smartbear.com/t5/ReadyAPI-Questions/Solution-Script-to-Cleanup-of-Custom-property-values-in-the/m-p/198108

     

    Since that post, there is now indeed a way to exclude test suite & test case variables, so you should exclude those from that script.

     

    You could, on top of that, also use a setup script (or equivalent load script) that loads in project properties from a file that is located in a git repo dedicated folder (which you can gitIgnore later). See below example where I have a readyApi.properties file in folder "datasource".

    Content should be like this:

    projectProperty1Name=projectProperty1Value
    projectProperty2Name=projectProperty2Value

    I got the original code form someone else, so I don't take credit for that. Together with that save script this should solve your question I believe.

     

    setup script

    def projectpath = project.path
    project.setPropertyValue("projectpath", projectpath)
    def testDataPath = project.path + "/datasource"
    // Load properties from file. These properties can be used across the different environments.
    def props = new Properties()
    //replace the path with your file name below. use / instead of \ as path separator even on windows platform.
    new File(testDataPath + File.separator + "readyApi.properties").withInputStream { s ->
        props.load(s)
    }
    props.each {
        project.setPropertyValue(it.key, it.value)
    }