How to auto-configure workspaces on creation


I can use a template (e.g. php) to setup an environment for my project. However, there are often a set of steps that need to be executed to go from a cloning the project to a fully functional workspace. Is there a way to have a template or a script to be executed whenever a new workspace is created based on the project? Hence, reducing the manual work to be done each time?

I can imagine that in some cases this can be a defined as part of the git repository, but in other cases, it would be useful to have this outside the repository (e.g. if not the whole team is using c9 – e.g. open source project). Another scenario for having it outside the project is if the setup steps include sensitive information (e.g. sendgrid credentials).

Is there a way to do this?



We are working on better solutions on this, more coming up on that in the near future.
But for now I can only recommend looking into git hooks, or simply adding a little script to your repository.



I had the same problem and solved it by writing an init script. Every Cloud9 user has it’s own init script. The init script runs as soon as you open the Cloud9 IDE and is able to execute commands on your workspace by using APIs provided by Cloud9. You can edit your own init script by clicking this menu entry:

My init script (which can be found here) clones a specific repository from GitHub to ~/c9-scripts and then runs ~/c9-scripts/install, which adds ~/c9-scripts/autoexec to ~/.bashrc and ~/.profile. If the clone (~/c9-scripts) already exists, it does a git pull. ~/c9-scripts/autoexec adds several directories from ~/c9-scripts to $PATH.

So, why all the effort? After I create a new workspace, all I have to do is type a command like install_appengine_go into a terminal, and my newly created workspace gets prepared for my needs.

I can easily add new install scripts by adding them to the GitHub repository, and my Cloud9 init script keeps the clones (~/c9-scripts directories inside my Cloud9 workspaces) up do date by doing git pull each time I open the IDE.

The c9-scripts-Project is open source & MIT licensed, you can either fork it or create a pull request to add your own install scripts.