The script functionality helps fully provision workspaces at startup so that you can start to code as soon as the workspace is ready without worrying about any additional configuration.
How does it work:
At the end of the template creation/edit page, you will see a script field. Any commands added to this field will be executed at the end of your workspace creation process.
As scripts within Nimbus are currently in Alpha, some script formats/functionalities may not be exactly the same as how you do so on your local machine.
Currently, we recommend using an existing script runner and storing your scripts in an external Git repo that you can synchronize with Nimbus as this will let you use the script field dynamically based on the sync’d Git repo.
Simply follow these instructions when editing or creating a template to operate as recommended:
- Connect that Git repo in the
repository
section
- in
scripts
input field, write the following commands cd <repo>
bash <your script path>
Once this is done, Nimbus will invoke that script during workspace creation.
FAQ:
When will the script be executed?
The script will be executed as the last step of your workspace creation. In other words, it will be executed after your repos are cloned and the selected packages are installed.
What are the limitations?
- Rule of thumb: think of the script as a bash script file that should complete in under 5 minutes. If your commands can be executed within a bash script, it will work with Nimbus.
- The script input acts as a single command input for bash with a max running time of 5 minutes. How it works under the hood is that all the commands will be combined into one line and executed with `eval` in bash
- Commands that start another session will interrupt your script. For example, if you add `npm start` in the scripts input field, your script may not run correctly
- All commands will be run under the same context (i.e. specific shell session). The commands run sequentially. For example, if you have the following three commands, the third one will fail because the third command will be run under `new_directory` but that directory is empty so `cd: no such file or directory: new_directory` error will be thrown.
- mkdir new_directory
- cd new_directory
- cd new_directory
Where can I see the script output or error log?
You can find the log at `/var/log/nimbus/user-script` in your workspace