Preparing Management Scripts
In order to achieve the automatic development flow, Jenkins requires special instructions, that indicate what should be done during different application delivery stages. In our case, we’ll define the necessary actions within special scripts (one for each required operation), to easily call these complex processes by means of Jenkins jobs afterwards.
In such a way, the next step is to create and upload the appropriate scripts to the Jenkins container:
1. To start with, here is a set of script examples, which can be used as templates for your own ones:
- install.sh - gets a user session and creates a new environment via the platform API according to the specified manifest file. It also defines, that the name of this environment will be equal to its creation date and time (as a unique name is required for every script execution, but you won’t be able to set it manually as this operation would be run automatically). However, you can set your own dynamic name pattern to be used here
- transfer.sh - changes the environment ownership based on the platform environment transferring feature
- migrate.sh - physically moves an environment to another hardware set (hardnode group)
Note: Before the appliance, each of the script templates, presented above, have to be additionally adjusted to make them work properly within a particular PaaS installation. Thus, the list of parameters below should be obligatory substituted according to your platform’s settings:
- /path/to/scripts/ - the full path to the folder with your scripts (see the next step)
- {cloud_domain} - your platform domain name
- {admin_dashboard_appID} - your dashboard ID, that could be seen within the Platform.DASHBOARD_APPID parameter at the admin panel’s About section
- {admin_appstore_appID} - appstore ID, listed within the same section (at the Platform.APPSTORE_APPID parameter)
- {url_to_manifest} - link to the application manifest file created according to our documentation (you may also use this one as an example - it sets up two Tomcat application servers with the NGINX load-balancer in front of them)
2. When the scripts are ready, you need to upload them to the Jenkins container. The easiest way to do this is to establish connection via the SSH Gateway.
Tip: In the case you haven’t performed similar operations before, you need to:
- generate an SSH keypair
- add your public SSH key to the dashboard
- access your account via SSH protocol
Once inside, create a new folder for your project (we’ll use demo) and move in there:
|
|
This location can be used for storing your scripts, variables, logs, etc.
3. Here, you can upload the required scripts using the command of the following type:
|
|
4. In addition, you need to create a separate file for storing the variable with environment name (as it needs to be dynamically changed each time a new environment is created):
|
|
Now all the preparations are finished, so we can proceed to the core of automation - configure the set of jobs at the Jenkins server.