shell script is unable to create workspace in eclipse che

6/19/2019

i have written a shell script to create a workspace in eclipse che. the script is generating the workspace url. but when i open it, workspace does not exit. Am i missing on something?

#!/bin/sh
#=========================================================================

repo_url=$1
branch_name=$2
ip_addr=$3
#echo $repo_url
#B="$(cut -d'/' -f4 <<<$repourl)"
temp_var="$(echo $repo_url | cut -d'/' -f5)"
repo_name="$(echo $temp_var | cut -d '.' -f1)"

#rm /opt/stackstorm/packs/jenkins/template/latest_template
sudo cp /opt/stackstorm/packs/dev_prediction/actions/latest_template.sh /opt/stackstorm/packs/dev_prediction/template/
#sed -i "s/repourl/$repo_url/g;s/branchname/$branch_name/g;s/reponame/$repo_name/g;s/ipaddr/$ip_addr/g" latest_template

sudo sed -i "s@repourl@$repo_url@g;s@branchname@$branch_name@g;s@reponame@$repo_name@g;s@ipaddr@$ip_addr@g" /opt/stackstorm/packs/dev_prediction/template/latest_template.sh
sudo chmod u+x /opt/stackstorm/packs/dev_prediction/template/latest_template.sh
#cat /opt/stackstorm/packs/jenkins/template/latest_template
sudo sh /opt/stackstorm/packs/dev_prediction/template/latest_template.sh > /dev/null
sudo rm /opt/stackstorm/packs/dev_prediction/template/latest_template.sh

echo "http://$ip_addr/dashboard/#/ide/admin/$repo_name-$branch_name"

Expected and Actual URL: "http://URL.ap-south-1.elb.amazonaws.com/dashboard/#/ide/admin/petclinic-new-AIAS-37"

-- Vageesh S M
docker-container
eclipse-che
kubernetes
linux
shell

1 Answer

6/19/2019

I don't actually follow... From what I can see here, you are just generating URL, but you are not creating a workspace. Was that done before?

To open a workspace by accessing URL of the workspace, the workspace has to exist first ;-)

If you are looking on how to create workspace from script, you can use REST API endpoints for that. In default Eclipse Che deployment, we are also deploying swagger on URL /swagger (in your case "http://URL.ap-south-1.elb.amazonaws.com/swagger"), so you can take a look at all the API endpoints for yourself.

The most interesting for you might be:

POST to <cheUrl>/api/devfile to create a workspace from devfile (new, Che 7 workspace definition file)

POST to <cheUrl>/api/workspace to create workspace from Che 6 workspace definition json.

Hope this helps.

Radim

-- rax
Source: StackOverflow