Deploy plugin tutorial
This tutorial will explain the basic case of deploying a file to a target Container and doing something on the target Container with that file.
Define the new type
Open the synthetic.xml file that is located under the Deploy server ext folder and put the following new type definition in it:
...
<type type="cp.Server" extends="generic.Container">
<property name="home" default="/opt/cp/container"/>
<property name="targetDirectory" default="${container.home}/apps" hidden="true"/>
</type>
<type type="cp.DeployedApp" extends="generic.ExecutedScriptWithDerivedArtifact" deployable-type="cp.App"
container-type="cp.Server">
<generate-deployable type="cp.App" extends="generic.Archive"/>
<property name="createScript" default="cp/install-app.sh" hidden="true"/>
<property name="modifyScript" default="cp/reinstall-app.sh" hidden="true"/>
<property name="destroyScript" default="cp/uninstall-app.sh" hidden="true"/>
</type>
...
Start (or restart) the Deploy server, and open the UI.
- Go to the repository view and create a new
overthere.LocalHostunder Infrastructure. - Right click on the just created
overthere.LocalHostand create a newcp.Serverunder it. - Notice that you can set the
homeproperty as defined in thesynthetic.xml. - Right click on Applications and create a new
Application - Right click on the just created application and create a new
Deployment Package(1.0) under it. - Add under 1.0 a new deployable
cp.App - Upload an archive (zip, jar, ...) to it and click
Save.
Create the create, modify and destroy script
- Go into the
extfolder and create a directorycpunder it. - Put the following scripts under the
cpfolder:- install-app.sh
echo Installing archive ${deployed.deployable.file} in ${deployed.container.home} - reinstall-app.sh
echo reinstalling archive ${deployed.deployable.file} in ${deployed.container.home} - uninstall-app.sh
echo uninstalling archive ${deployed.deployable.file} in ${deployed.container.home}
- install-app.sh
- When modifying scripts, there's no need to restart the Deploy server.
Run the first deployment
- Go to the Deploy UI, and open the Repository view.
- Right click on
Environmentsand create a new environment. - Add the
cp.Servercreated in one of the previous steps to the Environment. - Open the deployment view in the UI.
- Deploy version
1.0to the new created environment and notice the echo messages. - If you want you can also try the rollback, modify and uninstall functionality.