Parameterize the Controller URL in a GitLab CICD Pipeline
-
Edit the
gitlab-ci.ymlfile and add the lines as in the following sample code.
The following example assumes that your controller JSON file is namedcontroller.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=$SCENARIOThe
perlcommand 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 namedCONTROLLER. Then the value is added as a environmental variable so the build.xml file can use it to create the URL from where theRestClient.jarneeds to be downloaded. -
In the
build.xmlfileadd a line before the targets definitions, to get the controller from the environment variable.<property name="controller" value="${env.CONTROLLER}"/> -
Modify the
depstarget so the URL to download theRestClient.jarwill 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
SCENARIOandCONTROLLERvariables.
Last updated: September 25, 2024
If you have any feedback on this topic, please contact us at documentation@appvance.ai