Wildfly Maven plugin + hot deployment - maven

I have a Java Spring application, configured in Eclipse Mars and I am running Wildfly 9 from with in Eclipse. I am using the wildfly-maven-plugin to deploy to server.
These are the steps I follow:
Start the server from eclipse and do Maven build which also deploys the application to server. I can see whole lot of logs on server of "successful deployment"and I can access my application in browser. It creates a folder under "/standalone/data/content" but no war or exploded WAR under "standalone/deployments"
If I change some code and save it in eclipse, (I have checked Automatically publish check box and build on save), The sever logs says: Replaced deployment "myApp.war" with deployment "myApp.war" Content removed from location "standalone\data\content..."
And I see the prev folder created during step 1 is removed and myApp.war is added to deployment folder. But now I can not access my application in browser.
auto-deploy-exploded="true"
That is in the section of standalone.xml.

The wildfly-maven-plugin deploys applications using management operations. It doesn't deploy any exploded content only the archive. In other words you'd need to recreate the deployment archive before you redeploy otherwise changes won't be seen.
As #ozOli says it's probably best to use JBoss Tools.
There is an open issue to allow exploded content to be deployed. This is currently suggested only for the run goal, but it could likely be expanded to deploy exploded content as well. I think deploying exploded content works.
In general though the issue with "hot deployments" is source needs to be recompiled and then redeployed. The redploy is key as annotations and such need to be rescanned.

For Eclipse you can use the JBoss Tools plugins: http://tools.jboss.org/

