The following is an example of using the Admin Interface API to automatically upload a Delft-FEWS configuration using an Azure DevOps pipeline. In a build pipeline a Config.zip is prepared as artifact.

In a release pipeline the config can be uploaded using the admin interface api using a bash script as in the following example.

echo 'Uploading the Delft-FEWS Config file'
# login and store session cookie
curl -u $(ApiUser):$(ApiKey) --dump-header headers.txt --cookie cookie.txt --cookie-jar cookie.txt $(AdminInterfaceApi)/login
csrfToken=$(cat headers.txt | grep X-CSRF-TOKEN: | cut -c15- | tr -d '\n' | tr -d '\r' )
echo 'uploading now ...'
curl -v -H "X-CSRF-TOKEN: ${csrfToken}"  --cookie cookie.txt -F file=@'$(System.DefaultWorkingDirectory)/_AzureDevopsRepo/drop/Config.zip' $(AdminInterfaceApi)/configmanagement/fewsconfig
curl --cookie cookie.txt $(AdminInterfaceApi)/systemstatus
curl --cookie cookie.txt $(AdminInterfaceApi)/logout
 
  • No labels