FlexDeploy has various REST API that can be used for many useful purposes. For example, you can create Topology configurations or execute Build and Deploy workflows using REST API. See details at FlexDeploy REST API Guide.
In this blog entry, I will demonstrate use of REST API to setup Git Integrations in FlexDeploy with inputs from CSV file. This task can be done from FlexDeploy UI, but it is good idea to use REST API to speed up the configuration process. We will use POST method of Source Control Management Instance API.
For example, I have prepared CSV file with 10 Git Integrations with columns for Code, Name and URL to be used in FlexDeploy Git Integration. In this example, I am using same user ID and password for all Git repositories but you can always adjust this script as necessary.
Adjust run.sh file (shown below) for various properties like FD_HOST, FD_PORT, FD_USER, FD_PASSWORD, GITUSER and GITPASSWORD. When you run this script, it will invoke FlexDeploy REST API to create Git Integration configurations with data from scm.csv file.
Here is sample scm.csv file.
DEMO1,Demo1,https://github.com/flexagon9/demo1.git DEMO2,Demo2,https://github.com/flexagon9/demo2.git DEMO3,Demo3,https://github.com/flexagon9/demo3.git DEMO4,Demo4,https://github.com/flexagon9/demo4.git DEMO5,Demo5,https://github.com/flexagon9/demo5.git DEMO6,Demo6,https://github.com/flexagon9/demo6.git DEMO7,Demo7,https://github.com/flexagon9/demo7.git DEMO8,Demo8,https://github.com/flexagon9/demo8.git DEMO9,Demo9,https://github.com/flexagon9/demo9.git DEMO10,Demo10,https://github.com/flexagon9/demo10.git
run.sh code that will use scm.csv file.
FD_HOST=fdtlt05.flexagon FD_PORT=8000 FD_USER=fdadmin FD_PASSWORD=welcome1 GITUSER=flexagon9 GITPASSWORD=pAssword export IFS="," cat scm.csv | while read CODE NAME GITURL do echo Create FlexDeploy Git Connection using $CODE $NAME $GITURL curl -u $FD_USER:$FD_PASSWORD -i -X POST -H "Content-Type:application/json" http://$FD_HOST:$FD_PORT/flexdeploy/rest/v1/topology/integrations/scminstance -d '{"instanceName":"'$NAME'","properties":[{"propertyName":"FDGIT_URL","propertyValue":"'$GITURL'"},{"propertyName":"FDGIT_USER","propertyValue":"'$GITUSER'"},{"propertyName":"FDGIT_PASSWORD","propertyValue":"'$GITPASSWORD'"}],"scmType":"GIT","instanceCode":"'$CODE'","isActive":true}' done
There are many possibilities with API, this was just a simple example for API usage.