summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml42
-rw-r--r--doc/development/img/manual_build_docs.pngbin0 -> 14869 bytes
-rw-r--r--doc/development/writing_documentation.md21
-rwxr-xr-xscripts/trigger-build-docs80
-rwxr-xr-xscripts/trigger-build-omnibus (renamed from scripts/trigger-build)0
5 files changed, 140 insertions, 3 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7b42e661dff..dadce073309 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -40,6 +40,7 @@ stages:
- test
- post-test
- pages
+ - post-cleanup
# Predefined scopes
.dedicated-runner: &dedicated-runner
@@ -153,8 +154,7 @@ stages:
- master@gitlab/gitlabhq
- master@gitlab/gitlab-ee
-# Trigger a package build on omnibus-gitlab repository
-
+# Trigger a package build in omnibus-gitlab repository
build-package:
image: ruby:2.3-alpine
before_script: []
@@ -166,11 +166,47 @@ build-package:
cache: {}
when: manual
script:
- - scripts/trigger-build
+ - scripts/trigger-build-omnibus
only:
- //@gitlab-org/gitlab-ce
- //@gitlab-org/gitlab-ee
+# Review docs base
+.review-docs: &review-docs
+ image: ruby:2.4-alpine
+ before_script: []
+ services: []
+ variables:
+ SETUP_DB: "false"
+ USE_BUNDLE_INSTALL: "false"
+ cache: {}
+ when: manual
+ only:
+ - branches
+
+# Trigger a docs build in gitlab-docs
+# Useful to preview the docs changes live
+review-docs-deploy:
+ <<: *review-docs
+ stage: build
+ environment:
+ name: review-docs/$CI_COMMIT_REF_NAME
+ on_stop: review-docs-cleanup
+ script:
+ - gem install gitlab --no-doc
+ - scripts/trigger-build-docs deploy
+
+# Cleanup remote environment of gitlab-docs
+review-docs-cleanup:
+ <<: *review-docs
+ stage: post-cleanup
+ environment:
+ name: review-docs/$CI_COMMIT_REF_NAME
+ action: stop
+ script:
+ - gem install gitlab --no-doc
+ - scripts/trigger-build-docs cleanup
+
# Retrieve knapsack and rspec_flaky reports
retrieve-tests-metadata:
<<: *tests-metadata-state
diff --git a/doc/development/img/manual_build_docs.png b/doc/development/img/manual_build_docs.png
new file mode 100644
index 00000000000..fef767c2a79
--- /dev/null
+++ b/doc/development/img/manual_build_docs.png
Binary files differ
diff --git a/doc/development/writing_documentation.md b/doc/development/writing_documentation.md
index eac9ec2a470..479258f743e 100644
--- a/doc/development/writing_documentation.md
+++ b/doc/development/writing_documentation.md
@@ -103,3 +103,24 @@ If that job fails, read the instructions in the job log for what to do next.
Contributors do not need to submit their changes to EE, GitLab Inc. employees
on the other hand need to make sure that their changes apply cleanly to both
CE and EE.
+
+## Previewing the changes live
+
+If you want to preview your changes live, you can use the manual `build-docs`
+job in your merge request.
+
+![Manual trigger a docs build](img/manual_build_docs.png)
+
+This job will:
+
+1. Create a new branch in the [gitlab-docs](https://gitlab.com/gitlab-com/gitlab-docs)
+ project named after the scheme: `<CE/EE-branch-slug>-built-from-ce-ee`
+1. Trigger a pipeline and build the docs site with your changes
+
+Look for the docs URL at the output of the `build-docs` job.
+
+>**Note:**
+Make sure that you always delete the branch of the merge request you were
+working on. If you don't, the remote docs branch won't be removed either,
+and the server where the Review Apps are hosted will eventually be out of
+disk space.
diff --git a/scripts/trigger-build-docs b/scripts/trigger-build-docs
new file mode 100755
index 00000000000..e58edf189cf
--- /dev/null
+++ b/scripts/trigger-build-docs
@@ -0,0 +1,80 @@
+#!/usr/bin/env ruby
+
+require 'gitlab'
+
+#
+# Give the remote branch a different name than the current one
+# in order to avoid conflicts
+#
+@docs_branch = "#{ENV["CI_COMMIT_REF_SLUG"]}-built-from-ce-ee"
+GITLAB_DOCS_REPO = 'gitlab-com/gitlab-docs'
+
+#
+# Configure credentials to be used with gitlab gem
+#
+Gitlab.configure do |config|
+ config.endpoint = 'https://gitlab.com/api/v4'
+ config.private_token = ENV["DOCS_API_TOKEN"] # GitLab Docs bot access token which has only Developer access to gitlab-docs
+end
+
+#
+# Dummy way to find out in which repo we are, CE or EE
+#
+def is_ee?
+ File.exists?('CHANGELOG-EE.md')
+end
+
+#
+# Create a remote branch in gitlab-docs
+#
+def create_remote_branch
+ Gitlab.create_branch(GITLAB_DOCS_REPO, @docs_branch, 'master')
+ puts "Remote branch '#{@docs_branch}' created"
+rescue Gitlab::Error::BadRequest => e
+ puts "Remote branch '#{@docs_branch}' already exists"
+end
+
+#
+# Remove a remote branch in gitlab-docs
+#
+def remove_remote_branch
+ Gitlab.delete_branch(GITLAB_DOCS_REPO, @docs_branch)
+ puts "Remote branch '#{@docs_branch}' deleted"
+end
+
+#
+# Trigger a pipeline in gitlab-docs
+#
+def trigger_pipeline
+ # Overriding vars in https://gitlab.com/gitlab-com/gitlab-docs/blob/master/.gitlab-ci.yml
+ param_name = is_ee? ? 'BRANCH_EE' : 'BRANCH_CE'
+
+ # The review app URL
+ app_url = "http://#{@docs_branch}.#{ENV["DOCS_REVIEW_APPS_DOMAIN"]}/#{is_ee? ? 'ee' : 'ce'}"
+
+ # Create the pipeline
+ puts "=> Triggering a pipeline..."
+ pipeline = Gitlab.run_trigger(GITLAB_DOCS_REPO, ENV["DOCS_TRIGGER_TOKEN"], @docs_branch, { param_name => ENV["CI_COMMIT_REF_NAME"] })
+
+ puts "=> Pipeline created:"
+ puts ""
+ puts "https://gitlab.com/gitlab-com/gitlab-docs/pipelines/#{pipeline.id}"
+ puts ""
+ puts "=> Preview your changes live at:"
+ puts ""
+ puts app_url
+ puts ""
+end
+
+#
+# When the first argument is deploy then create the branch and trigger pipeline
+# When it is 'stop', it deleted the remote branch. That way, we ensure there
+# are no stale remote branches and the Review server doesn't fill.
+#
+case ARGV[0]
+when 'deploy'
+ create_remote_branch
+ trigger_pipeline
+when 'cleanup'
+ remove_remote_branch
+end
diff --git a/scripts/trigger-build b/scripts/trigger-build-omnibus
index dcda70d7ed8..dcda70d7ed8 100755
--- a/scripts/trigger-build
+++ b/scripts/trigger-build-omnibus