Most organizations use separate servers for development vs. production. While developing your Visual Builder application you'll be accessing REST Services from the development server, but when you are preparing to go production you will likely want to switch the app to use the production version of the services. In the demo below I show you how to automate such a switch using build jobs in Oracle Developer Cloud as part of your continuous delivery process.
(If you aren't already, you should first get familiar with how to integrate Visual Builder with the Git repository in developer cloud, and how to use Developer Cloud to automate the CI/CD of a VB app).
The process is quite simple:
We are hosting the code for our application in a private Git repository in Developer Cloud. The code for our application includes service.json files for each of the REST services we are consuming in our app.
We can use a build job to take the code from the Git repository and stage or publish our app on any Visual Builder server. If we want to switch the REST service that we are accessing when we stage & publish, then we need to inject one more step into our build job - this step will modify the service.json file we got from the Git repository and will replace the service connection in the file before we execute the grunt tasks to stage/publish on our production instance.
In the demo below I use a linux sed command to do the switching. The basic command syntax is
sed -i 'originalText+modifiedText+g' filename
The filename above will refer to your service.json file. You can find the location of your service.json file by looking in the Git repository browser in Developer Cloud. It would be something like: services/shayService/service.json - where the bold part is the name you gave to your service when you defined it.
If all you need to switch is just the server name a single sed command will do, but if you also need to switch other parts of the service URL you might need more than one sed command. Have a look at your service.json file and identify any part that needs switching.
Check out the demo video to see this in action:
In the demo I have a VB app that uses an ORDS service exposing data in an Oracle ATP database. I have another database (the production instance) which has the same table but in another schema. So my build job switches the pointer to the server, and also the name of the schema (two sed commands). I have two build jobs - one uses the code as is to stage my app on my "dev" instance of VB, the other takes the same app and stages it on another VB instance pointing to the production DB.