Commit a927a9bf authored by Gokmen Goksel's avatar Gokmen Goksel Committed by Stan Hu
Browse files

Support integration with Koding (online IDE)

Koding: #index: landing page for Koding integration

If enabled it will provide a link to open remote Koding instance url
for now we are also providing the sneak preview video for how
integration works in detail.

Repository: check whether .koding.yml file exists on repository

Projects: landing page: show Run in IDE (Koding) button if repo has stack file

Projects: MR: show Run in IDE Koding button if repo has stack file on active branch

ProjectHelpers: add_koding_stack: stack generator for provided project

With this helper we will auto-generate the required stack template
for a given project. For the feature we can request this base template
from the running Koding instance on integration.

Currently this will provide users to create a t2.nano instance on aws
and it'll automatically configures the instance for basic requirements.

Projects: empty state and landing page provide shortcuts to create stack

projects_helper: use branch on checkout and provide an entry point

This ${var.koding_queryString_branch} will be replaced with the branch
provided in query string which will allow us to use same stack template
for different branches of the same repository.


projects_helper: provide sha info in query string to use existing vms

With this change we'll be able to query existing vms on Koding side
based on the commit id that they've created.


Integration: Docs: Koding documentation added

Disable /koding route if integration is disabled

Use application settings to enable Koding

Projects_helper: better indentation with strip_heredoc usage

Projects_helper: return koding_url as is if there is no project provided

current_settings: set koding_enabled: false by default

Koding_Controller: to render not_found once integration is disabled

Dashboard_specs: update spec for Koding enabled case

Projects_Helper: make repo dynamic