Wildfly has administrative REST support. No need for fancy tools.
Here is a BASH script for Wildfly and Glassfish auto-redeploy of Maven projects, ie. when working with auto-compile in Eclipse:
set -x
pubname=$1
usewar=$2
if [[ -z $pubname ]]; then
pubname=ROOT
fi
if [[ -z "$usewar" ]]; then
usewar=0
else
usewar=1
fi
if ! webappdir=$(ls -d `pwd`/target/*-SNAPSHOT); then
webappdir=$(pwd)
fi
iswildfly=0
ctxroot="/$pubname"
if [[ "$pubname" == "ROOT" ]]; then
ctxroot="/"
fi
port=4848
if curl http://localhost:9991/ ; then
port=9991
iswildfly=1
elif curl http://localhost:9990/ ; then
port=9990
iswildfly=1
fi
if (( usewar )); then
webappdir=$webappdir.war
if ! (( iswildfly )); then
webappdir="#"$webappdir
fi
fi
wildflycmd() {
local cmd=$1
curl --retry 100 --retry-delay 3 --retry-connrefused --digest -L -u admin:admin -D - http://localhost:$port/management \
--header "Content-Type: application/json" \
-d "$cmd"
}
if (( iswildfly )); then
wildflycmd '{"operation" : "composite", "address" : [], "steps" : [{"operation" : "undeploy", "address" : {"deployment" : "'$pubname'.war"}},{"operation" : "remove", "address" : {"deployment" : "'$pubname'.war"}}],"json.pretty":1}'
if (( usewar )); then
wildflycmd '{"operation" : "composite", "address" : [], "steps" : [{"operation" : "add", "address" : {"deployment" : "'$pubname'.war"}, "content" : [{"url" : "file:'$webappdir'"}]},{"operation" : "deploy", "address" : {"deployment" : "'$pubname'.war"}}],"json.pretty":1}'
else
wildflycmd '{"operation" : "composite", "address" : [], "steps" : [{"operation" : "add", "address" : {"deployment" : "'$pubname'.war"}, "content" : [{"path" : "'$webappdir'", "archive":"false"}]},{"operation" : "deploy", "address" : {"deployment" : "'$pubname'.war"}}],"json.pretty":1}'
fi
fi
inotifyEvents=""
if ! [[ "$(uname)" =~ ^CYGWIN ]]; then
inotifyEvents="-e close_write"
fi
while inotifywait $inotifyEvents -r $webappdir --excludei "\.(js|html|css)$" || :; do
if ! (( iswildfly )); then
curl -v -H 'Accept: application/json' \
-X POST \
-H 'X-Requested-By: loadr' \
-F force=true \
-F id=$webappdir \
-F isredeploy=true \
-F virtualservers=server \
-F contextRoot=$ctxroot \
-F name=$pubname \
http://localhost:$port/management/domain/applications/application
else
wildflycmd '{"operation" : "composite", "address" : [], "steps" : [{"operation" : "redeploy", "address" : {"deployment" : "'$pubname'.war"}}],"json.pretty":1}'
fi
done
Just start the Wildfly instance with mvn clean wildfly:run.
Source: https://github.com/jjYBdx4IL/snippets/blob/master/java/jee_autodeploy.sh

Related

Download iCloud file from shared link using bash

I want to download a file from iCloud. I can share a link to a file. However the file is not directly linked in the urls, but the "real" download url can be retrieved:
#!/bin/bash
# given "https://www.icloud.com/iclouddrive/<ID>#<Filename>
ID="...."
URL=$(curl 'https://ckdatabasews.icloud.com/database/1/com.apple.cloudkit/production/public/records/resolve' \
--data-raw '{"shortGUIDs":[{"value":"$ID"}]}' --compressed \
jq -r '.results[0].rootRecord.fields.fileContent.value.downloadURL')
curl "$URL" -o myfile.ext
Sorce: https://gist.github.com/jpillora/702ded79330043e38e8202b5c73835e5
"fileContent" : {
"value" : {
...
"downloadURL" : "https://cvws.icloud-content.com/B/CYo..."
},
This is, however not working:
rl: (6) Could not resolve host: jq
curl: (3) nested brace in URL position 17:
{
"results" : [ {
"shortGUID" : {
"value" : "$ID",
"shouldFetchRootRecord" : true
},
"reason" : "shortGUID cannot be null or empty",
"serverErrorCode" : "BAD_REQUEST"
} ]
}
Any ideas, what I can do to make this work?
as #dan mentioned, jq is not a curl argument, its a separate command. hence you would need to | pipe it instead of \.
So the command would look something like this:
URL=$(curl 'https://ckdatabasews.icloud.com/database/1/com.apple.cloudkit/production/public/records/resolve' \ --data-raw '{"shortGUIDs":[{"value":"$ID"}]}' --compressed | jq -r '.results[0].rootRecord.fields.fileContent.value.downloadURL')
I solved it by installing jq and adding the ID directly instead of using $id. Just installing jq was not sufficient.
brew install jq
#!/bin/bash
# given "https://www.icloud.com/iclouddrive/<ID>#<Filename>
URL=$(curl 'https://ckdatabasews.icloud.com/database/1/com.apple.cloudkit/production/public/records/resolve' \
--data-raw '{"shortGUIDs":[{"value":"ID"}]}' --compressed | jq -r '.results[0].rootRecord.fields.fileContent.value.downloadURL')
Echo $url
curl "$URL" -o myfile.ext

Jenkins pipeline stage build is green even though an error is present

I have a Jenkins Pipline with three stages: "Build" "Test" and "Deploy".
Here is the problem I have with "Build":
The build step ensures that structure of the Control-M Automation API json files are valid.
To do this, I utilize the $endpoint/build service provided by Automation API in the build step:
stage('Build') {
environment {
CONTROLM_CREDS = credentials('xxx')
ENDPOINT = 'xxx'
}
steps {
sh '''
username=$CONTROLM_CREDS_USR
password=$CONTROLM_CREDS_PSW
# Login
login=$(curl -k -s -H "Content-Type: application/json" -X POST -d \\{\\"username\\":\\"$username\\",\\"password\\":\\"$password\\"\\} "$ENDPOINT/session/login" )
token=$(echo ${login##*token\\" : \\"} | cut -d '"' -f 1)
# Build
curl -k -s -H "Authorization: Bearer $token" -X POST -F "definitionsFile=#ctmjobs/TestCICD.json" "$ENDPOINT/build"
curl -k -s -H "Authorization: Bearer $token" -X POST "$ENDPOINT/session/logout"
'''
}
}
<snip>
Everything works as expected, but if I intentionally put an error in the json file, Jenkins detects it and prints the error in the terminal, but "Build" still goes green. Can anyone identify the error? My expectation is that the stage "Build" goes to red as soon as there is an error in the JSON file.
Here is a Jenkins output from the terminal:
+ password=****
++ curl -k -s -H 'Content-Type: application/json' -X POST -d '{"username":"xxx","password":"****"}' /automation-api/session/login
+ login='{
"username" : "xxx",
"token" : "xxx",
"version" : "9.19.200"
}'
++ echo 'xxx",
' '"version"' : '"9.19.200"
' '}'
++ cut -d '"' -f 1
+ token=xxx
+ curl -k -s -H 'Authorization: Bearer xxx' -X POST -F definitionsFile=#ctmjobs/Test.json /automation-api/build
{
"errors" : [ {
"message" : "unknown type: Job:Dummmy",
"file" : "Test.json",
"line" : 40,
"col" : 29
}, {
"message" : "unknown type: Job:Dummmy",
"file" : "Test.json",
"line" : 63,
"col" : 29
} ]
}+ curl -k -s -H 'Authorization: Bearer xxx' -X POST /automation-api/session/logout
{
"message" : "Successfully logged out from session xxx"
} ``
Jenkins in order to consider a stage as failed, it will check the exit code of a command executed, in your case
curl -k -s -H 'Authorization: Bearer xxx' -X POST -F definitionsFile=#ctmjobs/Test.json /automation-api/build
The issue is that the curl, as a command, is executed successfully.
But the body of the curl indicates that the api call failed.
You could add --fail flag to your curl. This will force curl to return an erroneous exit code when the response status is > 400
(HTTP) Fail silently (no output at all) on server errors. This is
mostly done to enable scripts etc to better deal with failed attempts.
In normal cases when an HTTP server fails to deliver a document, it
returns an HTML document stating so (which often also describes why
and more). This flag will prevent curl from outputting that and return
error 22.
curl --show-error --fail -k -H 'Authorization: Bearer xxx' -X POST -F definitionsFile=#ctmjobs/Test.json /automation-api/build

How to upload an asset from Azure Release pipeline to Github Enterprise using Bash

Since the company I work for will not allow any non-Microsoft released packages from the Azure Marketplace, I need to create a bash script to be able to upload my built/published asset to the Github Enterprise repo. For some reason I always get redirected when I try to get the info of a release tag, be it a specific tag or latest, does not matter.
The following is my script:
set -e
xargs=$(which gxargs || which xargs)
# Validate settings.
[ "$TRACE" ] && set -x
CONFIG=$#
for line in $CONFIG; do
eval "$line"
done
# Define variables.
GH_API="https://git.[company].com/api/v3"
GH_REPO="$GH_API/repos/[owner]/$(Build.Repository.Name)"
GH_TAGS="$GH_REPO/releases/tags/$(Build.SourceBranchName)"
AUTH="Authorization: token $github_api_token"
WGET_ARGS="--content-disposition --auth-no-challenge --no-cookie"
CURL_ARGS="-LJO#"
tag="$(Build.SourceBranchName)"
filename="BaseRepoName_$(Build.SourceBranchName)_$(Build.BuildId).zip"
echo "tag is: $tag"
echo $AUTH
echo "Repo: $GH_REPO"
if [[ "$tag" == 'LATEST' ]]; then
GH_TAGS="$GH_REPO/releases/latest"
fi
echo "Tags url: $GH_TAGS"
echo "Validate token ..."
# Validate token.
curl -o /dev/null -sH "$AUTH" $GH_REPO || { echo "Error: Invalid repo, token or network issue!"; exit 1; }
echo "Get api endpoints"
apiresponse=$(curl -sH "$AUTH" "$GH_API")
echo "API: $apiresponse"
echo "Read asset tags: curl -sH "$AUTH" $GH_TAGS"
# Read asset tags.
response=$(curl -sH "$AUTH" $GH_TAGS)
echo "Response: $response"
## In case of success, we upload a file
upload=$(echo $succ | grep upload_url)
if [[ $? -eq 0 ]]; then
echo Release created.
else
echo Error creating release!
return
fi
echo "Get the upload url for the given tag"
upload=$(echo $upload | cut -d "\"" -f4 | cut -d "{" -f1)
upload="$upload?name=$filename"
# Upload asset
echo "Uploading asset... "
succ=$(curl -H "Authorization: token $perstok" \
-H "Content-Type: $(file -b --mime-type $filename)" \
--data-binary #$filename $upload)
The logs of the Bash task:
2020-03-13T05:53:35.4274045Z ##[section]Starting: Bash Script
2020-03-13T05:53:35.4654068Z ==============================================================================
2020-03-13T05:53:35.4654773Z Task : Bash
2020-03-13T05:53:35.4655254Z Description : Run a Bash script on macOS, Linux, or Windows
2020-03-13T05:53:35.4655535Z Version : 3.163.1
2020-03-13T05:53:35.4656320Z Author : Microsoft Corporation
2020-03-13T05:53:35.4656864Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/bash
2020-03-13T05:53:35.4657312Z ==============================================================================
2020-03-13T05:53:36.4699984Z Generating script.
2020-03-13T05:53:36.4703019Z [command]"C:\Program Files\Git\bin\bash.exe" --noprofile --norc -c pwd
2020-03-13T05:53:36.8704279Z /d/a/_temp
2020-03-13T05:53:36.8755504Z
2020-03-13T05:53:36.8794400Z ========================== Starting Command Output ===========================
2020-03-13T05:53:36.8801355Z [command]"C:\Program Files\Git\bin\bash.exe" --noprofile --norc /d/a/_temp/c7a40af4-c1f2-4127-a2cf-4aa11ac19e48.sh
2020-03-13T05:53:36.9965374Z which: no gxargs in (/mingw64/bin:/usr/bin:/c/Users/VssAdministrator/bin:/c/hostedtoolcache/windows/Python/3.6.8/x64:/c/hostedtoolcache/windows/Python/3.6.8/x64/Scripts:/c/Program Files/Mercurial:/c/ProgramData/kind:/c/vcpkg:/c/cf-cli:/c/Program Files (x86)/NSIS:/c/Program Files/Mercurial:/c/hostedtoolcache/windows/Boost/1.69.0:/c/Program Files/dotnet:/c/mysql-5.7.21-winx64/bin:/c/Program Files/Java/zulu-8-azure-jdk_8.40.0.25-8.0.222-win_x64/bin:/c/SeleniumWebDrivers/GeckoDriver:/c/Program Files (x86)/sbt/bin:/c/Rust/.cargo/bin:/c/hostedtoolcache/windows/Ruby/2.5.7/x64/bin:/c/Go1.12.7/bin:/bin:/c/hostedtoolcache/windows/Python/3.6.8/x64/Scripts:/c/hostedtoolcache/windows/Python/3.6.8/x64:/c/npm/prefix:/c/Program Files (x86)/Microsoft SDKs/Azure/CLI2/wbin:/c/Program Files/Microsoft MPI/Bin:/c/windows/system32:/c/windows:/c/windows/System32/Wbem:/c/windows/System32/WindowsPowerShell/v1.0:/c/ProgramData/Chocolatey/bin:/c/Program Files/Docker:/c/Program Files/PowerShell/7:/c/Program Files/dotnet:/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/c/Program Files (x86)/Microsoft SQL Server/110/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/120/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/130/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/140/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/150/DTS/Binn:/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit:/c/Program Files/Microsoft Service Fabric/bin/Fabric/Fabric.Code:/c/Program Files/Microsoft SDKs/Service Fabric/Tools/ServiceFabricLocalClusterManager:/c/Program Files/nodejs:/c/Strawberry/c/bin:/c/Strawberry/perl/site/bin:/c/Strawberry/perl/bin:/cmd:/mingw64/bin:/usr/bin:/c/tools/php:/c/Program Files (x86)/sbt/bin:/c/Program Files (x86)/Subversion/bin:/c/SeleniumWebDrivers/ChromeDriver:/c/SeleniumWebDrivers/EdgeDriver:/c/ProgramData/chocolatey/lib/maven/apache-maven-3.6.3/bin:/c/Program Files/CMake/bin:/c/Program Files/OpenSSL/bin:/c/Users/VssAdministrator/.dotnet/tools:/c/Program Files (x86)/Microsoft SQ)
2020-03-13T05:53:37.0042653Z tag is: MBP_TestTag6
2020-03-13T05:53:37.0043260Z Authorization: token [Edited: secret]
2020-03-13T05:53:37.0043852Z Repo: https://git.[company].com/api/v3/repos/[owner]/[MyTestRepo]
2020-03-13T05:53:37.0044723Z Tags url: https://git.[company].com/api/v3/repos/[owner]/[MyTestRepo]/releases/tags/MBP_TestTag6
2020-03-13T05:53:37.0045218Z Validate token ...
2020-03-13T05:53:38.5703717Z Get api endpoints
2020-03-13T05:53:38.8038551Z API: {
2020-03-13T05:53:38.8050142Z "current_user_url": "https://git.[company].com/api/v3/user",
2020-03-13T05:53:38.8053206Z "current_user_authorizations_html_url": "https://git.[company].com/settings/connections/applications{/client_id}",
2020-03-13T05:53:38.8060689Z "authorizations_url": "https://git.[company].com/api/v3/authorizations",
2020-03-13T05:53:38.8064874Z "code_search_url": "https://git.[company].com/api/v3/search/code?q={query}{&page,per_page,sort,order}",
2020-03-13T05:53:38.8071647Z "commit_search_url": "https://git.[company].com/api/v3/search/commits?q={query}{&page,per_page,sort,order}",
2020-03-13T05:53:38.8073059Z "emails_url": "https://git.[company].com/api/v3/user/emails",
2020-03-13T05:53:38.8074445Z "emojis_url": "https://git.[company].com/api/v3/emojis",
2020-03-13T05:53:38.8075767Z "events_url": "https://git.[company].com/api/v3/events",
2020-03-13T05:53:38.8077032Z "feeds_url": "https://git.[company].com/api/v3/feeds",
2020-03-13T05:53:38.8078149Z "followers_url": "https://git.[company].com/api/v3/user/followers",
2020-03-13T05:53:38.8079345Z "following_url": "https://git.[company].com/api/v3/user/following{/target}",
2020-03-13T05:53:38.8080572Z "gists_url": "https://git.[company].com/api/v3/gists{/gist_id}",
2020-03-13T05:53:38.8081548Z "hub_url": "https://git.[company].com/api/v3/hub",
2020-03-13T05:53:38.8082418Z "issue_search_url": "https://git.[company].com/api/v3/search/issues?q={query}{&page,per_page,sort,order}",
2020-03-13T05:53:38.8083431Z "issues_url": "https://git.[company].com/api/v3/issues",
2020-03-13T05:53:38.8084430Z "keys_url": "https://git.[company].com/api/v3/user/keys",
2020-03-13T05:53:38.8086272Z "label_search_url": "https://git.[company].com/api/v3/search/labels?q={query}&repository_id={repository_id}{&page,per_page}",
2020-03-13T05:53:38.8091275Z "notifications_url": "https://git.[company].com/api/v3/notifications",
2020-03-13T05:53:38.8092166Z "organization_repositories_url": "https://git.[company].com/api/v3/orgs/{org}/repos{?type,page,per_page,sort}",
2020-03-13T05:53:38.8093095Z "organization_url": "https://git.[company].com/api/v3/orgs/{org}",
2020-03-13T05:53:38.8096487Z "public_gists_url": "https://git.[company].com/api/v3/gists/public",
2020-03-13T05:53:38.8097620Z "rate_limit_url": "https://git.[company].com/api/v3/rate_limit",
2020-03-13T05:53:38.8098584Z "repository_url": "https://git.[company].com/api/v3/repos/{owner}/{repo}",
2020-03-13T05:53:38.8100945Z "repository_search_url": "https://git.[company].com/api/v3/search/repositories?q={query}{&page,per_page,sort,order}",
2020-03-13T05:53:38.8102239Z "current_user_repositories_url": "https://git.[company].com/api/v3/user/repos{?type,page,per_page,sort}",
2020-03-13T05:53:38.8104230Z "starred_url": "https://git.[company].com/api/v3/user/starred{/owner}{/repo}",
2020-03-13T05:53:38.8104831Z "starred_gists_url": "https://git.[company].com/api/v3/gists/starred",
2020-03-13T05:53:38.8105328Z "team_url": "https://git.[company].com/api/v3/teams",
2020-03-13T05:53:38.8105772Z "user_url": "https://git.[company].com/api/v3/users/{user}",
2020-03-13T05:53:38.8106279Z "user_organizations_url": "https://git.[company].com/api/v3/user/orgs",
2020-03-13T05:53:38.8106871Z "user_repositories_url": "https://git.[company].com/api/v3/users/{user}/repos{?type,page,per_page,sort}",
2020-03-13T05:53:38.8107491Z "user_search_url": "https://git.[company].com/api/v3/search/users?q={query}{&page,per_page,sort,order}"
2020-03-13T05:53:38.8108556Z }
2020-03-13T05:53:38.8109344Z Read asset tags: curl -sH Authorization: token [Edited: Secret] https://git.[company].com/api/v3/repos/[owner]/[MyTestRepo]/releases/tags/MBP_TestTag6
2020-03-13T05:53:39.0378180Z Response: {
2020-03-13T05:53:39.0379040Z "message": "Not Found",
2020-03-13T05:53:39.0379599Z "documentation_url": "https://developer.github.com/enterprise/2.20/v3/repos/releases/#get-a-release-by-tag-name"
2020-03-13T05:53:39.0380100Z }
2020-03-13T05:53:39.2992296Z
2020-03-13T05:53:39.3060923Z ##[error]Bash exited with code '1'.
2020-03-13T05:53:39.3120104Z ##[section]Finishing: Bash Script
As you can see from the logs it always fails when calling the api to get the info of the supplied tag (or even latest tag).
Any idea why the system is trying to redirect me?
You should make changes on this line:
GH_API="https://git.[company].com/api/v3"
To
GH_API="https://api.github.com"
The problem that I experienced has to do with the way Git handles releases. In this case there was a Pre-Release (Release name/Tag: v0.0.1), which is what I got back when querying for all releases. As soon as I deleted this pre-release I got back nothing, but then realized that none of the other 'releases' were ever published.
After publishing a couple of releases I then finally got back a list of published releases. All other commands then worked as expected as well.
So, no sinister problems or bugs. Just some minor mistakes from a DevOps pipeline newbie.

How do I create a .bash_profile alias for a GroupMe bot's message command

I have a GroupMe bot that can send messages to the chat it is assigned to in this format:
curl -d '{"text" : "text", "bot_id" : "(REDACTED)"}' https://api.groupme.com/v3/bots/post
So, instead of typing up this monstrosity every time I wanted to send a message, I decided to create an alias for it.
Here is what I attempted to use in my .bash_profile for this:
alias groupmessage=groupmessagefunction
groupmessagefunction() { curl -d '{"text" : $1, "bot_id" : "(REDACTED)"}' https://api.groupme.com/v3/bots/post; }
Could anyone inform me what the correct formatting would be to get this to work? Thanks!
Update 1:
I now have my code as follows:
v="bot_id_string"
alias groupmessage=groupmessagefunction
groupmessagefunction() { curl -d '{"text" : '"$1"', "bot_id" : '"$v"'}' https://api.groupme.com/v3/bots/post; }
I would like to point out that what I am trying to accomplish is type in something like:
groupmessage "hello"
or
groupmessage hello
Then, it will send out the following command:
curl -d '{"text" : "hello", "bot_id" : "bot_id_string"}' https://api.groupme.com/v3/bots/post
I hope this helps clarify this question if any misunderstanding occurred.
Now, I hope this will be the solution for you:
v=bot_id
curl -d '{"text" : "Test", "'$v'" : "(REDACTED)"}' api.groupme.com/v3/bots/post
You have to use ' ' around $v --> '$v' because this will allow bash to evaluate $v inside curl -d ' ... ' .
Answer for your Update 1
As I see it would be the better way to use eval command:
v="bot_id_string"
alias groupmessage=groupmessagefunction
groupmessagefunction() {
a="curl -d '{\"text\" : \"$1\", \"bot_id\" : \"$v\"}' https://api.groupme.com/v3/bots/post"
echo "$a" # this echo just for checking
eval "$a"; }
groupmessage "Hello is it working now ?"

Sample code to deploy docker container on Jelastic

Can anyone provide sample code to deploy docker container on Jelastic? I was reading Jelastic official API document, it looks like this piece of information is missing.
Many thanks!
This is a sample of the creating new environment using bash:
#!/bin/bash
hoster_api_url='app.cloudplatform.hk'
platform_app_id='77047754c838ee6badea32b5afab1882'
email=''
password=''
docker_image='tutum/wordpress'
docker_tag='latest'
env_name='testenv-'$(((RANDOM % 10000) + 1))
WORK_DIR=$(dirname $0)
LOG="$WORK_DIR/$hoster_api_url.log"
log() {
echo -e "\n$#" >>"$LOG"
}
login() {
SESSION=$(curl -s "http://$hoster_api_url/1.0/users/authentication/rest/signin?appid=$platform_app_id&login=$email&password=$password" | \
sed -r 's/^.*"session":"([^"]+)".*$/\1/')
[ -n "$SESSION" ] || {
log "Failed to login with credentials supplied"
exit 0
}
}
create_environment() {
log "=============================== START CREATING $env_name | $(date +%d.%m.%y_%H-%M-%S) ==============================="
request='nodes=[{"nodeType":"docker","extip":false,"count":1,"fixedCloudlets":1,"flexibleCloudlets":16,"fakeId":-1,"dockerName":"'$docker_image'","dockerTag":"'$docker_tag'","displayName":"'$docker_image':'$docker_tag'","metadata":{"layer":"cp"}}]&env={"pricingType":"HYBRID","region":"default_region","shortdomain":"'$env_name'"}&actionkey=createenv;'$env_name'&appid='$platform_app_id'&session='$SESSION
log "$request"
curl -s -X POST --data $request "https://$hoster_api_url/1.0/environment/environment/rest/createenvironment" >> "$LOG"
log "=============================== STOP CREATING $env_name | $(date +%d.%m.%y_%H-%M-%S) ==============================="
}
login
create_environment
Also you can see Samples there

Resources