×
Back to book

SpringBot Development Environment: Source Code

SpringBot development environment: working on the codebase.

Applications can be run on multiple different environments. This article assumes that you are running your SpringBot application and updating the code within the same environment (machine). If you have followed the instructions for the virtual machine please refer to the SpringBot Development Environment: Source Code Virtual Machine.

Before getting started, you must have completed the setup of your development environment.

Where the source is stored

When an application is created on the Codebots Platform, a corresponding git repository is created and hosted by Codebots.

There are currently plans to allow self-nominated repositories to be included, Codebots Roadmap. This would allow you to provide your own git repository and access token details for an application, which would allow the codebot to write to your designated repository instead of a Codebots-owned repository).

When you are invited onto the platform, the Codebots support team will provide you with your access details. (This is currently a manual process. Please contact support if you have not received these details).

The login details for your account will work across any of the applications which are made on your site, despite them having different URLs.

As a general rule of thumb, your git repository URL will take the format of https://git.codebots.com/cb[subdomain]/[project-slug].git

When the source is updated

Hitting the 'Build Application' button from inside the Platform will trigger the codebot to build and write any changes to the application's git repository.

Currently, the codebot writes directly to the develop branch. If changes occur during the code writing process, the codebot will pull the latest changes and perform a git merge. If there are conflicts, the codebot will push the code with conflicts, and an status message indicating this will appear inside the Codebots Platform.

Setup project source

In order to download or pull your code from the source repository you will be required to download a git client which can either be one that uses the command line (recommended for experts) or a GUI.

If you prefer a git GUI you can find a many free and paid options available here.

For the purpose of this article we will make use of the command line (i.e, "Command Prompt" for windows, "Terminal" for Linux and Mac),but feel free to use your favourite git client.

Install Git

  1. Download Git from https://git-scm.com/downloads for your operating system.
  2. Follow the instructions to install
  3. Configure your details as shown in First Time Git Setup. We only really care about the email and name. e.g
    • git config --global user.name "John Doe"
    • git config --global user.email johndoe@example.com

Version Control

By cloning your application repository on your development environment, you can follow a simple set of git commands to update your application.

Setup

  1. Setup your application source code on your local environment

NB: It is best practice to store the source on an encrypted drive (setup not covered here). From this point on, on Windows it is assumed that G: is your encrypted drive, and on Mac or Linux your whole drive is encrypted.

a. Setup Project Drive or Directory

Windows

All project source files should be cloned in G:.

Mac or Linux

Create the directory /data/repository

sudo mkdir /data
cd /data
sudo mkdir repository
cd repository

b. Clone your repository (substituting in your provided git URL) and switch to the develop branch
The commands to enter to clone your application repository are:

cd [project drive or directory]
git clone https://git.codebots.com/cb[subdomain]/[project-slug].git
cd [project-slug]
git checkout develop

Update

  1. Make the changes to your application

  2. Commit those changes: git add . ; git commit -m "These are my changes"

  3. Make sure to pull in case of any other changes from other developers: git pull

  4. Push those changes to the remote git server: git push origin master

If all of the commands ran successfully, then the latest code should be in you remote git repository. You should now be able to pull those changes onto your server environment.