Skip to main content

Parameterize the Controller URL in a GitLab CICD Pipeline

    Edit the gitlab-ci.yml file and add the lines as in the following sample code.

    The following example assumes that your controller JSON file is named controller.json. If your file is named differently adjust the code as needed.

    variables:
       CONTROLLER: "http://10.70.10.1:8080"
       SCENARIO: "REPOSITORY/Appvance/scenarios/test.scenario"
    script:
       - perl -pi -e 's/"url": "[^"]*"/"url": "$CONTROLLER"/' controller.json
       - export CONTROLLER=$CONTROLLER
       - ant createScenariosDashboard -Dscenario=$SCENARIO

    The perl command line in the script section, searches for the value of the URL in the JSON and replaces it with the value set in the GitLab variable named CONTROLLER. Then the value is added as a environmental variable so the build.xml file can use it to create the URL from where the RestClient.jar needs to be downloaded.

    In the build.xmlfile add a line before the targets definitions, to get the controller from the environment variable.

    <property name="controller" value="${env.CONTROLLER}"/>

    Modify the deps target so the URL to download the RestClient.jar will use the parameterized controller URL.

    <target name="deps" depends="init">
        <mkdir dir="${lib}"/>
        <get src="${controller}/UI/container/AppvanceCIClientWithDeps.jar" dest="${lib}/RestClient.jar"/>
    </target>

    When triggering the pipeline manually or in the pipeline scheduler, provide the new desired value for the SCENARIO and CONTROLLER variables.


    Last updated: September 25, 2024

    If you have any feedback on this topic, please contact us at documentation@appvance.ai