Updated documentation to have right format
parent 1722aa6ba57f
......@@ -4,6 +4,7 @@ v 8.11.0 (unreleased)
- Use test coverage value from the latest successful pipeline in badge. !5862
- Add test coverage report badge. !5708
- Remove the http_parser.rb dependency by removing the tinder gem. !5758 (tbalthazar)
- Add Koding (online IDE) integration
- Ability to specify branches for Pivotal Tracker integration (Egor Lynko)
- Fix don't pass a local variable called `i` to a partial. !20510 (herminiotorres)
- Add delimiter to project stars and forks count (ClemMakesApps)
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="" viewBox="0 0 12 14">
<g fill="#d6d7d9">
<path d="M8.7 0L5.3.3l3.2 6.8-3.2 6.6 3.5.3L12 6.9z"/>
<ellipse cx="1.7" cy="11.1" rx="1.7" ry="1.7"/>
<ellipse cx="1.7" cy="5.6" rx="1.7" ry="1.7"/>
\ No newline at end of file
......@@ -109,6 +109,8 @@ def application_setting_params
class KodingController < ApplicationController
before_action :check_integration!, :authenticate_user!, :reject_blocked!
layout 'koding'
def index
path = File.join(Rails.root, 'doc/integration/')
@markdown =
def check_integration!
render_404 unless current_application_settings.koding_enabled?
......@@ -31,6 +31,10 @@ def askimet_enabled?
def koding_enabled?
def allowed_protocols_present?
......@@ -236,6 +236,60 @@ def add_special_file_path(project, file_name:, commit_message: nil)
def add_koding_stack_path(project)
project.default_branch || 'master',
file_name: '.koding.yml',
commit_message: "Add Koding stack script",
content: <<-CONTENT.strip_heredoc
access_key: '${var.aws_access_key}'
secret_key: '${var.aws_secret_key}'
instance_type: t2.nano
user_data: |-
# Created by GitLab UI for :>
echo _KD_NOTIFY_@Installing Base packages...@
apt-get update -y
apt-get install git -y
echo _KD_NOTIFY_@Cloning #{}...@
export KODING_USER=${var.koding_user_username}
export REPO_URL=#{root_url}${var.koding_queryString_repo}.git
export BRANCH=${var.koding_queryString_branch}
sudo -i -u $KODING_USER git clone $REPO_URL -b $BRANCH
echo _KD_NOTIFY_@#{} cloned.@
def koding_project_url(project = nil, branch = nil, sha = nil)
if project
import_path = "/Home/Stacks/import"
repo = project.path_with_namespace
branch ||= project.default_branch
sha ||= project.commit.short_id
path = "#{import_path}?repo=#{repo}&branch=#{branch}&sha=#{sha}"
return URI.join(current_application_settings.koding_url, path).to_s
def contribution_guide_path(project)
if project && contribution_guide = project.repository.contribution_guide
......@@ -55,6 +55,10 @@ class ApplicationSetting < ActiveRecord::Base
presence: true,
if: :akismet_enabled
validates :koding_url,
presence: true,
if: :koding_enabled
validates :max_attachment_size,
presence: true,
numericality: { only_integer: true, greater_than: 0 }
......@@ -149,6 +153,8 @@ def self.create_from_defaults
two_factor_grace_period: 48,
recaptcha_enabled: false,
akismet_enabled: false,
koding_enabled: false,
koding_url: nil,
repository_checks_enabled: true,
disabled_oauth_sign_in_sources: [],
send_user_confirmation_email: false,
......@@ -277,7 +277,7 @@ def diverging_commit_counts(branch)
def cache_keys
%i(size commit_count
readme version contribution_guide changelog
license_blob license_key gitignore)
license_blob license_key gitignore koding_yml)
# Keys for data on branch/tag operations.
......@@ -553,6 +553,14 @@ def gitignore
def koding_yml
return nil unless head_exists?
cache.fetch(:koding_yml) do
def gitlab_ci_yml
return nil unless head_exists?
......@@ -388,6 +388,25 @@
If you got a lot of false alarms from repository checks you can choose to clear all repository check information from the database.
%legend Koding
= f.label :koding_enabled do
= f.check_box :koding_enabled
Enable Koding
= f.label :koding_url, 'Koding URL', class: 'control-label col-sm-2'
= f.text_field :koding_url, class: 'form-control', placeholder: ''
Koding has integration enabled out of the box for the
%strong gitlab
team, and you need to provide that team's URL here. Learn more in the
= succeed "." do
= link_to "Koding integration documentation", help_page_path("integration/koding")
= f.submit 'Save', class: 'btn btn-save'
= icon('circle', class: 'cgreen')
Integration is active for
= link_to koding_project_url, target: '_blank' do
= markdown @markdown
- page_title "Koding"
- page_description "Koding Dashboard"
- header_title "Koding", koding_path
= render template: "layouts/application"
......@@ -12,6 +12,11 @@
= link_to activity_dashboard_path, class: 'dashboard-shortcuts-activity', title: 'Activity' do
- if koding_enabled?
= nav_link(controller: :koding) do
= link_to koding_path, title: 'Koding' do
= nav_link(controller: [:groups, 'groups/milestones', 'groups/group_members']) do
= link_to dashboard_groups_path, title: 'Groups' do
- if koding_enabled? && current_user && can_push_branch?(@project, @project.default_branch)
- if @repository.koding_yml
= link_to koding_project_url(@project), class: 'btn', target: '_blank' do
Run in IDE (Koding)
- else
= link_to add_koding_stack_path(@project), class: 'btn' do
Set Up Koding
......@@ -16,6 +16,9 @@
- if
- if @merge_request.source_branch_exists?
- if koding_enabled? && @repository.koding_yml
= link_to koding_project_url(@merge_request.source_project, @merge_request.source_branch, @merge_request.commits.first.short_id), class: "btn inline btn-grouped btn-sm", target: '_blank' do
Run in IDE (Koding)
= link_to "#modal_merge_info", class: "btn inline btn-grouped btn-sm", "data-toggle" => "modal" do
Check out branch
......@@ -64,10 +64,12 @@
= link_to add_special_file_path(@project, file_name: '.gitlab-ci.yml') do
Set Up CI
- if current_user
= render 'shared/members/access_request_buttons', source: @project
= render "projects/buttons/koding"
= render "projects/buttons/download"
......@@ -86,4 +88,4 @@
Archived project! Repository is read-only
%div{class: "project-show-#{default_project_view}"}
= render default_project_view
\ No newline at end of file
= render default_project_view
......@@ -90,6 +90,11 @@
get 'help/ui' => 'help#ui'
get 'help/*path' => 'help#show', as: :help_page
# Koding route
get 'koding' => 'koding#index'
# Global snippets
class AddKodingToApplicationSettings < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
add_column :application_settings, :koding_enabled, :boolean
add_column :application_settings, :koding_url, :string
......@@ -90,6 +90,8 @@
t.string "enabled_git_access_protocol"
t.boolean "domain_blacklist_enabled", default: false
t.text "domain_blacklist"
t.boolean "koding_enabled"
t.string "koding_url"
create_table "audit_events", force: :cascade do |t|
......@@ -15,6 +15,7 @@ See the documentation below for details on how to configure these services.
- [Gmail actions buttons]( Adds GitLab actions to messages
- [reCAPTCHA]( Configure GitLab to use Google reCAPTCHA for new users
- [Akismet]( Configure Akismet to stop spam
- [Koding]( Configure Koding to use IDE integration
GitLab Enterprise Edition contains [advanced Jenkins support][jenkins].
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment