diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-17 12:06:48 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-17 12:06:48 +0000 |
commit | bd860c22f6a4b9473cbddd34a53eead8235a7ea1 (patch) | |
tree | 3f955a56c2ac90497863da26902a42dba49f3466 | |
parent | e567b4c2df7dc4085d213db029eff6b6fcde0152 (diff) | |
download | gitlab-ce-bd860c22f6a4b9473cbddd34a53eead8235a7ea1.tar.gz |
Add latest changes from gitlab-org/gitlab@master
131 files changed, 2693 insertions, 2146 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f1f8ff6e862..48b840b4af2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -565,11 +565,6 @@ Style/EmptyLiteral: Style/EmptyMethod: Enabled: false -# Offense count: 40 -# Cop supports --auto-correct. -Style/Encoding: - Enabled: false - # Offense count: 203 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/16790-render-xml-artifacts.yml b/16790-render-xml-artifacts.yml new file mode 100644 index 00000000000..d9cfcc04a68 --- /dev/null +++ b/16790-render-xml-artifacts.yml @@ -0,0 +1,5 @@ +--- +title: Render xml artifact files in GitLab +merge_request: 16790 +author: +type: added diff --git a/GITLAB_PAGES_VERSION b/GITLAB_PAGES_VERSION index a8fdfda1c78..f8e233b2733 100644 --- a/GITLAB_PAGES_VERSION +++ b/GITLAB_PAGES_VERSION @@ -1 +1 @@ -1.8.1 +1.9.0 diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index 10a6d2d3f26..477ba36e9d1 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -199,12 +199,7 @@ class Projects::PipelinesController < Projects::ApplicationController end def latest_pipeline - ref = params['ref'].presence || @project.default_branch - sha = @project.commit(ref)&.sha - - @project.ci_pipelines - .newest_first(ref: ref, sha: sha) - .first + @project.latest_pipeline_for_ref(params['ref']) &.present(current_user: current_user) end diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb index 8ed6ff56e2b..2364777cdc5 100644 --- a/app/finders/issuable_finder.rb +++ b/app/finders/issuable_finder.rb @@ -46,10 +46,13 @@ class IssuableFinder # This is used in unassigning users NONE = '0' + NEGATABLE_PARAMS_HELPER_KEYS = %i[include_subgroups in].freeze + attr_accessor :current_user, :params - def self.scalar_params - @scalar_params ||= %i[ + class << self + def scalar_params + @scalar_params ||= %i[ assignee_id assignee_username author_id @@ -60,14 +63,30 @@ class IssuableFinder search in ] - end + end - def self.array_params - @array_params ||= { label_name: [], assignee_username: [] } - end + def array_params + @array_params ||= { label_name: [], assignee_username: [] } + end + + # This should not be used in controller strong params! + def negatable_scalar_params + @negatable_scalar_params ||= scalar_params + %i[project_id group_id] + end + + # This should not be used in controller strong params! + def negatable_array_params + @negatable_array_params ||= array_params.keys.append(:iids) + end - def self.valid_params - @valid_params ||= scalar_params + [array_params] + # This should not be used in controller strong params! + def negatable_params + @negatable_params ||= negatable_scalar_params + negatable_array_params + end + + def valid_params + @valid_params ||= scalar_params + [array_params] + [{ not: [] }] + end end def initialize(current_user, params = {}) @@ -79,6 +98,9 @@ class IssuableFinder items = init_collection items = filter_items(items) + # Let's see if we have to negate anything + items = by_negation(items) + # This has to be last as we use a CTE as an optimization fence # for counts by passing the force_cte param and enabling the # attempt_group_search_optimizations feature flag @@ -366,6 +388,33 @@ class IssuableFinder Array(value).last.to_sym end + # Negates all params found in `negatable_params` + # rubocop: disable CodeReuse/ActiveRecord + def by_negation(items) + not_params = params[:not].dup + # API endpoints send in `nil` values so we test if there are any non-nil + return items unless not_params.present? && not_params.values.any? + + not_params.keep_if { |_k, v| v.present? }.each do |(key, value)| + # These aren't negatable params themselves, but rather help other searches, so we skip them. + # They will be added into all the NOT searches. + next if NEGATABLE_PARAMS_HELPER_KEYS.include?(key.to_sym) + next unless self.class.negatable_params.include?(key.to_sym) + + # These are "helper" params that are required inside the NOT to get the right results. They usually come in + # at the top-level params, but if they do come in inside the `:not` params, they should take precedence. + not_helpers = params.slice(*NEGATABLE_PARAMS_HELPER_KEYS).merge(params[:not].slice(*NEGATABLE_PARAMS_HELPER_KEYS)) + not_param = { key => value }.with_indifferent_access.merge(not_helpers) + + items_to_negate = self.class.new(current_user, not_param).execute + + items = items.where.not(id: items_to_negate) + end + + items + end + # rubocop: enable CodeReuse/ActiveRecord + # rubocop: disable CodeReuse/ActiveRecord def by_scope(items) return items.none if current_user_related? && !current_user diff --git a/app/helpers/page_layout_helper.rb b/app/helpers/page_layout_helper.rb index ec1d8577f36..46e2c9ce56e 100644 --- a/app/helpers/page_layout_helper.rb +++ b/app/helpers/page_layout_helper.rb @@ -1,4 +1,3 @@ -# coding: utf-8 # frozen_string_literal: true module PageLayoutHelper diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 3fb39a19cf0..5ed95311767 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -562,7 +562,7 @@ module ProjectsHelper allowedVisibilityOptions: project_allowed_visibility_levels(project), visibilityHelpPath: help_page_path('public_access/public_access'), registryAvailable: Gitlab.config.registry.enabled, - registryHelpPath: help_page_path('user/project/container_registry'), + registryHelpPath: help_page_path('user/packages/container_registry/index'), lfsAvailable: Gitlab.config.lfs.enabled, lfsHelpPath: help_page_path('workflow/lfs/manage_large_binaries_with_git_lfs'), pagesAvailable: Gitlab.config.pages.enabled, diff --git a/app/models/ci/artifact_blob.rb b/app/models/ci/artifact_blob.rb index d87d6a5cb2f..ef00ad75683 100644 --- a/app/models/ci/artifact_blob.rb +++ b/app/models/ci/artifact_blob.rb @@ -4,7 +4,7 @@ module Ci class ArtifactBlob include BlobLike - EXTENSIONS_SERVED_BY_PAGES = %w[.html .htm .txt .json .log].freeze + EXTENSIONS_SERVED_BY_PAGES = %w[.html .htm .txt .json .xml .log].freeze attr_reader :entry diff --git a/app/models/clusters/cluster.rb b/app/models/clusters/cluster.rb index 7855fb69bd6..7a61622b139 100644 --- a/app/models/clusters/cluster.rb +++ b/app/models/clusters/cluster.rb @@ -37,13 +37,18 @@ module Clusters has_one :platform_kubernetes, class_name: 'Clusters::Platforms::Kubernetes', inverse_of: :cluster, autosave: true - has_one :application_helm, class_name: 'Clusters::Applications::Helm' - has_one :application_ingress, class_name: 'Clusters::Applications::Ingress' - has_one :application_cert_manager, class_name: 'Clusters::Applications::CertManager' - has_one :application_prometheus, class_name: 'Clusters::Applications::Prometheus' - has_one :application_runner, class_name: 'Clusters::Applications::Runner' - has_one :application_jupyter, class_name: 'Clusters::Applications::Jupyter' - has_one :application_knative, class_name: 'Clusters::Applications::Knative' + def self.has_one_cluster_application(name) # rubocop:disable Naming/PredicateName + application = APPLICATIONS[name.to_s] + has_one application.association_name, class_name: application.to_s # rubocop:disable Rails/ReflectionClassName + end + + has_one_cluster_application :helm + has_one_cluster_application :ingress + has_one_cluster_application :cert_manager + has_one_cluster_application :prometheus + has_one_cluster_application :runner + has_one_cluster_application :jupyter + has_one_cluster_application :knative has_many :kubernetes_namespaces @@ -127,15 +132,9 @@ module Clusters end def applications - [ - application_helm || build_application_helm, - application_ingress || build_application_ingress, - application_cert_manager || build_application_cert_manager, - application_prometheus || build_application_prometheus, - application_runner || build_application_runner, - application_jupyter || build_application_jupyter, - application_knative || build_application_knative - ] + APPLICATIONS.values.map do |application_class| + public_send(application_class.association_name) || public_send("build_#{application_class.association_name}") # rubocop:disable GitlabSecurity/PublicSend + end end def provider diff --git a/app/models/clusters/concerns/application_core.rb b/app/models/clusters/concerns/application_core.rb index 803a65726d3..d1b57a21a7d 100644 --- a/app/models/clusters/concerns/application_core.rb +++ b/app/models/clusters/concerns/application_core.rb @@ -32,6 +32,10 @@ module Clusters self.to_s.demodulize.underscore end + def self.association_name + :"application_#{application_name}" + end + def name self.class.application_name end diff --git a/app/models/commit.rb b/app/models/commit.rb index 1470b50f396..a442f607fbf 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -1,4 +1,3 @@ -# coding: utf-8 # frozen_string_literal: true class Commit diff --git a/app/models/project.rb b/app/models/project.rb index 59c187fac31..57f1ca98ee2 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -753,6 +753,15 @@ class Project < ApplicationRecord latest_successful_build_for_ref(job_name, ref) || raise(ActiveRecord::RecordNotFound.new("Couldn't find job #{job_name}")) end + def latest_pipeline_for_ref(ref = default_branch) + ref = ref.presence || default_branch + sha = commit(ref)&.sha + + return unless sha + + ci_pipelines.newest_first(ref: ref, sha: sha).first + end + def merge_base_commit(first_commit_id, second_commit_id) sha = repository.merge_base(first_commit_id, second_commit_id) commit_by(oid: sha) if sha diff --git a/app/services/clusters/applications/base_service.rb b/app/services/clusters/applications/base_service.rb index a9feb60be6e..67fb3ac8355 100644 --- a/app/services/clusters/applications/base_service.rb +++ b/app/services/clusters/applications/base_service.rb @@ -77,6 +77,10 @@ module Clusters params[:application] end + def application_class + Clusters::Cluster::APPLICATIONS[application_name] + end + def create_oauth_application(application, request) oauth_application_params = { name: params[:application], diff --git a/app/services/clusters/applications/create_service.rb b/app/services/clusters/applications/create_service.rb index f723c42c049..2a626a402e4 100644 --- a/app/services/clusters/applications/create_service.rb +++ b/app/services/clusters/applications/create_service.rb @@ -10,7 +10,7 @@ module Clusters end def builder - cluster.public_send(:"application_#{application_name}") || # rubocop:disable GitlabSecurity/PublicSend + cluster.public_send(application_class.association_name) || # rubocop:disable GitlabSecurity/PublicSend cluster.public_send(:"build_application_#{application_name}") # rubocop:disable GitlabSecurity/PublicSend end end diff --git a/app/services/clusters/applications/destroy_service.rb b/app/services/clusters/applications/destroy_service.rb index f3a4c4f754a..d666682487b 100644 --- a/app/services/clusters/applications/destroy_service.rb +++ b/app/services/clusters/applications/destroy_service.rb @@ -16,7 +16,7 @@ module Clusters private def builder - cluster.public_send(:"application_#{application_name}") # rubocop:disable GitlabSecurity/PublicSend + cluster.public_send(application_class.association_name) # rubocop:disable GitlabSecurity/PublicSend end end end diff --git a/app/services/clusters/applications/update_service.rb b/app/services/clusters/applications/update_service.rb index 0fa937da865..7a36401f156 100644 --- a/app/services/clusters/applications/update_service.rb +++ b/app/services/clusters/applications/update_service.rb @@ -10,7 +10,7 @@ module Clusters end def builder - cluster.public_send(:"application_#{application_name}") # rubocop:disable GitlabSecurity/PublicSend + cluster.public_send(application_class.association_name) # rubocop:disable GitlabSecurity/PublicSend end end end diff --git a/app/services/protected_branches/destroy_service.rb b/app/services/protected_branches/destroy_service.rb index 7190bc2001b..acd15b0214f 100644 --- a/app/services/protected_branches/destroy_service.rb +++ b/app/services/protected_branches/destroy_service.rb @@ -9,3 +9,5 @@ module ProtectedBranches end end end + +ProtectedBranches::DestroyService.prepend_if_ee('EE::ProtectedBranches::DestroyService') diff --git a/app/services/protected_branches/update_service.rb b/app/services/protected_branches/update_service.rb index 4d7d498b8ca..226aefb64d0 100644 --- a/app/services/protected_branches/update_service.rb +++ b/app/services/protected_branches/update_service.rb @@ -10,3 +10,5 @@ module ProtectedBranches end end end + +ProtectedBranches::UpdateService.prepend_if_ee('EE::ProtectedBranches::UpdateService') diff --git a/app/views/projects/registry/repositories/index.html.haml b/app/views/projects/registry/repositories/index.html.haml index e34973f1f43..d0d06a0df7e 100644 --- a/app/views/projects/registry/repositories/index.html.haml +++ b/app/views/projects/registry/repositories/index.html.haml @@ -2,7 +2,7 @@ .row.registry-placeholder.prepend-bottom-10 .col-12 #js-vue-registry-images{ data: { endpoint: project_container_registry_index_path(@project, format: :json), - "help_page_path" => help_page_path('user/project/container_registry'), + "help_page_path" => help_page_path('user/packages/container_registry/index'), "no_containers_image" => image_path('illustrations/docker-empty-state.svg'), "containers_error_image" => image_path('illustrations/docker-error-state.svg'), "repository_url" => escape_once(@project.container_registry_url), diff --git a/changelogs/unreleased/64213-not_filtering.yml b/changelogs/unreleased/64213-not_filtering.yml new file mode 100644 index 00000000000..3eedafa5a4c --- /dev/null +++ b/changelogs/unreleased/64213-not_filtering.yml @@ -0,0 +1,5 @@ +--- +title: Add not param to Issues API endpoint +merge_request: 16748 +author: +type: added diff --git a/changelogs/unreleased/enabling_runners_token_for_groups.yml b/changelogs/unreleased/enabling_runners_token_for_groups.yml new file mode 100644 index 00000000000..9e55aca82de --- /dev/null +++ b/changelogs/unreleased/enabling_runners_token_for_groups.yml @@ -0,0 +1,5 @@ +--- +title: Adds the runners_token of the group if the user that requests the group info is admin of it +merge_request: 16831 +author: Ignacio Lorenzo Subirá Otal nachootal@gmail.com +type: changed diff --git a/db/migrate/20190828170945_create_package_metadatum.rb b/db/migrate/20190828170945_create_package_metadatum.rb new file mode 100644 index 00000000000..3047b812e0e --- /dev/null +++ b/db/migrate/20190828170945_create_package_metadatum.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class CreatePackageMetadatum < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + create_table :packages_package_metadata do |t| + t.references :package, index: { unique: true }, null: false, foreign_key: { to_table: :packages_packages, on_delete: :cascade }, type: :integer + t.binary :metadata, null: false + end + end +end diff --git a/db/migrate/20190828172831_create_package_tag.rb b/db/migrate/20190828172831_create_package_tag.rb new file mode 100644 index 00000000000..baf0a5cf11b --- /dev/null +++ b/db/migrate/20190828172831_create_package_tag.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true . + +class CreatePackageTag < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + create_table :packages_package_tags do |t| + t.references :package, index: true, null: false, foreign_key: { to_table: :packages_packages, on_delete: :cascade }, type: :integer + t.string :name, limit: 255, null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 1460a8b11e8..8310d15fa9a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2498,6 +2498,18 @@ ActiveRecord::Schema.define(version: 2019_09_12_061145) do t.index ["package_id", "file_name"], name: "index_packages_package_files_on_package_id_and_file_name" end + create_table "packages_package_metadata", force: :cascade do |t| + t.integer "package_id", null: false + t.binary "metadata", null: false + t.index ["package_id"], name: "index_packages_package_metadata_on_package_id", unique: true + end + + create_table "packages_package_tags", force: :cascade do |t| + t.integer "package_id", null: false + t.string "name", limit: 255, null: false + t.index ["package_id"], name: "index_packages_package_tags_on_package_id" + end + create_table "packages_packages", force: :cascade do |t| t.integer "project_id", null: false t.datetime_with_timezone "created_at", null: false @@ -4023,6 +4035,8 @@ ActiveRecord::Schema.define(version: 2019_09_12_061145) do add_foreign_key "operations_feature_flags_clients", "projects", on_delete: :cascade add_foreign_key "packages_maven_metadata", "packages_packages", column: "package_id", name: "fk_be88aed360", on_delete: :cascade add_foreign_key "packages_package_files", "packages_packages", column: "package_id", name: "fk_86f0f182f8", on_delete: :cascade + add_foreign_key "packages_package_metadata", "packages_packages", column: "package_id", on_delete: :cascade + add_foreign_key "packages_package_tags", "packages_packages", column: "package_id", on_delete: :cascade add_foreign_key "packages_packages", "projects", on_delete: :cascade add_foreign_key "pages_domain_acme_orders", "pages_domains", on_delete: :cascade add_foreign_key "pages_domains", "projects", name: "fk_ea2f6dfc6f", on_delete: :cascade diff --git a/doc/README.md b/doc/README.md index c704bedc7d6..6e0f037bea4 100644 --- a/doc/README.md +++ b/doc/README.md @@ -36,7 +36,7 @@ Have a look at some of our most popular documentation resources: |:----------------------------------------------------------------|:-----------------------------------------------------------------| | [Configuring `.gitlab-ci.yml`](ci/yaml/README.md) | Complete syntax documentation for configuring your CI pipelines. | | [GitLab CI/CD examples](ci/examples/README.md) | Get up to speed quickly with common CI/CD scenarios. | -| [GitLab Container Registry](user/project/container_registry.md) | Host containers within GitLab. | +| [GitLab Container Registry](user/packages/container_registry/index.md) | Host Docker images within GitLab. | | [GitLab Pages](user/project/pages/index.md) | Host static websites for your projects with GitLab. | | [GitLab.com settings](user/gitlab_com/index.md) | Settings for GitLab.com. | | [Kubernetes integration](user/project/clusters/index.md) | Use GitLab with Kubernetes. | @@ -248,16 +248,18 @@ The following documentation relates to the DevOps **Verify** stage: ### Package -GitLab Container Registry gives you the enhanced security and access controls of -custom Docker images without 3rd party add-ons. Easily upload and download images -from GitLab CI/CD with full Git repository management integration. +GitLab Packages allows organizations to utilize GitLab as a private repository +for a variety of common package managers. Users are able to build and publish +packages, which can be easily consumed as a dependency in downstream projects. The following documentation relates to the DevOps **Package** stage: | Package Topics | Description | |:----------------------------------------------------------------|:-------------------------------------------------------| -| [GitLab Container Registry](user/project/container_registry.md) | Learn how to use GitLab's built-in Container Registry. | -| [GitLab Packages](administration/packages.md) **(PREMIUM)** | Use GitLab as an NPM registry or Maven repository. | +| [Container Registry](user/packages/container_registry/index.md) | The GitLab Container Registry enables every project in GitLab to have its own space to store [Docker](https://www.docker.com/) images. | +| [Dependency Proxy](user/packages/dependency_proxy/index.md) **(PREMIUM)** | The GitLab Dependency Proxy sets up a local proxy for frequently used upstream images/packages. | +| [Maven Repository](user/packages/maven_repository/index.md) **(PREMIUM)** | The GitLab Maven Repository enables every project in GitLab to have its own space to store [Maven](https://maven.apache.org/) packages. | +| [NPM Registry](user/packages/npm_registry/index.md) **(PREMIUM)** | The GitLab NPM Registry enables every project in GitLab to have its own space to store [NPM](https://www.npmjs.com/) packages. | <div align="right"> <a type="button" class="btn btn-default" href="#overview"> diff --git a/doc/administration/audit_events.md b/doc/administration/audit_events.md index 8075a40cae7..e961c677ca7 100644 --- a/doc/administration/audit_events.md +++ b/doc/administration/audit_events.md @@ -1,5 +1,5 @@ --- -last_updated: 2019-02-04 +last_updated: 2019-09-16 --- # Audit Events **(STARTER)** @@ -77,6 +77,7 @@ From there, you can see the following actions: - Project repository was downloaded - Project was archived - Project was unarchived +- Added/removed/updated protected branches ### Instance events **(PREMIUM ONLY)** diff --git a/doc/administration/auth/ldap-ee.md b/doc/administration/auth/ldap-ee.md index 34f3cfa353f..d9b7d8b4382 100644 --- a/doc/administration/auth/ldap-ee.md +++ b/doc/administration/auth/ldap-ee.md @@ -345,7 +345,7 @@ GitLab supports LDAP groups that use member attributes: - `memberuid`. This means group sync supports, at least, LDAP groups with object class: -`groupOfNames`, `posixGroup`, and `groupOfUniqueName`. +`groupOfNames`, `posixGroup`, and `groupOfUniqueNames`. Other object classes should work fine as long as members are defined as one of the mentioned attributes. This also means GitLab supports diff --git a/doc/administration/container_registry.md b/doc/administration/container_registry.md index f5d58db0133..7a533aa9043 100644 --- a/doc/administration/container_registry.md +++ b/doc/administration/container_registry.md @@ -1,736 +1,5 @@ -# GitLab Container Registry administration +--- +redirect_to: 'packages/container_registry.md' +--- -> - [Introduced][ce-4040] in GitLab 8.8. -> - Container Registry manifest `v1` support was added in GitLab 8.9 to support -> Docker versions earlier than 1.10. -> - This document is about the admin guide. To learn how to use GitLab Container -> Registry [user documentation](../user/project/container_registry.md). - -With the Container Registry integrated into GitLab, every project can have its -own space to store its Docker images. - -You can read more about the Container Registry at -<https://docs.docker.com/registry/introduction/>. - -## Enable the Container Registry - -**Omnibus GitLab installations** - -All you have to do is configure the domain name under which the Container -Registry will listen to. Read -[#container-registry-domain-configuration](#container-registry-domain-configuration) -and pick one of the two options that fits your case. - ->**Note:** -The container registry works under HTTPS by default. Using HTTP is possible -but not recommended and out of the scope of this document. -Read the [insecure Registry documentation][docker-insecure] if you want to -implement this. - -**Installations from source** - -If you have installed GitLab from source: - -1. You will have to [install Registry][registry-deploy] by yourself. -1. After the installation is complete, you will have to configure the Registry's - settings in `gitlab.yml` in order to enable it. -1. Use the sample NGINX configuration file that is found under - [`lib/support/nginx/registry-ssl`][registry-ssl] and edit it to match the - `host`, `port` and TLS certs paths. - -The contents of `gitlab.yml` are: - -``` -registry: - enabled: true - host: registry.gitlab.example.com - port: 5005 - api_url: http://localhost:5000/ - key: config/registry.key - path: shared/registry - issuer: gitlab-issuer -``` - -where: - -| Parameter | Description | -| --------- | ----------- | -| `enabled` | `true` or `false`. Enables the Registry in GitLab. By default this is `false`. | -| `host` | The host URL under which the Registry will run and the users will be able to use. | -| `port` | The port under which the external Registry domain will listen on. | -| `api_url` | The internal API URL under which the Registry is exposed to. It defaults to `http://localhost:5000`. | -| `key` | The private key location that is a pair of Registry's `rootcertbundle`. Read the [token auth configuration documentation][token-config]. | -| `path` | This should be the same directory like specified in Registry's `rootdirectory`. Read the [storage configuration documentation][storage-config]. This path needs to be readable by the GitLab user, the web-server user and the Registry user. Read more in [#container-registry-storage-path](#container-registry-storage-path). | -| `issuer` | This should be the same value as configured in Registry's `issuer`. Read the [token auth configuration documentation][token-config]. | - ->**Note:** -A Registry init file is not shipped with GitLab if you install it from source. -Hence, [restarting GitLab][restart gitlab] will not restart the Registry should -you modify its settings. Read the upstream documentation on how to achieve that. - -At the **absolute** minimum, make sure your [Registry configuration][registry-auth] -has `container_registry` as the service and `https://gitlab.example.com/jwt/auth` -as the realm: - -``` -auth: - token: - realm: https://gitlab.example.com/jwt/auth - service: container_registry - issuer: gitlab-issuer - rootcertbundle: /root/certs/certbundle -``` - -CAUTION: **Caution:** -If `auth` is not set up, users will be able to pull docker images without authentication. - -## Container Registry domain configuration - -There are two ways you can configure the Registry's external domain. - -- Either [use the existing GitLab domain][existing-domain] where in that case - the Registry will have to listen on a port and reuse GitLab's TLS certificate, -- or [use a completely separate domain][new-domain] with a new TLS certificate - for that domain. - -Since the container Registry requires a TLS certificate, in the end it all boils -down to how easy or pricey is to get a new one. - -Please take this into consideration before configuring the Container Registry -for the first time. - -### Configure Container Registry under an existing GitLab domain - -If the Registry is configured to use the existing GitLab domain, you can -expose the Registry on a port so that you can reuse the existing GitLab TLS -certificate. - -Assuming that the GitLab domain is `https://gitlab.example.com` and the port the -Registry is exposed to the outside world is `4567`, here is what you need to set -in `gitlab.rb` or `gitlab.yml` if you are using Omnibus GitLab or installed -GitLab from source respectively. - ->**Note:** -Be careful to choose a port different than the one that Registry listens to (`5000` by default), -otherwise you will run into conflicts. - -**Omnibus GitLab installations** - -1. Your `/etc/gitlab/gitlab.rb` should contain the Registry URL as well as the - path to the existing TLS certificate and key used by GitLab: - - ```ruby - registry_external_url 'https://gitlab.example.com:4567' - ``` - - Note how the `registry_external_url` is listening on HTTPS under the - existing GitLab URL, but on a different port. - - If your TLS certificate is not in `/etc/gitlab/ssl/gitlab.example.com.crt` - and key not in `/etc/gitlab/ssl/gitlab.example.com.key` uncomment the lines - below: - - ```ruby - registry_nginx['ssl_certificate'] = "/path/to/certificate.pem" - registry_nginx['ssl_certificate_key'] = "/path/to/certificate.key" - ``` - -1. Save the file and [reconfigure GitLab][] for the changes to take effect. - -1. Validate using: - - ```sh - openssl s_client -showcerts -servername gitlab.example.com -connect gitlab.example.com:443 > cacert.pem - ``` - -NOTE: **Note:** -If your certificate provider provides the CA Bundle certificates, append them to the TLS certificate file. - -**Installations from source** - -1. Open `/home/git/gitlab/config/gitlab.yml`, find the `registry` entry and - configure it with the following settings: - - ``` - registry: - enabled: true - host: gitlab.example.com - port: 4567 - ``` - -1. Save the file and [restart GitLab][] for the changes to take effect. -1. Make the relevant changes in NGINX as well (domain, port, TLS certificates path). - -Users should now be able to login to the Container Registry with their GitLab -credentials using: - -```bash -docker login gitlab.example.com:4567 -``` - -### Configure Container Registry under its own domain - -If the Registry is configured to use its own domain, you will need a TLS -certificate for that specific domain (e.g., `registry.example.com`) or maybe -a wildcard certificate if hosted under a subdomain of your existing GitLab -domain (e.g., `registry.gitlab.example.com`). - -NOTE: **Note:** -As well as manually generated SSL certificates (explained here), certificates automatically -generated by Let's Encrypt are also [supported in Omnibus installs](https://docs.gitlab.com/omnibus/settings/ssl.html#host-services). - -Let's assume that you want the container Registry to be accessible at -`https://registry.gitlab.example.com`. - -**Omnibus GitLab installations** - -1. Place your TLS certificate and key in - `/etc/gitlab/ssl/registry.gitlab.example.com.crt` and - `/etc/gitlab/ssl/registry.gitlab.example.com.key` and make sure they have - correct permissions: - - ```bash - chmod 600 /etc/gitlab/ssl/registry.gitlab.example.com.* - ``` - -1. Once the TLS certificate is in place, edit `/etc/gitlab/gitlab.rb` with: - - ```ruby - registry_external_url 'https://registry.gitlab.example.com' - ``` - - Note how the `registry_external_url` is listening on HTTPS. - -1. Save the file and [reconfigure GitLab][] for the changes to take effect. - -> **Note:** -If you have a [wildcard certificate][], you need to specify the path to the -certificate in addition to the URL, in this case `/etc/gitlab/gitlab.rb` will -look like: -> -> ```ruby -> registry_nginx['ssl_certificate'] = "/etc/gitlab/ssl/certificate.pem" -> registry_nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/certificate.key" -> ``` - -**Installations from source** - -1. Open `/home/git/gitlab/config/gitlab.yml`, find the `registry` entry and - configure it with the following settings: - - ```yaml - registry: - enabled: true - host: registry.gitlab.example.com - ``` - -1. Save the file and [restart GitLab][] for the changes to take effect. -1. Make the relevant changes in NGINX as well (domain, port, TLS certificates path). - -Users should now be able to login to the Container Registry using their GitLab -credentials: - -```bash -docker login registry.gitlab.example.com -``` - -## Disable Container Registry site-wide - ->**Note:** -Disabling the Registry in the Rails GitLab application as set by the following -steps, will not remove any existing Docker images. This is handled by the -Registry application itself. - -**Omnibus GitLab** - -1. Open `/etc/gitlab/gitlab.rb` and set `registry['enable']` to `false`: - - ```ruby - registry['enable'] = false - ``` - -1. Save the file and [reconfigure GitLab][] for the changes to take effect. - -**Installations from source** - -1. Open `/home/git/gitlab/config/gitlab.yml`, find the `registry` entry and - set `enabled` to `false`: - - ```yaml - registry: - enabled: false - ``` - -1. Save the file and [restart GitLab][] for the changes to take effect. - -## Disable Container Registry for new projects site-wide - -If the Container Registry is enabled, then it will be available on all new -projects. To disable this function and let the owners of a project to enable -the Container Registry by themselves, follow the steps below. - -**Omnibus GitLab installations** - -1. Edit `/etc/gitlab/gitlab.rb` and add the following line: - - ```ruby - gitlab_rails['gitlab_default_projects_features_container_registry'] = false - ``` - -1. Save the file and [reconfigure GitLab][] for the changes to take effect. - -**Installations from source** - -1. Open `/home/git/gitlab/config/gitlab.yml`, find the `default_projects_features` - entry and configure it so that `container_registry` is set to `false`: - - ```yaml - ## Default project features settings - default_projects_features: - issues: true - merge_requests: true - wiki: true - snippets: false - builds: true - container_registry: false - ``` - -1. Save the file and [restart GitLab][] for the changes to take effect. - -## Container Registry storage path - ->**Note:** -For configuring storage in the cloud instead of the filesystem, see the -[storage driver configuration](#container-registry-storage-driver). - -If you want to store your images on the filesystem, you can change the storage -path for the Container Registry, follow the steps below. - -This path is accessible to: - -- the user running the Container Registry daemon, -- the user running GitLab - -> **Warning** You should confirm that all GitLab, Registry and web server users -have access to this directory. - -**Omnibus GitLab installations** - -The default location where images are stored in Omnibus, is -`/var/opt/gitlab/gitlab-rails/shared/registry`. To change it: - -1. Edit `/etc/gitlab/gitlab.rb`: - - ```ruby - gitlab_rails['registry_path'] = "/path/to/registry/storage" - ``` - -1. Save the file and [reconfigure GitLab][] for the changes to take effect. - -**Installations from source** - -The default location where images are stored in source installations, is -`/home/git/gitlab/shared/registry`. To change it: - -1. Open `/home/git/gitlab/config/gitlab.yml`, find the `registry` entry and - change the `path` setting: - - ```yaml - registry: - path: shared/registry - ``` - -1. Save the file and [restart GitLab][] for the changes to take effect. - -## Container Registry storage driver - -You can configure the Container Registry to use a different storage backend by -configuring a different storage driver. By default the GitLab Container Registry -is configured to use the filesystem driver, which makes use of [storage path](#container-registry-storage-path) -configuration. - -NOTE: **Note:** Enabling a storage driver other than `filesystem` would mean -that your Docker client needs to be able to access the storage backend directly. -In that case, you must use an address that resolves and is accessible outside GitLab server. - -The different supported drivers are: - -| Driver | Description | -|------------|-------------------------------------| -| filesystem | Uses a path on the local filesystem | -| azure | Microsoft Azure Blob Storage | -| gcs | Google Cloud Storage | -| s3 | Amazon Simple Storage Service. Be sure to configure your storage bucket with the correct [S3 Permission Scopes](https://docs.docker.com/registry/storage-drivers/s3/#s3-permission-scopes). | -| swift | OpenStack Swift Object Storage | -| oss | Aliyun OSS | - -Read more about the individual driver's config options in the -[Docker Registry docs][storage-config]. - -CAUTION: **Warning:** GitLab will not backup Docker images that are not stored on the -filesystem. Remember to enable backups with your object storage provider if -desired. - -NOTE: **Note:** -`regionendpoint` is only required when configuring an S3 compatible service such as Minio. It takes a URL such as `http://127.0.0.1:9000`. - -**Omnibus GitLab installations** - -To configure the `s3` storage driver in Omnibus: - -1. Edit `/etc/gitlab/gitlab.rb`: - - ```ruby - registry['storage'] = { - 's3' => { - 'accesskey' => 's3-access-key', - 'secretkey' => 's3-secret-key-for-access-key', - 'bucket' => 'your-s3-bucket', - 'region' => 'your-s3-region', - 'regionendpoint' => 'your-s3-regionendpoint' - } - } - ``` - -1. Save the file and [reconfigure GitLab][] for the changes to take effect. - -**Installations from source** - -Configuring the storage driver is done in your registry config YML file created -when you [deployed your docker registry][registry-deploy]. - -`s3` storage driver example: - -```yml -storage: - s3: - accesskey: 'AKIAKIAKI' - secretkey: 'secret123' - bucket: 'gitlab-registry-bucket-AKIAKIAKI' - region: 'your-s3-region' - regionendpoint: 'your-s3-regionendpoint' - cache: - blobdescriptor: inmemory - delete: - enabled: true -``` - -## Change the registry's internal port - -> **Note:** -This is not to be confused with the port that GitLab itself uses to expose -the Registry to the world. - -The Registry server listens on localhost at port `5000` by default, -which is the address for which the Registry server should accept connections. -In the examples below we set the Registry's port to `5001`. - -**Omnibus GitLab** - -1. Open `/etc/gitlab/gitlab.rb` and set `registry['registry_http_addr']`: - - ```ruby - registry['registry_http_addr'] = "localhost:5001" - ``` - -1. Save the file and [reconfigure GitLab][] for the changes to take effect. - -**Installations from source** - -1. Open the configuration file of your Registry server and edit the - [`http:addr`][registry-http-config] value: - - ```yaml - http - addr: localhost:5001 - ``` - -1. Save the file and restart the Registry server. - -## Disable Container Registry per project - -If Registry is enabled in your GitLab instance, but you don't need it for your -project, you can disable it from your project's settings. Read the user guide -on how to achieve that. - -## Disable Container Registry but use GitLab as an auth endpoint - -**Omnibus GitLab** - -You can use GitLab as an auth endpoint and use a non-bundled Container Registry. - -1. Open `/etc/gitlab/gitlab.rb` and set necessary configurations: - - ```ruby - gitlab_rails['registry_enabled'] = true - gitlab_rails['registry_host'] = "registry.gitlab.example.com" - gitlab_rails['registry_port'] = "5005" - gitlab_rails['registry_api_url'] = "http://localhost:5000" - gitlab_rails['registry_path'] = "/var/opt/gitlab/gitlab-rails/shared/registry" - gitlab_rails['registry_issuer'] = "omnibus-gitlab-issuer" - ``` - -1. A certificate keypair is required for GitLab and the Container Registry to - communicate securely. By default Omnibus GitLab will generate one keypair, - which is saved to `/var/opt/gitlab/gitlab-rails/etc/gitlab-registry.key`. - When using a non-bundled Container Registry, you will need to supply a - custom certificate key. To do that, add the following to - `/etc/gitlab/gitlab.rb` - - ```ruby - gitlab_rails['registry_key_path'] = "/custom/path/to/registry-key.key" - # registry['internal_key'] should contain the contents of the custom key - # file. Line breaks in the key file should be marked using `\n` character - # Example: - registry['internal_key'] = "---BEGIN RSA PRIVATE KEY---\nMIIEpQIBAA\n" - ``` - - **Note:** The file specified at `registry_key_path` gets populated with the - content specified by `internal_key`, each time reconfigure is executed. If - no file is specified, Omnibus GitLab will default it to - `/var/opt/gitlab/gitlab-rails/etc/gitlab-registry.key` and will populate - it. - -1. Save the file and [reconfigure GitLab][] for the changes to take effect. - -**Installations from source** - -1. Open `/home/git/gitlab/config/gitlab.yml`, and edit the configuration settings under `registry`: - - ```yaml - ## Container Registry - - registry: - enabled: true - host: "registry.gitlab.example.com" - port: "5005" - api_url: "http://localhost:5000" - path: /var/opt/gitlab/gitlab-rails/shared/registry - key: /var/opt/gitlab/gitlab-rails/certificate.key - issuer: omnibus-gitlab-issuer - ``` - -1. Save the file and [restart GitLab][] for the changes to take effect. - -## Storage limitations - -Currently, there is no storage limitation, which means a user can upload an -infinite amount of Docker images with arbitrary sizes. This setting will be -configurable in future releases. - -## Configure Container Registry notifications - -You can configure the Container Registry to send webhook notifications in -response to events happening within the registry. - -Read more about the Container Registry notifications config options in the -[Docker Registry notifications documentation][notifications-config]. - ->**Note:** -Multiple endpoints can be configured for the Container Registry. - -**Omnibus GitLab installations** - -To configure a notification endpoint in Omnibus: - -1. Edit `/etc/gitlab/gitlab.rb`: - - ```ruby - registry['notifications'] = [ - { - 'name' => 'test_endpoint', - 'url' => 'https://gitlab.example.com/notify', - 'timeout' => '500ms', - 'threshold' => 5, - 'backoff' => '1s', - 'headers' => { - "Authorization" => ["AUTHORIZATION_EXAMPLE_TOKEN"] - } - } - ] - ``` - -1. Save the file and [reconfigure GitLab][] for the changes to take effect. - -**Installations from source** - -Configuring the notification endpoint is done in your registry config YML file created -when you [deployed your docker registry][registry-deploy]. - -Example: - -``` -notifications: - endpoints: - - name: alistener - disabled: false - url: https://my.listener.com/event - headers: <http.Header> - timeout: 500 - threshold: 5 - backoff: 1000 -``` - -## Troubleshooting - -### Using self-signed certificates with Container Registry - -If you're using a self-signed certificate with your Container Registry, you -might encounter issues during the CI jobs like the following: - -``` -Error response from daemon: Get registry.example.com/v1/users/: x509: certificate signed by unknown authority -``` - -The Docker daemon running the command expects a cert signed by a recognized CA, -thus the error above. - -While GitLab doesn't support using self-signed certificates with Container Registry out of the box, it is possible to make it work by [instructing the docker-daemon to trust the self-signed certificates][docker-insecure-self-signed], mounting the docker-daemon and setting `privileged = false` in the runner's `config.toml`. Setting `privileged = true` takes precedence over the docker-daemon. - -``` - [runners.docker] - image = "ruby:2.1" - privileged = false - volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"] -``` - -Additional information about this: [issue 18239][ce-18239]. - -### AWS S3 with the GitLab registry error when pushing large images - -When using AWS S3 with the GitLab registry, an error may occur when pushing -large images. Look in the Registry log for the following error: - -``` -level=error msg="response completed with error" err.code=unknown err.detail="unexpected EOF" err.message="unknown error" -``` - -To resolve the error specify a `chunksize` value in the Registry configuration. -Start with a value between `25000000` (25MB) and `50000000` (50MB). - -**For Omnibus installations** - -1. Edit `/etc/gitlab/gitlab.rb`: - - ```ruby - registry['storage'] = { - 's3' => { - 'accesskey' => 'AKIAKIAKI', - 'secretkey' => 'secret123', - 'bucket' => 'gitlab-registry-bucket-AKIAKIAKI', - 'chunksize' => 25000000 - } - } - ``` - -1. Save the file and [reconfigure GitLab][] for the changes to take effect. - -**For installations from source** - -1. Edit `config/gitlab.yml`: - - ```yaml - storage: - s3: - accesskey: 'AKIAKIAKI' - secretkey: 'secret123' - bucket: 'gitlab-registry-bucket-AKIAKIAKI' - chunksize: 25000000 - ``` - -1. Save the file and [restart GitLab][] for the changes to take effect. - -### Supporting older Docker clients - -As of GitLab 11.9, we began shipping version 2.7.1 of the Docker container registry, which disables the schema1 manifest by default. If you are still using older Docker clients (1.9 or older), you may experience an error pushing images. See [omnibus-4145](https://gitlab.com/gitlab-org/omnibus-gitlab/issues/4145) for more details. - -You can add a configuration option for backwards compatibility. - -**For Omnibus installations** - -1. Edit `/etc/gitlab/gitlab.rb`: - - ```ruby - registry['compatibility_schema1_enabled'] = true - ``` - -1. Save the file and [reconfigure GitLab][] for the changes to take effect. - -**For installations from source** - -1. Edit the YML configuration file you created when you [deployed the registry][registry-deploy]. Add the following snippet: - - ```yaml - compatibility: - schema1: - enabled: true - ``` - -1. Restart the registry for the changes to take affect. - -### Docker connection error - -A Docker connection error can occur when there are special characters in either the group, -project or branch name. Special characters can include: - -- Leading underscore -- Trailing hyphen/dash -- Double hyphen/dash - -To get around this, you can [change the group path](../user/group/index.md#changing-a-groups-path), -[change the project path](../user/project/settings/index.md#renaming-a-repository) or change the -branch name. Another option is to create a [push rule](../push_rules/push_rules.html) to prevent -this at the instance level. - -### Image push errors - -When getting errors or "retrying" loops in an attempt to push an image but `docker login` works fine, -there is likely an issue with the headers forwarded to the registry by NGINX. The default recommended -NGINX configurations should handle this, but it might occur in custom setups where the SSL is -offloaded to a third party reverse proxy. - -This problem was discussed in a [docker project issue][docker-image-push-issue] and a simple solution -would be to enable relative urls in the registry. - -**For Omnibus installations** - -1. Edit `/etc/gitlab/gitlab.rb`: - - ```ruby - registry['env'] = { - "REGISTRY_HTTP_RELATIVEURLS" => true - } - ``` - -1. Save the file and [reconfigure GitLab][] for the changes to take effect. - -**For installations from source** - -1. Edit the YML configuration file you created when you [deployed the registry][registry-deploy]. Add the following snippet: - - ```yaml - http: - relativeurls: true - ``` - -1. Restart the registry for the changes to take affect. - -[ce-18239]: https://gitlab.com/gitlab-org/gitlab-ce/issues/18239 -[docker-insecure-self-signed]: https://docs.docker.com/registry/insecure/#use-self-signed-certificates -[reconfigure gitlab]: restart_gitlab.md#omnibus-gitlab-reconfigure -[restart gitlab]: restart_gitlab.md#installations-from-source -[wildcard certificate]: https://en.wikipedia.org/wiki/Wildcard_certificate -[ce-4040]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4040 -[docker-insecure]: https://docs.docker.com/registry/insecure/ -[registry-deploy]: https://docs.docker.com/registry/deploying/ -[storage-config]: https://docs.docker.com/registry/configuration/#storage -[registry-http-config]: https://docs.docker.com/registry/configuration/#http -[registry-auth]: https://docs.docker.com/registry/configuration/#auth -[token-config]: https://docs.docker.com/registry/configuration/#token -[8-8-docs]: https://gitlab.com/gitlab-org/gitlab-ce/blob/8-8-stable/doc/administration/container_registry.md -[registry-ssl]: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/support/nginx/registry-ssl -[existing-domain]: #configure-container-registry-under-an-existing-gitlab-domain -[new-domain]: #configure-container-registry-under-its-own-domain -[notifications-config]: https://docs.docker.com/registry/notifications/ -[registry-notifications-config]: https://docs.docker.com/registry/configuration/#notifications -[docker-image-push-issue]: https://github.com/docker/distribution/issues/970 +This document was moved to [another location](packages/container_registry.md). diff --git a/doc/administration/dependency_proxy.md b/doc/administration/dependency_proxy.md index 5153666705f..4683565998a 100644 --- a/doc/administration/dependency_proxy.md +++ b/doc/administration/dependency_proxy.md @@ -1,151 +1,5 @@ -# GitLab Dependency Proxy administration **(PREMIUM ONLY)** +--- +redirect_to: 'packages/dependency_proxy.md' +--- -> [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/issues/7934) in [GitLab Premium](https://about.gitlab.com/pricing/) 11.11. - -GitLab can be utilized as a dependency proxy for a variety of common package managers. - -This is the administration documentation. If you want to learn how to use the -dependency proxies, see the [user guide](../user/group/dependency_proxy/index.md). - -## Enabling the Dependency Proxy feature - -NOTE: **Note:** -Dependency proxy requires the Puma web server to be enabled. -Puma support is EXPERIMENTAL at this time. - -To enable the Dependency proxy feature: - -**Omnibus GitLab installations** - -1. Edit `/etc/gitlab/gitlab.rb` and add the following line: - - ```ruby - gitlab_rails['dependency_proxy_enabled'] = true - ``` - -1. Save the file and [reconfigure GitLab][] for the changes to take effect. -1. Enable the [Puma web server](https://docs.gitlab.com/omnibus/settings/puma.html). - -**Installations from source** - -1. After the installation is complete, you will have to configure the `dependency_proxy` - section in `config/gitlab.yml`. Set to `true` to enable it: - - ```yaml - dependency_proxy: - enabled: true - ``` - -1. [Restart GitLab] for the changes to take effect. -1. Enable the [Puma web server](../install/installation.md#using-puma). - -## Changing the storage path - -By default, the dependency proxy files are stored locally, but you can change the default -local location or even use object storage. - -### Changing the local storage path - -The dependency proxy files for Omnibus GitLab installations are stored under -`/var/opt/gitlab/gitlab-rails/shared/dependency_proxy/` and for source -installations under `shared/dependency_proxy/` (relative to the Git home directory). -To change the local storage path: - -**Omnibus GitLab installations** - -1. Edit `/etc/gitlab/gitlab.rb` and add the following line: - - ```ruby - gitlab_rails['dependency_proxy_storage_path'] = "/mnt/dependency_proxy" - ``` - -1. Save the file and [reconfigure GitLab][] for the changes to take effect. - -**Installations from source** - -1. Edit the `dependency_proxy` section in `config/gitlab.yml`: - - ```yaml - dependency_proxy: - enabled: true - storage_path: shared/dependency_proxy - ``` - -1. [Restart GitLab] for the changes to take effect. - -### Using object storage - -Instead of relying on the local storage, you can use an object storage to -upload the blobs of the dependency proxy: - -**Omnibus GitLab installations** - -1. Edit `/etc/gitlab/gitlab.rb` and add the following lines (uncomment where - necessary): - - ```ruby - gitlab_rails['dependency_proxy_enabled'] = true - gitlab_rails['dependency_proxy_storage_path'] = "/var/opt/gitlab/gitlab-rails/shared/dependency_proxy" - gitlab_rails['dependency_proxy_object_store_enabled'] = true - gitlab_rails['dependency_proxy_object_store_remote_directory'] = "dependency_proxy" # The bucket name. - gitlab_rails['dependency_proxy_object_store_direct_upload'] = false # Use Object Storage directly for uploads instead of background uploads if enabled (Default: false). - gitlab_rails['dependency_proxy_object_store_background_upload'] = true # Temporary option to limit automatic upload (Default: true). - gitlab_rails['dependency_proxy_object_store_proxy_download'] = false # Passthrough all downloads via GitLab instead of using Redirects to Object Storage. - gitlab_rails['dependency_proxy_object_store_connection'] = { - ## - ## If the provider is AWS S3, uncomment the following - ## - #'provider' => 'AWS', - #'region' => 'eu-west-1', - #'aws_access_key_id' => 'AWS_ACCESS_KEY_ID', - #'aws_secret_access_key' => 'AWS_SECRET_ACCESS_KEY', - ## - ## If the provider is other than AWS (an S3-compatible one), uncomment the following - ## - #'host' => 's3.amazonaws.com', - #'aws_signature_version' => 4 # For creation of signed URLs. Set to 2 if provider does not support v4. - #'endpoint' => 'https://s3.amazonaws.com' # Useful for S3-compliant services such as DigitalOcean Spaces. - #'path_style' => false # If true, use 'host/bucket_name/object' instead of 'bucket_name.host/object'. - } - ``` - -1. Save the file and [reconfigure GitLab][] for the changes to take effect. - -**Installations from source** - -1. Edit the `dependency_proxy` section in `config/gitlab.yml` (uncomment where necessary): - - ```yaml - dependency_proxy: - enabled: true - ## - ## The location where build dependency_proxy are stored (default: shared/dependency_proxy). - ## - #storage_path: shared/dependency_proxy - object_store: - enabled: false - remote_directory: dependency_proxy # The bucket name. - #direct_upload: false # Use Object Storage directly for uploads instead of background uploads if enabled (Default: false). - #background_upload: true # Temporary option to limit automatic upload (Default: true). - #proxy_download: false # Passthrough all downloads via GitLab instead of using Redirects to Object Storage. - connection: - ## - ## If the provider is AWS S3, uncomment the following - ## - #provider: AWS - #region: us-east-1 - #aws_access_key_id: AWS_ACCESS_KEY_ID - #aws_secret_access_key: AWS_SECRET_ACCESS_KEY - ## - ## If the provider is other than AWS (an S3-compatible one), uncomment the following - ## - #host: 's3.amazonaws.com' # default: s3.amazonaws.com. - #aws_signature_version: 4 # For creation of signed URLs. Set to 2 if provider does not support v4. - #endpoint: 'https://s3.amazonaws.com' # Useful for S3-compliant services such as DigitalOcean Spaces. - #path_style: false # If true, use 'host/bucket_name/object' instead of 'bucket_name.host/object'. - ``` - -1. [Restart GitLab] for the changes to take effect. - -[reconfigure gitlab]: restart_gitlab.md#omnibus-gitlab-reconfigure "How to reconfigure Omnibus GitLab" -[restart gitlab]: restart_gitlab.md#omnibus-gitlab-reconfigure "How to reconfigure Omnibus GitLab" +This document was moved to [another location](packages/dependency_proxy.md). diff --git a/doc/administration/geo/replication/docker_registry.md b/doc/administration/geo/replication/docker_registry.md index b326717205e..537f8f57420 100644 --- a/doc/administration/geo/replication/docker_registry.md +++ b/doc/administration/geo/replication/docker_registry.md @@ -11,7 +11,7 @@ Registry on the **primary** node, you can use the same storage for a **secondary Docker Registry as well. For more information, read the [Load balancing considerations](https://docs.docker.com/registry/deploying/#load-balancing-considerations) when deploying the Registry, and how to set up the storage driver for GitLab's -integrated [Container Registry](../../container_registry.md#container-registry-storage-driver). +integrated [Container Registry](../../packages/container_registry.md#container-registry-storage-driver). ## Replicating Docker Registry diff --git a/doc/administration/geo/replication/index.md b/doc/administration/geo/replication/index.md index 1d50c924f6e..bbad9f455fe 100644 --- a/doc/administration/geo/replication/index.md +++ b/doc/administration/geo/replication/index.md @@ -274,9 +274,9 @@ You can keep track of the progress to include the missing items in: | [Server-side Git Hooks](../../custom_hooks.md) | No | No | | [Elasticsearch integration](../../../integration/elasticsearch.md) | No | No | | [GitLab Pages](../../pages/index.md) | No | No | -| [Container Registry](../../container_registry.md) | Yes | No | -| [NPM Registry](../../npm_registry.md) | No | No | -| [Maven Packages](../../maven_packages.md) | No | No | +| [Container Registry](../../packages/container_registry.md) | Yes | No | +| [NPM Registry](../../../user/packages/npm_registry/index.md) | No | No | +| [Maven Packages](../../../user/packages/maven_repository/index.md) | No | No | | [External merge request diffs](../../merge_request_diffs.md) | No, if they are on-disk | No | | Content in object storage ([track progress](https://gitlab.com/groups/gitlab-org/-/epics/1526)) | No | No | diff --git a/doc/administration/index.md b/doc/administration/index.md index df3501ae950..731c25cd3d8 100644 --- a/doc/administration/index.md +++ b/doc/administration/index.md @@ -128,13 +128,17 @@ Learn how to install, configure, update, and maintain your GitLab instance. ## Project settings -- [Container Registry](container_registry.md): Configure Container Registry with GitLab. - [Issue closing pattern](issue_closing_pattern.md): Customize how to close an issue from commit messages. - [Gitaly](gitaly/index.md): Configuring Gitaly, GitLab's Git repository storage service. - [Default labels](../user/admin_area/labels.md): Create labels that will be automatically added to every new project. - [Restrict the use of public or internal projects](../public_access/public_access.md#restricting-the-use-of-public-or-internal-projects): Restrict the use of visibility levels for users when they create a project or a snippet. - [Custom project templates](../user/admin_area/custom_project_templates.md): Configure a set of projects to be used as custom templates when creating a new project. **(PREMIUM ONLY)** -- [Packages](packages.md): Enable GitLab to act as a Maven repository or NPM registry. **(PREMIUM ONLY)** + +## Package Registry administration + +- [Container Registry](packages/container_registry.md): Configure Container Registry with GitLab. +- [Package Registry](packages/index.md): Enable GitLab to act as an NPM Registry and a Maven Repository. **(PREMIUM ONLY)** +- [Dependency Proxy](packages/dependency_proxy.md): Configure the Dependency Proxy, a local proxy for frequently used upstream images/packages. **(PREMIUM ONLY)** ### Repository settings diff --git a/doc/administration/maven_packages.md b/doc/administration/maven_packages.md index d8551f64ece..cdcce79f8f9 100644 --- a/doc/administration/maven_packages.md +++ b/doc/administration/maven_packages.md @@ -1,5 +1,5 @@ --- -redirect_to: 'packages.md' +redirect_to: 'packages/index.md' --- -This document was moved to [another location](packages.md). +This document was moved to [another location](packages/index.md). diff --git a/doc/administration/maven_repository.md b/doc/administration/maven_repository.md index d8551f64ece..cdcce79f8f9 100644 --- a/doc/administration/maven_repository.md +++ b/doc/administration/maven_repository.md @@ -1,5 +1,5 @@ --- -redirect_to: 'packages.md' +redirect_to: 'packages/index.md' --- -This document was moved to [another location](packages.md). +This document was moved to [another location](packages/index.md). diff --git a/doc/administration/npm_registry.md b/doc/administration/npm_registry.md index d8551f64ece..cdcce79f8f9 100644 --- a/doc/administration/npm_registry.md +++ b/doc/administration/npm_registry.md @@ -1,5 +1,5 @@ --- -redirect_to: 'packages.md' +redirect_to: 'packages/index.md' --- -This document was moved to [another location](packages.md). +This document was moved to [another location](packages/index.md). diff --git a/doc/administration/packages.md b/doc/administration/packages.md index 1628b6d6f91..cdcce79f8f9 100644 --- a/doc/administration/packages.md +++ b/doc/administration/packages.md @@ -1,176 +1,5 @@ -# GitLab Packages administration **(PREMIUM ONLY)** +--- +redirect_to: 'packages/index.md' +--- -GitLab Packages allows organizations to utilize GitLab as a private repository -for a variety of common package managers. Users are able to build and publish -packages, which can be easily consumed as a dependency in downstream projects. - -The Packages feature allows GitLab to act as a repository for the following: - -| Software repository | Description | Available in GitLab version | -| ------------------- | ----------- | --------------------------- | -| [Maven Repository](../user/project/packages/maven_repository.md) | The GitLab Maven Repository enables every project in GitLab to have its own space to store [Maven](https://maven.apache.org/) packages. | 11.3+ | -| [NPM Registry](../user/project/packages/npm_registry.md) | The GitLab NPM Registry enables every project in GitLab to have its own space to store [NPM](https://www.npmjs.com/) packages. | 11.7+ | - -Don't you see your package management system supported yet? -Please consider contributing -to GitLab. This [development documentation](../development/packages.md) will guide you through the process. - -## Enabling the Packages feature - -NOTE: **Note:** -After the Packages feature is enabled, the repositories are available -for all new projects by default. To enable it for existing projects, users will -have to explicitly do so in the project's settings. - -To enable the Packages feature: - -**Omnibus GitLab installations** - -1. Edit `/etc/gitlab/gitlab.rb` and add the following line: - - ```ruby - gitlab_rails['packages_enabled'] = true - ``` - -1. Save the file and [reconfigure GitLab][] for the changes to take effect. - -**Installations from source** - -1. After the installation is complete, you will have to configure the `packages` - section in `config/gitlab.yml`. Set to `true` to enable it: - - ```yaml - packages: - enabled: true - ``` - -1. [Restart GitLab] for the changes to take effect. - -## Changing the storage path - -By default, the packages are stored locally, but you can change the default -local location or even use object storage. - -### Changing the local storage path - -The packages for Omnibus GitLab installations are stored under -`/var/opt/gitlab/gitlab-rails/shared/packages/` and for source -installations under `shared/packages/` (relative to the Git homedir). -To change the local storage path: - -**Omnibus GitLab installations** - -1. Edit `/etc/gitlab/gitlab.rb` and add the following line: - - ```ruby - gitlab_rails['packages_storage_path'] = "/mnt/packages" - ``` - -1. Save the file and [reconfigure GitLab][] for the changes to take effect. - -**Installations from source** - -1. Edit the `packages` section in `config/gitlab.yml`: - - ```yaml - packages: - enabled: true - storage_path: shared/packages - ``` - -1. [Restart GitLab] for the changes to take effect. - -### Using object storage - -Instead of relying on the local storage, you can use an object storage to -upload packages: - -**Omnibus GitLab installations** - -1. Edit `/etc/gitlab/gitlab.rb` and add the following lines (uncomment where - necessary): - - ```ruby - gitlab_rails['packages_enabled'] = true - gitlab_rails['packages_storage_path'] = "/var/opt/gitlab/gitlab-rails/shared/packages" - gitlab_rails['packages_object_store_enabled'] = true - gitlab_rails['packages_object_store_remote_directory'] = "packages" # The bucket name. - gitlab_rails['packages_object_store_direct_upload'] = false # Use Object Storage directly for uploads instead of background uploads if enabled (Default: false). - gitlab_rails['packages_object_store_background_upload'] = true # Temporary option to limit automatic upload (Default: true). - gitlab_rails['packages_object_store_proxy_download'] = false # Passthrough all downloads via GitLab instead of using Redirects to Object Storage. - gitlab_rails['packages_object_store_connection'] = { - ## - ## If the provider is AWS S3, uncomment the following - ## - #'provider' => 'AWS', - #'region' => 'eu-west-1', - #'aws_access_key_id' => 'AWS_ACCESS_KEY_ID', - #'aws_secret_access_key' => 'AWS_SECRET_ACCESS_KEY', - ## - ## If the provider is other than AWS (an S3-compatible one), uncomment the following - ## - #'host' => 's3.amazonaws.com', - #'aws_signature_version' => 4 # For creation of signed URLs. Set to 2 if provider does not support v4. - #'endpoint' => 'https://s3.amazonaws.com' # Useful for S3-compliant services such as DigitalOcean Spaces. - #'path_style' => false # If true, use 'host/bucket_name/object' instead of 'bucket_name.host/object'. - } - ``` - -1. Save the file and [reconfigure GitLab][] for the changes to take effect. - -**Installations from source** - -1. Edit the `packages` section in `config/gitlab.yml` (uncomment where necessary): - - ```yaml - packages: - enabled: true - ## - ## The location where build packages are stored (default: shared/packages). - ## - #storage_path: shared/packages - object_store: - enabled: false - remote_directory: packages # The bucket name. - #direct_upload: false # Use Object Storage directly for uploads instead of background uploads if enabled (Default: false). - #background_upload: true # Temporary option to limit automatic upload (Default: true). - #proxy_download: false # Passthrough all downloads via GitLab instead of using Redirects to Object Storage. - connection: - ## - ## If the provider is AWS S3, uncomment the following - ## - #provider: AWS - #region: us-east-1 - #aws_access_key_id: AWS_ACCESS_KEY_ID - #aws_secret_access_key: AWS_SECRET_ACCESS_KEY - ## - ## If the provider is other than AWS (an S3-compatible one), uncomment the following - ## - #host: 's3.amazonaws.com' # default: s3.amazonaws.com. - #aws_signature_version: 4 # For creation of signed URLs. Set to 2 if provider does not support v4. - #endpoint: 'https://s3.amazonaws.com' # Useful for S3-compliant services such as DigitalOcean Spaces. - #path_style: false # If true, use 'host/bucket_name/object' instead of 'bucket_name.host/object'. - ``` - -1. [Restart GitLab] for the changes to take effect. - -### Migrating local packages to object storage - -After [configuring the object storage](#using-object-storage), you may use the -following task to migrate existing packages from the local storage to the remote one. -The processing will be done in a background worker and requires **no downtime**. - -For Omnibus GitLab: - -```sh -sudo gitlab-rake "gitlab:packages:migrate" -``` - -For installations from source: - -```bash -RAILS_ENV=production sudo -u git -H bundle exec rake gitlab:packages:migrate -``` - -[reconfigure gitlab]: restart_gitlab.md#omnibus-gitlab-reconfigure "How to reconfigure Omnibus GitLab" -[restart gitlab]: restart_gitlab.md#omnibus-gitlab-reconfigure "How to reconfigure Omnibus GitLab" +This document was moved to [another location](packages/index.md). diff --git a/doc/administration/packages/container_registry.md b/doc/administration/packages/container_registry.md new file mode 100644 index 00000000000..e3c793ee339 --- /dev/null +++ b/doc/administration/packages/container_registry.md @@ -0,0 +1,882 @@ +# GitLab Container Registry administration + +> - [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4040) in GitLab 8.8. +> - Container Registry manifest `v1` support was added in GitLab 8.9 to support +> Docker versions earlier than 1.10. + +NOTE: **Note:** +This document is about the admin guide. To learn how to use GitLab Container +Registry [user documentation](../../user/packages/container_registry/index.md). + +With the Container Registry integrated into GitLab, every project can have its +own space to store its Docker images. + +You can read more about the Docker Registry at +<https://docs.docker.com/registry/introduction/>. + +## Enable the Container Registry + +**Omnibus GitLab installations** + +All you have to do is configure the domain name under which the Container +Registry will listen to. Read +[#container-registry-domain-configuration](#container-registry-domain-configuration) +and pick one of the two options that fits your case. + +NOTE: **Note:** +The container registry works under HTTPS by default. Using HTTP is possible +but not recommended and out of the scope of this document. +Read the [insecure Registry documentation](https://docs.docker.com/registry/insecure/) +if you want to implement this. + +**Installations from source** + +If you have installed GitLab from source: + +1. You will have to [install Registry](https://docs.docker.com/registry/deploying/) by yourself. +1. After the installation is complete, you will have to configure the Registry's + settings in `gitlab.yml` in order to enable it. +1. Use the sample NGINX configuration file that is found under + [`lib/support/nginx/registry-ssl`](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/support/nginx/registry-ssl) and edit it to match the + `host`, `port` and TLS certs paths. + +The contents of `gitlab.yml` are: + +```yaml +registry: + enabled: true + host: registry.gitlab.example.com + port: 5005 + api_url: http://localhost:5000/ + key: config/registry.key + path: shared/registry + issuer: gitlab-issuer +``` + +where: + +| Parameter | Description | +| --------- | ----------- | +| `enabled` | `true` or `false`. Enables the Registry in GitLab. By default this is `false`. | +| `host` | The host URL under which the Registry will run and the users will be able to use. | +| `port` | The port under which the external Registry domain will listen on. | +| `api_url` | The internal API URL under which the Registry is exposed to. It defaults to `http://localhost:5000`. | +| `key` | The private key location that is a pair of Registry's `rootcertbundle`. Read the [token auth configuration documentation](https://docs.docker.com/registry/configuration/#token). | +| `path` | This should be the same directory like specified in Registry's `rootdirectory`. Read the [storage configuration documentation](https://docs.docker.com/registry/configuration/#storage). This path needs to be readable by the GitLab user, the web-server user and the Registry user. Read more in [#container-registry-storage-path](#container-registry-storage-path). | +| `issuer` | This should be the same value as configured in Registry's `issuer`. Read the [token auth configuration documentation](https://docs.docker.com/registry/configuration/#token). | + +NOTE: **Note:** +A Registry init file is not shipped with GitLab if you install it from source. +Hence, [restarting GitLab](../restart_gitlab.md#installations-from-source) will not restart the Registry should +you modify its settings. Read the upstream documentation on how to achieve that. + +At the **absolute** minimum, make sure your [Registry configuration](https://docs.docker.com/registry/configuration/#auth) +has `container_registry` as the service and `https://gitlab.example.com/jwt/auth` +as the realm: + +```yaml +auth: + token: + realm: https://gitlab.example.com/jwt/auth + service: container_registry + issuer: gitlab-issuer + rootcertbundle: /root/certs/certbundle +``` + +CAUTION: **Caution:** +If `auth` is not set up, users will be able to pull docker images without authentication. + +## Container Registry domain configuration + +There are two ways you can configure the Registry's external domain. Either: + +- [Use the existing GitLab domain](#configure-container-registry-under-an-existing-gitlab-domain) where in that case + the Registry will have to listen on a port and reuse GitLab's TLS certificate, +- [Use a completely separate domain](#configure-container-registry-under-its-own-domain) with a new TLS certificate + for that domain. + +Since the container Registry requires a TLS certificate, in the end it all boils +down to how easy or pricey is to get a new one. + +Please take this into consideration before configuring the Container Registry +for the first time. + +### Configure Container Registry under an existing GitLab domain + +If the Registry is configured to use the existing GitLab domain, you can +expose the Registry on a port so that you can reuse the existing GitLab TLS +certificate. + +Assuming that the GitLab domain is `https://gitlab.example.com` and the port the +Registry is exposed to the outside world is `4567`, here is what you need to set +in `gitlab.rb` or `gitlab.yml` if you are using Omnibus GitLab or installed +GitLab from source respectively. + +NOTE: **Note:** +Be careful to choose a port different than the one that Registry listens to (`5000` by default), +otherwise you will run into conflicts. + +**Omnibus GitLab installations** + +1. Your `/etc/gitlab/gitlab.rb` should contain the Registry URL as well as the + path to the existing TLS certificate and key used by GitLab: + + ```ruby + registry_external_url 'https://gitlab.example.com:4567' + ``` + + Note how the `registry_external_url` is listening on HTTPS under the + existing GitLab URL, but on a different port. + + If your TLS certificate is not in `/etc/gitlab/ssl/gitlab.example.com.crt` + and key not in `/etc/gitlab/ssl/gitlab.example.com.key` uncomment the lines + below: + + ```ruby + registry_nginx['ssl_certificate'] = "/path/to/certificate.pem" + registry_nginx['ssl_certificate_key'] = "/path/to/certificate.key" + ``` + +1. Save the file and [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure) + for the changes to take effect. + +1. Validate using: + + ```sh + openssl s_client -showcerts -servername gitlab.example.com -connect gitlab.example.com:443 > cacert.pem + ``` + +NOTE: **Note:** +If your certificate provider provides the CA Bundle certificates, append them to the TLS certificate file. + +**Installations from source** + +1. Open `/home/git/gitlab/config/gitlab.yml`, find the `registry` entry and + configure it with the following settings: + + ``` + registry: + enabled: true + host: gitlab.example.com + port: 4567 + ``` + +1. Save the file and [restart GitLab](../restart_gitlab.md#installations-from-source) for the changes to take effect. +1. Make the relevant changes in NGINX as well (domain, port, TLS certificates path). + +Users should now be able to login to the Container Registry with their GitLab +credentials using: + +```bash +docker login gitlab.example.com:4567 +``` + +### Configure Container Registry under its own domain + +If the Registry is configured to use its own domain, you will need a TLS +certificate for that specific domain (e.g., `registry.example.com`) or maybe +a wildcard certificate if hosted under a subdomain of your existing GitLab +domain (e.g., `registry.gitlab.example.com`). + +NOTE: **Note:** +As well as manually generated SSL certificates (explained here), certificates automatically +generated by Let's Encrypt are also [supported in Omnibus installs](https://docs.gitlab.com/omnibus/settings/ssl.html#host-services). + +Let's assume that you want the container Registry to be accessible at +`https://registry.gitlab.example.com`. + +**Omnibus GitLab installations** + +1. Place your TLS certificate and key in + `/etc/gitlab/ssl/registry.gitlab.example.com.crt` and + `/etc/gitlab/ssl/registry.gitlab.example.com.key` and make sure they have + correct permissions: + + ```bash + chmod 600 /etc/gitlab/ssl/registry.gitlab.example.com.* + ``` + +1. Once the TLS certificate is in place, edit `/etc/gitlab/gitlab.rb` with: + + ```ruby + registry_external_url 'https://registry.gitlab.example.com' + ``` + + Note how the `registry_external_url` is listening on HTTPS. + +1. Save the file and [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure) for the changes to take effect. + +If you have a [wildcard certificate](https://en.wikipedia.org/wiki/Wildcard_certificate), you need to specify the path to the +certificate in addition to the URL, in this case `/etc/gitlab/gitlab.rb` will +look like: + +```ruby +registry_nginx['ssl_certificate'] = "/etc/gitlab/ssl/certificate.pem" +registry_nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/certificate.key" +``` + +**Installations from source** + +1. Open `/home/git/gitlab/config/gitlab.yml`, find the `registry` entry and + configure it with the following settings: + + ```yaml + registry: + enabled: true + host: registry.gitlab.example.com + ``` + +1. Save the file and [restart GitLab](../restart_gitlab.md#installations-from-source) for the changes to take effect. +1. Make the relevant changes in NGINX as well (domain, port, TLS certificates path). + +Users should now be able to login to the Container Registry using their GitLab +credentials: + +```bash +docker login registry.gitlab.example.com +``` + +## Disable Container Registry site-wide + +NOTE: **Note:** +Disabling the Registry in the Rails GitLab application as set by the following +steps, will not remove any existing Docker images. This is handled by the +Registry application itself. + +**Omnibus GitLab** + +1. Open `/etc/gitlab/gitlab.rb` and set `registry['enable']` to `false`: + + ```ruby + registry['enable'] = false + ``` + +1. Save the file and [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure) for the changes to take effect. + +**Installations from source** + +1. Open `/home/git/gitlab/config/gitlab.yml`, find the `registry` entry and + set `enabled` to `false`: + + ```yaml + registry: + enabled: false + ``` + +1. Save the file and [restart GitLab](../restart_gitlab.md#installations-from-source) for the changes to take effect. + +## Disable Container Registry for new projects site-wide + +If the Container Registry is enabled, then it will be available on all new +projects. To disable this function and let the owners of a project to enable +the Container Registry by themselves, follow the steps below. + +**Omnibus GitLab installations** + +1. Edit `/etc/gitlab/gitlab.rb` and add the following line: + + ```ruby + gitlab_rails['gitlab_default_projects_features_container_registry'] = false + ``` + +1. Save the file and [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure) for the changes to take effect. + +**Installations from source** + +1. Open `/home/git/gitlab/config/gitlab.yml`, find the `default_projects_features` + entry and configure it so that `container_registry` is set to `false`: + + ```yaml + ## Default project features settings + default_projects_features: + issues: true + merge_requests: true + wiki: true + snippets: false + builds: true + container_registry: false + ``` + +1. Save the file and [restart GitLab](../restart_gitlab.md#installations-from-source) for the changes to take effect. + +## Container Registry storage path + +NOTE: **Note:** +For configuring storage in the cloud instead of the filesystem, see the +[storage driver configuration](#container-registry-storage-driver). + +If you want to store your images on the filesystem, you can change the storage +path for the Container Registry, follow the steps below. + +This path is accessible to: + +- The user running the Container Registry daemon. +- The user running GitLab. + +CAUTION: **Warning** You should confirm that all GitLab, Registry and web server users +have access to this directory. + +**Omnibus GitLab installations** + +The default location where images are stored in Omnibus, is +`/var/opt/gitlab/gitlab-rails/shared/registry`. To change it: + +1. Edit `/etc/gitlab/gitlab.rb`: + + ```ruby + gitlab_rails['registry_path'] = "/path/to/registry/storage" + ``` + +1. Save the file and [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure) for the changes to take effect. + +**Installations from source** + +The default location where images are stored in source installations, is +`/home/git/gitlab/shared/registry`. To change it: + +1. Open `/home/git/gitlab/config/gitlab.yml`, find the `registry` entry and + change the `path` setting: + + ```yaml + registry: + path: shared/registry + ``` + +1. Save the file and [restart GitLab](../restart_gitlab.md#installations-from-source) for the changes to take effect. + +## Container Registry storage driver + +You can configure the Container Registry to use a different storage backend by +configuring a different storage driver. By default the GitLab Container Registry +is configured to use the filesystem driver, which makes use of [storage path](#container-registry-storage-path) +configuration. + +NOTE: **Note:** Enabling a storage driver other than `filesystem` would mean +that your Docker client needs to be able to access the storage backend directly. +In that case, you must use an address that resolves and is accessible outside GitLab server. + +The different supported drivers are: + +| Driver | Description | +|------------|-------------------------------------| +| filesystem | Uses a path on the local filesystem | +| azure | Microsoft Azure Blob Storage | +| gcs | Google Cloud Storage | +| s3 | Amazon Simple Storage Service. Be sure to configure your storage bucket with the correct [S3 Permission Scopes](https://docs.docker.com/registry/storage-drivers/s3/#s3-permission-scopes). | +| swift | OpenStack Swift Object Storage | +| oss | Aliyun OSS | + +Read more about the individual driver's config options in the +[Docker Registry docs](https://docs.docker.com/registry/configuration/#storage). + +CAUTION: **Warning:** GitLab will not backup Docker images that are not stored on the +filesystem. Remember to enable backups with your object storage provider if +desired. + +NOTE: **Note:** +`regionendpoint` is only required when configuring an S3 compatible service such as Minio. It takes a URL such as `http://127.0.0.1:9000`. + +**Omnibus GitLab installations** + +To configure the `s3` storage driver in Omnibus: + +1. Edit `/etc/gitlab/gitlab.rb`: + + ```ruby + registry['storage'] = { + 's3' => { + 'accesskey' => 's3-access-key', + 'secretkey' => 's3-secret-key-for-access-key', + 'bucket' => 'your-s3-bucket', + 'region' => 'your-s3-region', + 'regionendpoint' => 'your-s3-regionendpoint' + } + } + ``` + +1. Save the file and [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure) for the changes to take effect. + +**Installations from source** + +Configuring the storage driver is done in your registry config YML file created +when you [deployed your docker registry](https://docs.docker.com/registry/deploying/). + +`s3` storage driver example: + +```yml +storage: + s3: + accesskey: 'AKIAKIAKI' + secretkey: 'secret123' + bucket: 'gitlab-registry-bucket-AKIAKIAKI' + region: 'your-s3-region' + regionendpoint: 'your-s3-regionendpoint' + cache: + blobdescriptor: inmemory + delete: + enabled: true +``` + +## Change the registry's internal port + +NOTE: **Note:** +This is not to be confused with the port that GitLab itself uses to expose +the Registry to the world. + +The Registry server listens on localhost at port `5000` by default, +which is the address for which the Registry server should accept connections. +In the examples below we set the Registry's port to `5001`. + +**Omnibus GitLab** + +1. Open `/etc/gitlab/gitlab.rb` and set `registry['registry_http_addr']`: + + ```ruby + registry['registry_http_addr'] = "localhost:5001" + ``` + +1. Save the file and [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure) for the changes to take effect. + +**Installations from source** + +1. Open the configuration file of your Registry server and edit the + [`http:addr`](https://docs.docker.com/registry/configuration/#http) value: + + ```yaml + http + addr: localhost:5001 + ``` + +1. Save the file and restart the Registry server. + +## Disable Container Registry per project + +If Registry is enabled in your GitLab instance, but you don't need it for your +project, you can disable it from your project's settings. Read the user guide +on how to achieve that. + +## Disable Container Registry but use GitLab as an auth endpoint + +**Omnibus GitLab** + +You can use GitLab as an auth endpoint and use a non-bundled Container Registry. + +1. Open `/etc/gitlab/gitlab.rb` and set necessary configurations: + + ```ruby + gitlab_rails['registry_enabled'] = true + gitlab_rails['registry_host'] = "registry.gitlab.example.com" + gitlab_rails['registry_port'] = "5005" + gitlab_rails['registry_api_url'] = "http://localhost:5000" + gitlab_rails['registry_path'] = "/var/opt/gitlab/gitlab-rails/shared/registry" + gitlab_rails['registry_issuer'] = "omnibus-gitlab-issuer" + ``` + +1. A certificate keypair is required for GitLab and the Container Registry to + communicate securely. By default Omnibus GitLab will generate one keypair, + which is saved to `/var/opt/gitlab/gitlab-rails/etc/gitlab-registry.key`. + When using a non-bundled Container Registry, you will need to supply a + custom certificate key. To do that, add the following to + `/etc/gitlab/gitlab.rb` + + ```ruby + gitlab_rails['registry_key_path'] = "/custom/path/to/registry-key.key" + # registry['internal_key'] should contain the contents of the custom key + # file. Line breaks in the key file should be marked using `\n` character + # Example: + registry['internal_key'] = "---BEGIN RSA PRIVATE KEY---\nMIIEpQIBAA\n" + ``` + + NOTE: **Note:** + The file specified at `registry_key_path` gets populated with the + content specified by `internal_key`, each time reconfigure is executed. If + no file is specified, Omnibus GitLab will default it to + `/var/opt/gitlab/gitlab-rails/etc/gitlab-registry.key` and will populate + it. + +1. Save the file and [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure) for the changes to take effect. + +**Installations from source** + +1. Open `/home/git/gitlab/config/gitlab.yml`, and edit the configuration settings under `registry`: + + ```yaml + ## Container Registry + + registry: + enabled: true + host: "registry.gitlab.example.com" + port: "5005" + api_url: "http://localhost:5000" + path: /var/opt/gitlab/gitlab-rails/shared/registry + key: /var/opt/gitlab/gitlab-rails/certificate.key + issuer: omnibus-gitlab-issuer + ``` + +1. Save the file and [restart GitLab](../restart_gitlab.md#installations-from-source) for the changes to take effect. + +## Storage limitations + +Currently, there is no storage limitation, which means a user can upload an +infinite amount of Docker images with arbitrary sizes. This setting will be +configurable in future releases. + +## Configure Container Registry notifications + +You can configure the Container Registry to send webhook notifications in +response to events happening within the registry. + +Read more about the Container Registry notifications config options in the +[Docker Registry notifications documentation](https://docs.docker.com/registry/notifications/). + +NOTE: **Note:** +Multiple endpoints can be configured for the Container Registry. + +**Omnibus GitLab installations** + +To configure a notification endpoint in Omnibus: + +1. Edit `/etc/gitlab/gitlab.rb`: + + ```ruby + registry['notifications'] = [ + { + 'name' => 'test_endpoint', + 'url' => 'https://gitlab.example.com/notify', + 'timeout' => '500ms', + 'threshold' => 5, + 'backoff' => '1s', + 'headers' => { + "Authorization" => ["AUTHORIZATION_EXAMPLE_TOKEN"] + } + } + ] + ``` + +1. Save the file and [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure) for the changes to take effect. + +**Installations from source** + +Configuring the notification endpoint is done in your registry config YML file created +when you [deployed your docker registry](https://docs.docker.com/registry/deploying/). + +Example: + +```yaml +notifications: + endpoints: + - name: alistener + disabled: false + url: https://my.listener.com/event + headers: <http.Header> + timeout: 500 + threshold: 5 + backoff: 1000 +``` + +## Troubleshooting + +Before diving in to the following sections, here's some basic troubleshooting: + +1. Check to make sure that the system clock on your Docker client and GitLab server have + been synchronized (e.g. via NTP). + +1. If you are using an S3-backed Registry, double check that the IAM + permissions and the S3 credentials (including region) are correct. See [the + sample IAM policy](https://docs.docker.com/registry/storage-drivers/s3/) + for more details. + +1. Check the Registry logs (e.g. `/var/log/gitlab/registry/current`) and the GitLab production logs + for errors (e.g. `/var/log/gitlab/gitlab-rails/production.log`). You may be able to find clues + there. + +### Using self-signed certificates with Container Registry + +If you're using a self-signed certificate with your Container Registry, you +might encounter issues during the CI jobs like the following: + +``` +Error response from daemon: Get registry.example.com/v1/users/: x509: certificate signed by unknown authority +``` + +The Docker daemon running the command expects a cert signed by a recognized CA, +thus the error above. + +While GitLab doesn't support using self-signed certificates with Container +Registry out of the box, it is possible to make it work by +[instructing the docker-daemon to trust the self-signed certificates](https://docs.docker.com/registry/insecure/#use-self-signed-certificates), +mounting the docker-daemon and setting `privileged = false` in the Runner's +`config.toml`. Setting `privileged = true` takes precedence over the docker-daemon: + +```toml + [runners.docker] + image = "ruby:2.1" + privileged = false + volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"] +``` + +Additional information about this: [issue 18239](https://gitlab.com/gitlab-org/gitlab-ce/issues/18239). + +### AWS S3 with the GitLab registry error when pushing large images + +When using AWS S3 with the GitLab registry, an error may occur when pushing +large images. Look in the Registry log for the following error: + +``` +level=error msg="response completed with error" err.code=unknown err.detail="unexpected EOF" err.message="unknown error" +``` + +To resolve the error specify a `chunksize` value in the Registry configuration. +Start with a value between `25000000` (25MB) and `50000000` (50MB). + +**For Omnibus installations** + +1. Edit `/etc/gitlab/gitlab.rb`: + + ```ruby + registry['storage'] = { + 's3' => { + 'accesskey' => 'AKIAKIAKI', + 'secretkey' => 'secret123', + 'bucket' => 'gitlab-registry-bucket-AKIAKIAKI', + 'chunksize' => 25000000 + } + } + ``` + +1. Save the file and [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure) for the changes to take effect. + +**For installations from source** + +1. Edit `config/gitlab.yml`: + + ```yaml + storage: + s3: + accesskey: 'AKIAKIAKI' + secretkey: 'secret123' + bucket: 'gitlab-registry-bucket-AKIAKIAKI' + chunksize: 25000000 + ``` + +1. Save the file and [restart GitLab](../restart_gitlab.md#installations-from-source) for the changes to take effect. + +### Supporting older Docker clients + +As of GitLab 11.9, we began shipping version 2.7.1 of the Docker container registry, which disables the schema1 manifest by default. If you are still using older Docker clients (1.9 or older), you may experience an error pushing images. See [omnibus-4145](https://gitlab.com/gitlab-org/omnibus-gitlab/issues/4145) for more details. + +You can add a configuration option for backwards compatibility. + +**For Omnibus installations** + +1. Edit `/etc/gitlab/gitlab.rb`: + + ```ruby + registry['compatibility_schema1_enabled'] = true + ``` + +1. Save the file and [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure) for the changes to take effect. + +**For installations from source** + +1. Edit the YML configuration file you created when you [deployed the registry](https://docs.docker.com/registry/deploying/). Add the following snippet: + + ```yaml + compatibility: + schema1: + enabled: true + ``` + +1. Restart the registry for the changes to take affect. + +### Docker connection error + +A Docker connection error can occur when there are special characters in either the group, +project or branch name. Special characters can include: + +- Leading underscore +- Trailing hyphen/dash +- Double hyphen/dash + +To get around this, you can [change the group path](../../user/group/index.md#changing-a-groups-path), +[change the project path](../../user/project/settings/index.md#renaming-a-repository) or change the +branch name. Another option is to create a [push rule](../../push_rules/push_rules.html) to prevent +this at the instance level. + +### Image push errors + +When getting errors or "retrying" loops in an attempt to push an image but `docker login` works fine, +there is likely an issue with the headers forwarded to the registry by NGINX. The default recommended +NGINX configurations should handle this, but it might occur in custom setups where the SSL is +offloaded to a third party reverse proxy. + +This problem was discussed in a [docker project issue](https://github.com/docker/distribution/issues/970) +and a simple solution would be to enable relative URLs in the Registry. + +**For Omnibus installations** + +1. Edit `/etc/gitlab/gitlab.rb`: + + ```ruby + registry['env'] = { + "REGISTRY_HTTP_RELATIVEURLS" => true + } + ``` + +1. Save the file and [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure) for the changes to take effect. + +**For installations from source** + +1. Edit the YML configuration file you created when you [deployed the registry](https://docs.docker.com/registry/deploying/). Add the following snippet: + + ```yaml + http: + relativeurls: true + ``` + +1. Save the file and [restart GitLab](../restart_gitlab.md#installations-from-source) for the changes to take effect. + +### Enable the Registry debug server + +The optional debug server can be enabled by setting the registry debug address +in your `gitlab.rb` configuration. + +```ruby +registry['debug_addr'] = "localhost:5001" +``` + +After adding the setting, [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure) to apply the change. + +Use curl to request debug output from the debug server: + +```bash +curl localhost:5001/debug/health +curl localhost:5001/debug/vars +``` + +### Advanced Troubleshooting + +NOTE: **Note:** +The following section is only recommended for experts. + +Sometimes it's not obvious what is wrong, and you may need to dive deeper into +the communication between the Docker client and the Registry to find out +what's wrong. We will use a concrete example in the past to illustrate how to +diagnose a problem with the S3 setup. + +#### Unexpected 403 error during push + +A user attempted to enable an S3-backed Registry. The `docker login` step went +fine. However, when pushing an image, the output showed: + +```text +The push refers to a repository [s3-testing.myregistry.com:4567/root/docker-test/docker-image] +dc5e59c14160: Pushing [==================================================>] 14.85 kB +03c20c1a019a: Pushing [==================================================>] 2.048 kB +a08f14ef632e: Pushing [==================================================>] 2.048 kB +228950524c88: Pushing 2.048 kB +6a8ecde4cc03: Pushing [==> ] 9.901 MB/205.7 MB +5f70bf18a086: Pushing 1.024 kB +737f40e80b7f: Waiting +82b57dbc5385: Waiting +19429b698a22: Waiting +9436069b92a3: Waiting +error parsing HTTP 403 response body: unexpected end of JSON input: "" +``` + +This error is ambiguous, as it's not clear whether the 403 is coming from the +GitLab Rails application, the Docker Registry, or something else. In this +case, since we know that since the login succeeded, we probably need to look +at the communication between the client and the Registry. + +The REST API between the Docker client and Registry is [described +here](https://docs.docker.com/registry/spec/api/). Normally, one would just +use Wireshark or tcpdump to capture the traffic and see where things went +wrong. However, since all communications between Docker clients and servers +are done over HTTPS, it's a bit difficult to decrypt the traffic quickly even +if you know the private key. What can we do instead? + +One way would be to disable HTTPS by setting up an [insecure +Registry](https://docs.docker.com/registry/insecure/). This could introduce a +security hole and is only recommended for local testing. If you have a +production system and can't or don't want to do this, there is another way: +use mitmproxy, which stands for Man-in-the-Middle Proxy. + +#### mitmproxy + +[mitmproxy](https://mitmproxy.org/) allows you to place a proxy between your +client and server to inspect all traffic. One wrinkle is that your system +needs to trust the mitmproxy SSL certificates for this to work. + +The following installation instructions assume you are running Ubuntu: + +1. [Install mitmproxy](https://docs.mitmproxy.org/stable/overview-installation/). +1. Run `mitmproxy --port 9000` to generate its certificates. + Enter <kbd>CTRL</kbd>-<kbd>C</kbd> to quit. +1. Install the certificate from `~/.mitmproxy` to your system: + + ```sh + sudo cp ~/.mitmproxy/mitmproxy-ca-cert.pem /usr/local/share/ca-certificates/mitmproxy-ca-cert.crt + sudo update-ca-certificates + ``` + +If successful, the output should indicate that a certificate was added: + +```sh +Updating certificates in /etc/ssl/certs... 1 added, 0 removed; done. +Running hooks in /etc/ca-certificates/update.d....done. +``` + +To verify that the certificates are properly installed, run: + +```sh +mitmproxy --port 9000 +``` + +This will run mitmproxy on port `9000`. In another window, run: + +```sh +curl --proxy http://localhost:9000 https://httpbin.org/status/200 +``` + +If everything is set up correctly, you will see information on the mitmproxy window and +no errors from the curl commands. + +#### Running the Docker daemon with a proxy + +For Docker to connect through a proxy, you must start the Docker daemon with the +proper environment variables. The easiest way is to shutdown Docker (e.g. `sudo initctl stop docker`) +and then run Docker by hand. As root, run: + +```sh +export HTTP_PROXY="http://localhost:9000" +export HTTPS_PROXY="https://localhost:9000" +docker daemon --debug +``` + +This will launch the Docker daemon and proxy all connections through mitmproxy. + +#### Running the Docker client + +Now that we have mitmproxy and Docker running, we can attempt to login and push +a container image. You may need to run as root to do this. For example: + +```sh +docker login s3-testing.myregistry.com:4567 +docker push s3-testing.myregistry.com:4567/root/docker-test/docker-image +``` + +In the example above, we see the following trace on the mitmproxy window: + +![mitmproxy output from Docker](img/mitmproxy-docker.png) + +The above image shows: + +- The initial PUT requests went through fine with a 201 status code. +- The 201 redirected the client to the S3 bucket. +- The HEAD request to the AWS bucket reported a 403 Unauthorized. + +What does this mean? This strongly suggests that the S3 user does not have the right +[permissions to perform a HEAD request](http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectHEAD.html). +The solution: check the [IAM permissions again](https://docs.docker.com/registry/storage-drivers/s3/). +Once the right permissions were set, the error will go away. diff --git a/doc/administration/packages/dependency_proxy.md b/doc/administration/packages/dependency_proxy.md new file mode 100644 index 00000000000..967ba2592c3 --- /dev/null +++ b/doc/administration/packages/dependency_proxy.md @@ -0,0 +1,148 @@ +# GitLab Dependency Proxy administration **(PREMIUM ONLY)** + +> [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/issues/7934) in [GitLab Premium](https://about.gitlab.com/pricing/) 11.11. + +GitLab can be utilized as a dependency proxy for a variety of common package managers. + +This is the administration documentation. If you want to learn how to use the +dependency proxies, see the [user guide](../../user/group/dependency_proxy/index.md). + +## Enabling the Dependency Proxy feature + +NOTE: **Note:** +Dependency proxy requires the Puma web server to be enabled. +Puma support is EXPERIMENTAL at this time. + +To enable the Dependency proxy feature: + +**Omnibus GitLab installations** + +1. Edit `/etc/gitlab/gitlab.rb` and add the following line: + + ```ruby + gitlab_rails['dependency_proxy_enabled'] = true + ``` + +1. Save the file and [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure "How to reconfigure Omnibus GitLab") for the changes to take effect. +1. Enable the [Puma web server](https://docs.gitlab.com/omnibus/settings/puma.html). + +**Installations from source** + +1. After the installation is complete, you will have to configure the `dependency_proxy` + section in `config/gitlab.yml`. Set to `true` to enable it: + + ```yaml + dependency_proxy: + enabled: true + ``` + +1. [Restart GitLab](../restart_gitlab.md#installations-from-source "How to restart GitLab") for the changes to take effect. +1. Enable the [Puma web server](../../install/installation.md#using-puma). + +## Changing the storage path + +By default, the dependency proxy files are stored locally, but you can change the default +local location or even use object storage. + +### Changing the local storage path + +The dependency proxy files for Omnibus GitLab installations are stored under +`/var/opt/gitlab/gitlab-rails/shared/dependency_proxy/` and for source +installations under `shared/dependency_proxy/` (relative to the Git home directory). +To change the local storage path: + +**Omnibus GitLab installations** + +1. Edit `/etc/gitlab/gitlab.rb` and add the following line: + + ```ruby + gitlab_rails['dependency_proxy_storage_path'] = "/mnt/dependency_proxy" + ``` + +1. Save the file and [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure "How to reconfigure Omnibus GitLab") for the changes to take effect. + +**Installations from source** + +1. Edit the `dependency_proxy` section in `config/gitlab.yml`: + + ```yaml + dependency_proxy: + enabled: true + storage_path: shared/dependency_proxy + ``` + +1. [Restart GitLab](../restart_gitlab.md#installations-from-source "How to restart GitLab") for the changes to take effect. + +### Using object storage + +Instead of relying on the local storage, you can use an object storage to +upload the blobs of the dependency proxy: + +**Omnibus GitLab installations** + +1. Edit `/etc/gitlab/gitlab.rb` and add the following lines (uncomment where + necessary): + + ```ruby + gitlab_rails['dependency_proxy_enabled'] = true + gitlab_rails['dependency_proxy_storage_path'] = "/var/opt/gitlab/gitlab-rails/shared/dependency_proxy" + gitlab_rails['dependency_proxy_object_store_enabled'] = true + gitlab_rails['dependency_proxy_object_store_remote_directory'] = "dependency_proxy" # The bucket name. + gitlab_rails['dependency_proxy_object_store_direct_upload'] = false # Use Object Storage directly for uploads instead of background uploads if enabled (Default: false). + gitlab_rails['dependency_proxy_object_store_background_upload'] = true # Temporary option to limit automatic upload (Default: true). + gitlab_rails['dependency_proxy_object_store_proxy_download'] = false # Passthrough all downloads via GitLab instead of using Redirects to Object Storage. + gitlab_rails['dependency_proxy_object_store_connection'] = { + ## + ## If the provider is AWS S3, uncomment the following + ## + #'provider' => 'AWS', + #'region' => 'eu-west-1', + #'aws_access_key_id' => 'AWS_ACCESS_KEY_ID', + #'aws_secret_access_key' => 'AWS_SECRET_ACCESS_KEY', + ## + ## If the provider is other than AWS (an S3-compatible one), uncomment the following + ## + #'host' => 's3.amazonaws.com', + #'aws_signature_version' => 4 # For creation of signed URLs. Set to 2 if provider does not support v4. + #'endpoint' => 'https://s3.amazonaws.com' # Useful for S3-compliant services such as DigitalOcean Spaces. + #'path_style' => false # If true, use 'host/bucket_name/object' instead of 'bucket_name.host/object'. + } + ``` + +1. Save the file and [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure "How to reconfigure Omnibus GitLab") for the changes to take effect. + +**Installations from source** + +1. Edit the `dependency_proxy` section in `config/gitlab.yml` (uncomment where necessary): + + ```yaml + dependency_proxy: + enabled: true + ## + ## The location where build dependency_proxy are stored (default: shared/dependency_proxy). + ## + #storage_path: shared/dependency_proxy + object_store: + enabled: false + remote_directory: dependency_proxy # The bucket name. + #direct_upload: false # Use Object Storage directly for uploads instead of background uploads if enabled (Default: false). + #background_upload: true # Temporary option to limit automatic upload (Default: true). + #proxy_download: false # Passthrough all downloads via GitLab instead of using Redirects to Object Storage. + connection: + ## + ## If the provider is AWS S3, uncomment the following + ## + #provider: AWS + #region: us-east-1 + #aws_access_key_id: AWS_ACCESS_KEY_ID + #aws_secret_access_key: AWS_SECRET_ACCESS_KEY + ## + ## If the provider is other than AWS (an S3-compatible one), uncomment the following + ## + #host: 's3.amazonaws.com' # default: s3.amazonaws.com. + #aws_signature_version: 4 # For creation of signed URLs. Set to 2 if provider does not support v4. + #endpoint: 'https://s3.amazonaws.com' # Useful for S3-compliant services such as DigitalOcean Spaces. + #path_style: false # If true, use 'host/bucket_name/object' instead of 'bucket_name.host/object'. + ``` + +1. [Restart GitLab](../restart_gitlab.md#installations-from-source "How to restart GitLab") for the changes to take effect. diff --git a/doc/user/project/img/mitmproxy-docker.png b/doc/administration/packages/img/mitmproxy-docker.png Binary files differindex aa3b6a0b830..aa3b6a0b830 100644 --- a/doc/user/project/img/mitmproxy-docker.png +++ b/doc/administration/packages/img/mitmproxy-docker.png diff --git a/doc/administration/packages/index.md b/doc/administration/packages/index.md new file mode 100644 index 00000000000..99ec5811681 --- /dev/null +++ b/doc/administration/packages/index.md @@ -0,0 +1,175 @@ +# GitLab Package Registry administration **(PREMIUM ONLY)** + +GitLab Packages allows organizations to utilize GitLab as a private repository +for a variety of common package managers. Users are able to build and publish +packages, which can be easily consumed as a dependency in downstream projects. + +The Packages feature allows GitLab to act as a repository for the following: + +| Software repository | Description | Available in GitLab version | +| ------------------- | ----------- | --------------------------- | +| [Maven Repository](../../user/packages/maven_repository/index.md) | The GitLab Maven Repository enables every project in GitLab to have its own space to store [Maven](https://maven.apache.org/) packages. | 11.3+ | +| [NPM Registry](../../user/packages/npm_registry/index.md) | The GitLab NPM Registry enables every project in GitLab to have its own space to store [NPM](https://www.npmjs.com/) packages. | 11.7+ | + +Don't you see your package management system supported yet? +Please consider contributing +to GitLab. This [development documentation](../../development/packages.md) will guide you through the process. + +## Enabling the Packages feature + +NOTE: **Note:** +After the Packages feature is enabled, the repositories are available +for all new projects by default. To enable it for existing projects, users will +have to explicitly do so in the project's settings. + +To enable the Packages feature: + +**Omnibus GitLab installations** + +1. Edit `/etc/gitlab/gitlab.rb` and add the following line: + + ```ruby + gitlab_rails['packages_enabled'] = true + ``` + +1. Save the file and [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure "How to reconfigure Omnibus GitLab") for the changes to take effect. + +**Installations from source** + +1. After the installation is complete, you will have to configure the `packages` + section in `config/gitlab.yml`. Set to `true` to enable it: + + ```yaml + packages: + enabled: true + ``` + +1. [Restart GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure "How to reconfigure Omnibus GitLab") for the changes to take effect. + +## Changing the storage path + +By default, the packages are stored locally, but you can change the default +local location or even use object storage. + +### Changing the local storage path + +The packages for Omnibus GitLab installations are stored under +`/var/opt/gitlab/gitlab-rails/shared/packages/` and for source +installations under `shared/packages/` (relative to the Git homedir). +To change the local storage path: + +**Omnibus GitLab installations** + +1. Edit `/etc/gitlab/gitlab.rb` and add the following line: + + ```ruby + gitlab_rails['packages_storage_path'] = "/mnt/packages" + ``` + +1. Save the file and [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure) + for the changes to take effect. + +**Installations from source** + +1. Edit the `packages` section in `config/gitlab.yml`: + + ```yaml + packages: + enabled: true + storage_path: shared/packages + ``` + +1. Save the file and [restart GitLab](../restart_gitlab.md#installations-from-source) for the changes to take effect. + +### Using object storage + +Instead of relying on the local storage, you can use an object storage to +upload packages: + +**Omnibus GitLab installations** + +1. Edit `/etc/gitlab/gitlab.rb` and add the following lines (uncomment where + necessary): + + ```ruby + gitlab_rails['packages_enabled'] = true + gitlab_rails['packages_storage_path'] = "/var/opt/gitlab/gitlab-rails/shared/packages" + gitlab_rails['packages_object_store_enabled'] = true + gitlab_rails['packages_object_store_remote_directory'] = "packages" # The bucket name. + gitlab_rails['packages_object_store_direct_upload'] = false # Use Object Storage directly for uploads instead of background uploads if enabled (Default: false). + gitlab_rails['packages_object_store_background_upload'] = true # Temporary option to limit automatic upload (Default: true). + gitlab_rails['packages_object_store_proxy_download'] = false # Passthrough all downloads via GitLab instead of using Redirects to Object Storage. + gitlab_rails['packages_object_store_connection'] = { + ## + ## If the provider is AWS S3, uncomment the following + ## + #'provider' => 'AWS', + #'region' => 'eu-west-1', + #'aws_access_key_id' => 'AWS_ACCESS_KEY_ID', + #'aws_secret_access_key' => 'AWS_SECRET_ACCESS_KEY', + ## + ## If the provider is other than AWS (an S3-compatible one), uncomment the following + ## + #'host' => 's3.amazonaws.com', + #'aws_signature_version' => 4 # For creation of signed URLs. Set to 2 if provider does not support v4. + #'endpoint' => 'https://s3.amazonaws.com' # Useful for S3-compliant services such as DigitalOcean Spaces. + #'path_style' => false # If true, use 'host/bucket_name/object' instead of 'bucket_name.host/object'. + } + ``` + +1. Save the file and [reconfigure GitLab](../restart_gitlab.md#omnibus-gitlab-reconfigure) + for the changes to take effect. + +**Installations from source** + +1. Edit the `packages` section in `config/gitlab.yml` (uncomment where necessary): + + ```yaml + packages: + enabled: true + ## + ## The location where build packages are stored (default: shared/packages). + ## + #storage_path: shared/packages + object_store: + enabled: false + remote_directory: packages # The bucket name. + #direct_upload: false # Use Object Storage directly for uploads instead of background uploads if enabled (Default: false). + #background_upload: true # Temporary option to limit automatic upload (Default: true). + #proxy_download: false # Passthrough all downloads via GitLab instead of using Redirects to Object Storage. + connection: + ## + ## If the provider is AWS S3, uncomment the following + ## + #provider: AWS + #region: us-east-1 + #aws_access_key_id: AWS_ACCESS_KEY_ID + #aws_secret_access_key: AWS_SECRET_ACCESS_KEY + ## + ## If the provider is other than AWS (an S3-compatible one), uncomment the following + ## + #host: 's3.amazonaws.com' # default: s3.amazonaws.com. + #aws_signature_version: 4 # For creation of signed URLs. Set to 2 if provider does not support v4. + #endpoint: 'https://s3.amazonaws.com' # Useful for S3-compliant services such as DigitalOcean Spaces. + #path_style: false # If true, use 'host/bucket_name/object' instead of 'bucket_name.host/object'. + ``` + +1. Save the file and [restart GitLab](../restart_gitlab.md#installations-from-source) for the changes to take effect. + +### Migrating local packages to object storage + +After [configuring the object storage](#using-object-storage), you may use the +following task to migrate existing packages from the local storage to the remote one. +The processing will be done in a background worker and requires **no downtime**. + +For Omnibus GitLab: + +```sh +sudo gitlab-rake "gitlab:packages:migrate" +``` + +For installations from source: + +```bash +RAILS_ENV=production sudo -u git -H bundle exec rake gitlab:packages:migrate +``` diff --git a/doc/api/container_registry.md b/doc/api/container_registry.md index bf544f64178..0957b502340 100644 --- a/doc/api/container_registry.md +++ b/doc/api/container_registry.md @@ -2,7 +2,7 @@ > [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/55978) in GitLab 11.8. -This is the API docs of the [GitLab Container Registry](../user/project/container_registry.md). +This is the API docs of the [GitLab Container Registry](../user/packages/container_registry/index.md). ## List registry repositories diff --git a/doc/api/groups.md b/doc/api/groups.md index 8b13462b887..18e71f488ce 100644 --- a/doc/api/groups.md +++ b/doc/api/groups.md @@ -208,7 +208,7 @@ Example response: ## Details of a group Get all details of a group. This endpoint can be accessed without authentication -if the group is publicly accessible. +if the group is publicly accessible. In case the user that requests is admin of the group, it will return the `runners_token` for the group too. ``` GET /groups/:id @@ -240,6 +240,7 @@ Example response: "request_access_enabled": false, "full_name": "Twitter", "full_path": "twitter", + "runners_token": "ba324ca7b1c77fc20bb9", "file_template_project_id": 1, "parent_id": null, "projects": [ diff --git a/doc/api/issues.md b/doc/api/issues.md index a89a6e7c5cc..a991baef230 100644 --- a/doc/api/issues.md +++ b/doc/api/issues.md @@ -57,7 +57,8 @@ GET /issues?confidential=true | `created_before` | datetime | no | Return issues created on or before the given time | | `updated_after` | datetime | no | Return issues updated on or after the given time | | `updated_before` | datetime | no | Return issues updated on or before the given time | -| `confidential` | Boolean | no | Filter confidential or public issues. | +| `confidential` | Boolean | no | Filter confidential or public issues. | +| `not` | Hash | no | Return issues that do not match the parameters supplied. Accepts: `labels`, `milestone`, `author_id`, `author_username`, `assignee_id`, `assignee_username`, `my_reaction_emoji`, `search`, `in` | ```bash curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/issues @@ -206,6 +207,7 @@ GET /groups/:id/issues?confidential=true | `updated_after` | datetime | no | Return issues updated on or after the given time | | `updated_before` | datetime | no | Return issues updated on or before the given time | | `confidential` | Boolean | no | Filter confidential or public issues. | +| `not` | Hash | no | Return issues that do not match the parameters supplied. Accepts: `labels`, `milestone`, `author_id`, `author_username`, `assignee_id`, `assignee_username`, `my_reaction_emoji`, `search`, `in` | ```bash curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/groups/4/issues @@ -354,6 +356,7 @@ GET /projects/:id/issues?confidential=true | `updated_after` | datetime | no | Return issues updated on or after the given time | | `updated_before` | datetime | no | Return issues updated on or before the given time | | `confidential` | Boolean | no | Filter confidential or public issues. | +| `not` | Hash | no | Return issues that do not match the parameters supplied. Accepts: `labels`, `milestone`, `author_id`, `author_username`, `assignee_id`, `assignee_username`, `my_reaction_emoji`, `search`, `in` | ```bash curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/4/issues diff --git a/doc/api/packages.md b/doc/api/packages.md index ca90771b085..c852be0ad7b 100644 --- a/doc/api/packages.md +++ b/doc/api/packages.md @@ -1,6 +1,6 @@ # Packages API **(PREMIUM)** -This is the API docs of [GitLab Packages](../administration/packages.md). +This is the API docs of [GitLab Packages](../administration/packages/index.md). ## List project packages diff --git a/doc/ci/docker/using_docker_build.md b/doc/ci/docker/using_docker_build.md index 4da527154ad..93317d310db 100644 --- a/doc/ci/docker/using_docker_build.md +++ b/doc/ci/docker/using_docker_build.md @@ -515,7 +515,7 @@ If you're running multiple Runners you will have to modify all configuration fil > login to GitLab's Container Registry. Once you've built a Docker image, you can push it up to the built-in -[GitLab Container Registry](../../user/project/container_registry.md). +[GitLab Container Registry](../../user/packages/container_registry/index.md). Some things you should be aware of: - You must [log in to the container registry](#authenticating-to-the-container-registry) diff --git a/doc/ci/docker/using_kaniko.md b/doc/ci/docker/using_kaniko.md index 925653f9fdf..0d78e1f6953 100644 --- a/doc/ci/docker/using_kaniko.md +++ b/doc/ci/docker/using_kaniko.md @@ -43,7 +43,7 @@ few important details: In the following example, kaniko is used to: 1. Build a Docker image. -1. Then push it to [GitLab Container Registry](../../user/project/container_registry.md). +1. Then push it to [GitLab Container Registry](../../user/packages/container_registry/index.md). The job will run only when a tag is pushed. A `config.json` file is created under `/kaniko/.docker` with the needed GitLab Container Registry credentials taken from the diff --git a/doc/ci/examples/laravel_with_gitlab_and_envoy/index.md b/doc/ci/examples/laravel_with_gitlab_and_envoy/index.md index 808e4285f2f..d79821ff258 100644 --- a/doc/ci/examples/laravel_with_gitlab_and_envoy/index.md +++ b/doc/ci/examples/laravel_with_gitlab_and_envoy/index.md @@ -437,7 +437,7 @@ We used `docker-php-ext-install` (provided by the official PHP Docker image) to #### Setting Up GitLab Container Registry -Now that we have our `Dockerfile` let's build and push it to our [GitLab Container Registry](../../../user/project/container_registry.md). +Now that we have our `Dockerfile` let's build and push it to our [GitLab Container Registry](../../../user/packages/container_registry/index.md). > The registry is the place to store and tag images for later use. Developers may want to maintain their own registry for private, company images, or for throw-away images used only in testing. Using GitLab Container Registry means you don't need to set up and administer yet another service or use a public registry. @@ -445,7 +445,7 @@ On your GitLab project repository navigate to the **Registry** tab. ![container registry page empty image](img/container_registry_page_empty_image.png) -You may need to [enable Container Registry](../../../user/project/container_registry.md#enable-the-container-registry-for-your-project) to your project to see this tab. You'll find it under your project's **Settings > General > Permissions**. +You may need to [enable Container Registry](../../../user/packages/container_registry/index.md#enable-the-container-registry-for-your-project) to your project to see this tab. You'll find it under your project's **Settings > General > Permissions**. To start using Container Registry on our machine, we first need to login to the GitLab registry using our GitLab username and password: diff --git a/doc/ci/introduction/index.md b/doc/ci/introduction/index.md index d5ba94f4d19..b15978a0aaa 100644 --- a/doc/ci/introduction/index.md +++ b/doc/ci/introduction/index.md @@ -187,9 +187,9 @@ according to each stage (Verify, Package, Release). - Perform a series of tests, such as [Container Scanning](../../user/application_security/container_scanning/index.md) **(ULTIMATE)**, [Dependency Scanning](../../user/application_security/dependency_scanning/index.md) **(ULTIMATE)**, and [JUnit tests](../junit_test_reports.md). - Deploy your changes with [Review Apps](../review_apps/index.md) to preview the app changes on every branch. 1. **Package**: - - Store Docker images with [Container Registry](../../user/project/container_registry.md). - - Store NPM packages with [NPM Registry](../../user/project/packages/npm_registry.md). **(PREMIUM)** - - Store Maven artifacts with [Maven Repository](../../user/project/packages/maven_repository.md). **(PREMIUM)** + - Store Docker images with [Container Registry](../../user/packages/container_registry/index.md). + - Store NPM packages with [NPM Registry](../../user/packages/npm_registry/index.md). **(PREMIUM)** + - Store Maven artifacts with [Maven Repository](../../user/packages/maven_repository/index.md). **(PREMIUM)** 1. **Release**: - Continuous Deployment, automatically deploying your app to production. - Continuous Delivery, manually click to deploy your app to production. diff --git a/doc/ci/jenkins/index.md b/doc/ci/jenkins/index.md index ace1204511e..29eba5ea928 100644 --- a/doc/ci/jenkins/index.md +++ b/doc/ci/jenkins/index.md @@ -27,7 +27,7 @@ There are some high level differences between the products worth mentioning: - The `.gitlab-ci.yml` file is checked in to the root of your repository, much like a Jenkinsfile, but is in the YAML format (see [complete reference](../yaml/README.md)) instead of a Groovy DSL. It's most analagous to the declarative Jenkinsfile format. -- GitLab comes with a [container registry](../../user/project/container_registry.md), and we recommend using +- GitLab comes with a [container registry](../../user/packages/container_registry/index.md), and we recommend using container images to set up your build environment. ## Groovy vs. YAML @@ -209,7 +209,7 @@ Because GitLab is integrated tightly with git, SCM polling options for triggers GitLab does not support a separate `tools` directive. Our best-practice reccomendation is to use pre-built container images, which can be cached, and can be built to already contain the tools you need for your pipelines. Pipelines can -be set up to automatically build these images as needed and deploy them to the [container registry](../../user/project/container_registry.md). +be set up to automatically build these images as needed and deploy them to the [container registry](../../user/packages/container_registry/index.md). If you're not using container images with Docker/Kubernetes, for example on Mac or FreeBSD, then the `shell` executor does require you to set up your environment either in advance or as part of the jobs. You could create a `before_script` diff --git a/doc/ci/triggers/README.md b/doc/ci/triggers/README.md index f62a4660713..4e486af9b29 100644 --- a/doc/ci/triggers/README.md +++ b/doc/ci/triggers/README.md @@ -277,6 +277,6 @@ removed with one of the future versions of GitLab. [ee]: https://about.gitlab.com/pricing/ [variables]: ../variables/README.md [predef]: ../variables/README.md#predefined-environment-variables -[registry]: ../../user/project/container_registry.md +[registry]: ../../user/packages/container_registry/index.md [permissions]: ../../user/permissions.md#job-permissions [trigapi]: ../../api/pipeline_triggers.md diff --git a/doc/ci/variables/predefined_variables.md b/doc/ci/variables/predefined_variables.md index 5a8de3dd4d1..e3ff3385f97 100644 --- a/doc/ci/variables/predefined_variables.md +++ b/doc/ci/variables/predefined_variables.md @@ -126,5 +126,5 @@ future GitLab releases.** | `GITLAB_FEATURES` | 10.6 | all | The comma separated list of licensed features available for your instance and plan | [gitlab-deploy-token]: ../../user/project/deploy_tokens/index.md#gitlab-deploy-token -[registry]: ../../user/project/container_registry.md +[registry]: ../../user/packages/container_registry/index.md [dependent-repositories]: ../../user/project/new_ci_build_permissions_model.md#dependent-repositories diff --git a/doc/container_registry/README.md b/doc/container_registry/README.md index b31870df36d..b98d1b51999 100644 --- a/doc/container_registry/README.md +++ b/doc/container_registry/README.md @@ -1,5 +1,5 @@ --- -redirect_to: '../user/project/container_registry.md' +redirect_to: '../user/packages/container_registry/index.md' --- -This document was moved to [another location](../user/project/container_registry.md). +This document was moved to [another location](../user/packages/container_registry/index.md). diff --git a/doc/container_registry/troubleshooting.md b/doc/container_registry/troubleshooting.md index c99d7011ac2..092d7831e35 100644 --- a/doc/container_registry/troubleshooting.md +++ b/doc/container_registry/troubleshooting.md @@ -1,5 +1,5 @@ --- -redirect_to: '../user/project/container_registry.md' +redirect_to: '../user/packages/container_registry/index.md#troubleshooting-the-gitlab-container-registry' --- -This document was moved to [user/project/container_registry](../user/project/container_registry.md). +This document was moved to [user/project/container_registry](../user/packages/container_registry/index.md#troubleshooting-the-gitlab-container-registry). diff --git a/doc/development/architecture.md b/doc/development/architecture.md index 1a970549cbd..e30b9d27f46 100644 --- a/doc/development/architecture.md +++ b/doc/development/architecture.md @@ -134,7 +134,7 @@ Component statuses are linked to configuration documentation for each component. | [GitLab Workhorse](#gitlab-workhorse) | Smart reverse proxy, handles large HTTP requests | [✅][workhorse-omnibus] | [✅][workhorse-charts] | [✅][workhorse-charts] | [✅](https://about.gitlab.com/handbook/engineering/infrastructure/production-architecture/#service-architecture) | [⚙][workhorse-source] | ✅ | CE & EE | | [GitLab Shell](#gitlab-shell) | Handles `git` over SSH sessions | [✅][shell-omnibus] | [✅][shell-charts] | [✅][shell-charts] | [✅](https://about.gitlab.com/handbook/engineering/infrastructure/production-architecture/#service-architecture) | [⚙][shell-source] | [✅][gitlab-yml] | CE & EE | | [GitLab Pages](#gitlab-pages) | Hosts static websites | [⚙][pages-omnibus] | [❌][pages-charts] | [❌][pages-charts] | [✅](../user/gitlab_com/index.md#gitlab-pages) | [⚙][pages-source] | [⚙][pages-gdk] | CE & EE | -| [Registry](#registry) | Container registry, allows pushing and pulling of images | [⚙][registry-omnibus] | [✅][registry-charts] | [✅][registry-charts] | [✅](../user/project/container_registry.md#build-and-push-images) | [⤓][registry-source] | [⚙][registry-gdk] | CE & EE | +| [Registry](#registry) | Container registry, allows pushing and pulling of images | [⚙][registry-omnibus] | [✅][registry-charts] | [✅][registry-charts] | [✅](../user/packages/container_registry/index.md#build-and-push-images) | [⤓][registry-source] | [⚙][registry-gdk] | CE & EE | | [Redis](#redis) | Caching service | [✅][redis-omnibus] | [✅][redis-omnibus] | [✅][redis-charts] | [✅](https://about.gitlab.com/handbook/engineering/infrastructure/production-architecture/#service-architecture) | [⤓][redis-source] | ✅ | CE & EE | | [PostgreSQL](#postgresql) | Database | [✅][postgres-omnibus] | [✅][postgres-charts] | [✅][postgres-charts] | [✅](../user/gitlab_com/index.md#postgresql) | [⤓][postgres-source] | ✅ | CE & EE | | [PgBouncer](#pgbouncer) | Database connection pooling, failover | [⚙][pgbouncer-omnibus] | [❌][pgbouncer-charts] | [❌][pgbouncer-charts] | [✅](https://about.gitlab.com/handbook/engineering/infrastructure/production-architecture/#database-architecture) | ❌ | ❌ | EE Only | @@ -654,9 +654,9 @@ We've also detailed [our architecture of GitLab.com](https://about.gitlab.com/ha [pages-charts]: https://gitlab.com/gitlab-org/charts/gitlab/issues/37 [pages-source]: ../install/installation.md#install-gitlab-pages [pages-gdk]: https://gitlab.com/gitlab-org/gitlab-development-kit/blob/master/doc/howto/pages.md -[registry-omnibus]: ../administration/container_registry.md#container-registry-domain-configuration +[registry-omnibus]: ../administration/packages/container_registry.md#container-registry-domain-configuration [registry-charts]: https://docs.gitlab.com/charts/charts/registry/ -[registry-source]: ../administration/container_registry.md#enable-the-container-registry +[registry-source]: ../administration/packages/container_registry.md#enable-the-container-registry [registry-gdk]: https://gitlab.com/gitlab-org/gitlab-development-kit/blob/master/doc/howto/registry.md [redis-omnibus]: https://docs.gitlab.com/omnibus/settings/redis.html [redis-charts]: https://docs.gitlab.com/charts/charts/redis/ diff --git a/doc/development/packages.md b/doc/development/packages.md index 08aa0b08525..3d209c4a93c 100644 --- a/doc/development/packages.md +++ b/doc/development/packages.md @@ -1,8 +1,8 @@ # Packages **(PREMIUM)** -This document will guide you through adding another [package management system](../administration/packages.md) support to GitLab. +This document will guide you through adding another [package management system](../administration/packages/index.md) support to GitLab. -See already supported package types in [Packages documentation](../administration/packages.md) +See already supported package types in [Packages documentation](../administration/packages/index.md) Since GitLab packages' UI is pretty generic, it is possible to add new package system support by solely backend changes. This guide is superficial and does @@ -46,7 +46,7 @@ Group-level and instance-level endpoints are good to have but are optional. NOTE: **Note:** To avoid name conflict for instance-level endpoints we use -[the package naming convention](../user/project/packages/npm_registry.md#package-naming-convention) +[the package naming convention](../user/packages/npm_registry/index.md#package-naming-convention) ## Configuration diff --git a/doc/install/aws/index.md b/doc/install/aws/index.md index ddf2b2fb738..e47f1cb640e 100644 --- a/doc/install/aws/index.md +++ b/doc/install/aws/index.md @@ -540,7 +540,7 @@ which would otherwise take much space. In particular, you can store in S3: - [The Git LFS objects](../../workflow/lfs/lfs_administration.md#s3-for-omnibus-installations) ((Omnibus GitLab installations)) -- [The Container Registry images](../../administration/container_registry.md#container-registry-storage-driver) (Omnibus GitLab installations) +- [The Container Registry images](../../administration/packages/container_registry.md#container-registry-storage-driver) (Omnibus GitLab installations) - [The GitLab CI/CD job artifacts](../../administration/job_artifacts.md#using-object-storage) (Omnibus GitLab installations) ### Setting up a domain name diff --git a/doc/install/google_cloud_platform/index.md b/doc/install/google_cloud_platform/index.md index be29bcc7cd7..56e5ecb3a58 100644 --- a/doc/install/google_cloud_platform/index.md +++ b/doc/install/google_cloud_platform/index.md @@ -130,7 +130,7 @@ Kerberos, etc. Here are some documents you might be interested in reading: - [Omnibus GitLab documentation](https://docs.gitlab.com/omnibus/) - [Integration documentation](../../integration/README.md) - [GitLab Pages configuration](../../administration/pages/index.md) -- [GitLab Container Registry configuration](../../administration/container_registry.md) +- [GitLab Container Registry configuration](../../administration/packages/container_registry.md) [freetrial]: https://console.cloud.google.com/freetrial "GCP free trial" [ip]: https://cloud.google.com/compute/docs/configure-instance-ip-addresses#promote_ephemeral_ip "Configuring an Instance's IP Addresses" diff --git a/doc/raketasks/backup_restore.md b/doc/raketasks/backup_restore.md index c230bb413f2..bc9e429c431 100644 --- a/doc/raketasks/backup_restore.md +++ b/doc/raketasks/backup_restore.md @@ -992,7 +992,7 @@ and the lost data can be manually replaced. ### Container Registry push failures after restoring from a backup -If you use the [Container Registry](../user/project/container_registry.md), you +If you use the [Container Registry](../user/packages/container_registry/index.md), you may see pushes to the registry fail after restoring your backup on an Omnibus GitLab instance after restoring the registry data. diff --git a/doc/topics/autodevops/index.md b/doc/topics/autodevops/index.md index 3ced926a530..ebeb5270884 100644 --- a/doc/topics/autodevops/index.md +++ b/doc/topics/autodevops/index.md @@ -752,14 +752,14 @@ In projects: 1. Activate the experimental `Dockerfile` syntax by adding the following to the top of the file: - ```Dockerfile + ```docker # syntax = docker/dockerfile:experimental ``` 1. To make secrets available in any `RUN $COMMAND` in the `Dockerfile`, mount the secret file and source it prior to running `$COMMAND`: - ```Dockerfile + ```docker RUN --mount=type=secret,id=auto-devops-build-secrets . /run/secrets/auto-devops-build-secrets && $COMMAND ``` @@ -1263,7 +1263,7 @@ curl --data "value=true" --header "PRIVATE-TOKEN: personal_access_token" https:/ [kubernetes-clusters]: ../../user/project/clusters/index.md [docker-in-docker]: ../../docker/using_docker_build.md#use-docker-in-docker-executor [review-app]: ../../ci/review_apps/index.md -[container-registry]: ../../user/project/container_registry.md +[container-registry]: ../../user/packages/container_registry/index.md [postgresql]: https://www.postgresql.org/ [Auto DevOps template]: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/templates/Auto-DevOps.gitlab-ci.yml [ee]: https://about.gitlab.com/pricing/ diff --git a/doc/topics/autodevops/quick_start_guide.md b/doc/topics/autodevops/quick_start_guide.md index 35a5aff6a60..d0ff149cf31 100644 --- a/doc/topics/autodevops/quick_start_guide.md +++ b/doc/topics/autodevops/quick_start_guide.md @@ -152,7 +152,7 @@ The pipeline is split into 4 stages, each running a couple of jobs. ![Pipeline stages](img/guide_pipeline_stages.png) In the **build** stage, the application is built into a Docker image and then -uploaded to your project's [Container Registry](../../user/project/container_registry.md) ([Auto Build](index.md#auto-build)). +uploaded to your project's [Container Registry](../../user/packages/container_registry/index.md) ([Auto Build](index.md#auto-build)). In the **test** stage, GitLab runs various checks on the application: diff --git a/doc/user/application_security/container_scanning/index.md b/doc/user/application_security/container_scanning/index.md index cb802612b56..7c24edb8558 100644 --- a/doc/user/application_security/container_scanning/index.md +++ b/doc/user/application_security/container_scanning/index.md @@ -48,7 +48,7 @@ To enable Container Scanning in your pipeline, you need: running. If you're using the shared Runners on GitLab.com, this is already the case. - To [build and push](../../../ci/docker/using_docker_build.md#container-registry-examples) - your Docker image to your project's [Container Registry](../../project/container_registry.md). + your Docker image to your project's [Container Registry](../../packages/container_registry/index.md). The name of the Docker image should match the following scheme: ```text @@ -79,7 +79,7 @@ The included template will: 1. Create a `container_scanning` job in your CI/CD pipeline. 1. Pull the already built Docker image from your project's - [Container Registry](../../project/container_registry.md) (see [requirements](#requirements)) + [Container Registry](../../packages/container_registry/index.md) (see [requirements](#requirements)) and scan it for possible vulnerabilities. The results will be saved as a diff --git a/doc/user/group/dependency_proxy/index.md b/doc/user/group/dependency_proxy/index.md index 771468fbba8..f735ec0214f 100644 --- a/doc/user/group/dependency_proxy/index.md +++ b/doc/user/group/dependency_proxy/index.md @@ -1,74 +1,5 @@ -# Dependency Proxy **(PREMIUM)** +--- +redirect_to: '../../packages/dependency_proxy/index.md' +--- -> [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/issues/7934) in [GitLab Premium](https://about.gitlab.com/pricing/) 11.11. - -NOTE: **Note:** -This is the user guide. In order to use the dependency proxy, an administrator -must first [configure it](../../../administration/dependency_proxy.md). - -For many organizations, it is desirable to have a local proxy for frequently used -upstream images/packages. In the case of CI/CD, the proxy is responsible for -receiving a request and returning the upstream image from a registry, acting -as a pull-through cache. - -The dependency proxy is available in the group level. To access it, navigate to -a group's **Overview > Dependency Proxy**. - -![Dependency Proxy group page](img/group_dependency_proxy.png) - -## Supported dependency proxies - -NOTE: **Note:** -For a list of the upcoming additions to the proxies, visit the -[direction page](https://about.gitlab.com/direction/package/dependency_proxy/#top-vision-items). - -The following dependency proxies are supported. - -| Dependency proxy | GitLab version | -| ---------------- | -------------- | -| Docker | 11.11+ | - -## Using the Docker dependency proxy - -With the Docker dependency proxy, you can use GitLab as a source for a Docker image. -To get a Docker image into the dependency proxy: - -1. Find the proxy URL on your group's page under **Overview > Dependency Proxy**, - for example `gitlab.com/groupname/dependency_proxy/containers`. -1. Trigger GitLab to pull the Docker image you want (e.g., `alpine:latest` or - `linuxserver/nextcloud:latest`) and store it in the proxy storage by using - one of the following ways: - - - Manually pulling the Docker image: - - ```bash - docker pull gitlab.com/groupname/dependency_proxy/containers/alpine:latest - ``` - - - From a `Dockerfile`: - - ```bash - FROM gitlab.com/groupname/dependency_proxy/containers/alpine:latest - ``` - - - In [`.gitlab-ci.yml`](../../../ci/yaml/README.md#image): - - ```bash - image: gitlab.com/groupname/dependency_proxy/containers/alpine:latest - ``` - -GitLab will then pull the Docker image from Docker Hub and will cache the blobs -on the GitLab server. The next time you pull the same image, it will get the latest -information about the image from Docker Hub but will serve the existing blobs -from GitLab. - -The blobs are kept forever, and there is no hard limit on how much data can be -stored. - -## Limitations - -The following limitations apply: - -- Only public groups are supported (authentication is not supported yet). -- Only Docker Hub is supported. -- This feature requires Docker Hub being available. +This document was moved to [another location](../../packages/dependency_proxy/index.md). diff --git a/doc/user/group/index.md b/doc/user/group/index.md index c09acd36e31..a0bdb737466 100644 --- a/doc/user/group/index.md +++ b/doc/user/group/index.md @@ -285,7 +285,7 @@ To change your group path: CAUTION: **Caution:** It is currently not possible to rename a namespace if it contains a -project with [Container Registry](../project/container_registry.md) tags, +project with [Container Registry](../packages/container_registry/index.md) tags, because the project cannot be moved. TIP: **TIP:** @@ -461,7 +461,7 @@ With [GitLab Issues Analytics](issues_analytics/index.md), you can see a bar cha ## Dependency Proxy **(PREMIUM)** -Use GitLab as a [dependency proxy](dependency_proxy/index.md) for upstream Docker images. +Use GitLab as a [dependency proxy](../packages/dependency_proxy/index.md) for upstream Docker images. <!-- ## Troubleshooting diff --git a/doc/user/index.md b/doc/user/index.md index 27e75189fc3..e1833cab6b8 100644 --- a/doc/user/index.md +++ b/doc/user/index.md @@ -44,7 +44,7 @@ GitLab is a Git-based platform that integrates a great number of essential tools branch with [Review Apps](../ci/review_apps/index.md). - Building, testing, and deploying with built-in [Continuous Integration](../ci/README.md). - Deploying personal and professional static websites with [GitLab Pages](project/pages/index.md). -- Integrating with Docker by using [GitLab Container Registry](project/container_registry.md). +- Integrating with Docker by using [GitLab Container Registry](packages/container_registry/index.md). - Tracking the development lifecycle by using [GitLab Cycle Analytics](project/cycle_analytics.md). With GitLab Enterprise Edition, you can also: @@ -92,7 +92,7 @@ directly from GitLab. No third-party integrations needed. - [Review Apps](../ci/review_apps/index.md): Live-preview the changes introduced by a merge request with Review Apps. - [GitLab Pages](project/pages/index.md): Publish your static site directly from GitLab with GitLab Pages. You can build, test, and deploy any Static Site Generator with Pages. -- [GitLab Container Registry](project/container_registry.md): Build and deploy Docker +- [GitLab Container Registry](packages/container_registry/index.md): Build and deploy Docker images with Container Registry. ## Account diff --git a/doc/user/packages/container_registry/index.md b/doc/user/packages/container_registry/index.md new file mode 100644 index 00000000000..710e7bd405b --- /dev/null +++ b/doc/user/packages/container_registry/index.md @@ -0,0 +1,158 @@ +# GitLab Container Registry + +> - [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4040) in GitLab 8.8. +> - Docker Registry manifest `v1` support was added in GitLab 8.9 to support Docker +> versions earlier than 1.10. +> - Starting from GitLab 8.12, if you have 2FA enabled in your account, you need +> to pass a [personal access token](../../profile/personal_access_tokens.md) instead of your password in order to +> login to GitLab's Container Registry. +> - Multiple level image names support was added in GitLab 9.1. + +NOTE: **Note:** +This document is the user guide. To learn how to enable GitLab Container +Registry across your GitLab instance, visit the +[administrator documentation](../../../administration/packages/container_registry.md). + +With the Docker Container Registry integrated into GitLab, every project can +have its own space to store its Docker images. + +You can read more about Docker Registry at <https://docs.docker.com/registry/introduction/>. + +## Enable the Container Registry for your project + +If you cannot find the **Packages > Container Registry** entry under your +project's sidebar, it is not enabled in your GitLab instance. Ask your +administrator to enable GitLab Container Registry following the +[administration documentation](../../../administration/packages/container_registry.md). + +If you are using GitLab.com, this is enabled by default so you can start using +the Registry immediately. Currently there is a soft (10GB) size restriction for +Registry on GitLab.com, as part of the [repository size limit](../../project/repository/index.md). + +Once enabled for your GitLab instance, to enable Container Registry for your +project: + +1. Go to your project's **Settings > General** page. +1. Expand the **Visibility, project features, permissions** section + and enable the **Container Registry** feature on your project. For new + projects this might be enabled by default. For existing projects + (prior GitLab 8.8), you will have to explicitly enable it. +1. Press **Save changes** for the changes to take effect. You should now be able + to see the **Packages > Container Registry** link in the sidebar. + +## Build and push images + +> **Notes:** +> +> - Moving or renaming existing container registry repositories is not supported +> once you have pushed images because the images are signed, and the +> signature includes the repository name. +> - To move or rename a repository with a container registry you will have to +> delete all existing images. + +If you visit the **Packages > Container Registry** link under your project's +menu, you can see the explicit instructions to login to the Container Registry +using your GitLab credentials. + +For example if the Registry's URL is `registry.example.com`, then you should be +able to login with: + +```sh +docker login registry.example.com +``` + +Building and publishing images should be a straightforward process. Just make +sure that you are using the Registry URL with the namespace and project name +that is hosted on GitLab: + +```sh +docker build -t registry.example.com/group/project/image . +docker push registry.example.com/group/project/image +``` + +Your image will be named after the following scheme: + +```text +<registry URL>/<namespace>/<project>/<image> +``` + +GitLab supports up to three levels of image repository names. + +Following examples of image tags are valid: + +```text +registry.example.com/group/project:some-tag +registry.example.com/group/project/image:latest +registry.example.com/group/project/my/image:rc1 +``` + +## Use images from GitLab Container Registry + +To download and run a container from images hosted in GitLab Container Registry, +use `docker run`: + +```sh +docker run [options] registry.example.com/group/project/image [arguments] +``` + +For more information on running Docker containers, visit the +[Docker documentation](https://docs.docker.com/engine/userguide/intro/). + +## Control Container Registry from within GitLab + +GitLab offers a simple Container Registry management panel. Go to your project +and click **Packages > Container Registry** in the project menu. + +This view will show you all tags in your project and will easily allow you to +delete them. + +## Build and push images using GitLab CI + +NOTE: **Note:** +This feature requires GitLab 8.8 and GitLab Runner 1.2. + +Make sure that your GitLab Runner is configured to allow building Docker images by +following the [Using Docker Build](../../../ci/docker/using_docker_build.md) +and [Using the GitLab Container Registry documentation](../../../ci/docker/using_docker_build.md#using-the-gitlab-container-registry). +Alternatively, you can [build images with Kaniko](../../../ci/docker/using_kaniko.md) if the Docker builds are not an option for you. + +## Using with private projects + +> Personal Access tokens were [introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/11845) in GitLab 9.3. +> Project Deploy Tokens were [introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/17894) in GitLab 10.7 + +If a project is private, credentials will need to be provided for authorization. +There are two ways to do this: + +- By using a [personal access token](../../profile/personal_access_tokens.md). +- By using a [deploy token](../../project/deploy_tokens/index.md). + +The minimal scope needed for both of them is `read_registry`. + +Example of using a token: + +```sh +docker login registry.example.com -u <username> -p <token> +``` + +## Troubleshooting the GitLab Container Registry + +### Docker connection error + +A Docker connection error can occur when there are special characters in either the group, +project or branch name. Special characters can include: + +- Leading underscore +- Trailing hyphen/dash +- Double hyphen/dash + +To get around this, you can [change the group path](../../group/index.md#changing-a-groups-path), +[change the project path](../../project/settings/index.md#renaming-a-repository) or change the branch +name. + +### Troubleshoot as a GitLab server admin + +Troubleshooting the GitLab Container Registry, most of the times, requires +administration access to the GitLab server. + +[Read how to troubleshoot the Container Registry](../../../administration/packages/container_registry.md#troubleshooting). diff --git a/doc/user/packages/dependency_proxy/img/group_dependency_proxy.png b/doc/user/packages/dependency_proxy/img/group_dependency_proxy.png Binary files differnew file mode 100644 index 00000000000..035aff0b6c4 --- /dev/null +++ b/doc/user/packages/dependency_proxy/img/group_dependency_proxy.png diff --git a/doc/user/packages/dependency_proxy/index.md b/doc/user/packages/dependency_proxy/index.md new file mode 100644 index 00000000000..8c337f74dcf --- /dev/null +++ b/doc/user/packages/dependency_proxy/index.md @@ -0,0 +1,74 @@ +# Dependency Proxy **(PREMIUM)** + +> [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/issues/7934) in [GitLab Premium](https://about.gitlab.com/pricing/) 11.11. + +NOTE: **Note:** +This is the user guide. In order to use the dependency proxy, an administrator +must first [configure it](../../../administration/packages/dependency_proxy.md). + +For many organizations, it is desirable to have a local proxy for frequently used +upstream images/packages. In the case of CI/CD, the proxy is responsible for +receiving a request and returning the upstream image from a registry, acting +as a pull-through cache. + +The dependency proxy is available in the group level. To access it, navigate to +a group's **Overview > Dependency Proxy**. + +![Dependency Proxy group page](img/group_dependency_proxy.png) + +## Supported dependency proxies + +NOTE: **Note:** +For a list of the upcoming additions to the proxies, visit the +[direction page](https://about.gitlab.com/direction/package/dependency_proxy/#top-vision-items). + +The following dependency proxies are supported. + +| Dependency proxy | GitLab version | +| ---------------- | -------------- | +| Docker | 11.11+ | + +## Using the Docker dependency proxy + +With the Docker dependency proxy, you can use GitLab as a source for a Docker image. +To get a Docker image into the dependency proxy: + +1. Find the proxy URL on your group's page under **Overview > Dependency Proxy**, + for example `gitlab.com/groupname/dependency_proxy/containers`. +1. Trigger GitLab to pull the Docker image you want (e.g., `alpine:latest` or + `linuxserver/nextcloud:latest`) and store it in the proxy storage by using + one of the following ways: + + - Manually pulling the Docker image: + + ```bash + docker pull gitlab.com/groupname/dependency_proxy/containers/alpine:latest + ``` + + - From a `Dockerfile`: + + ```bash + FROM gitlab.com/groupname/dependency_proxy/containers/alpine:latest + ``` + + - In [`.gitlab-ci.yml`](../../../ci/yaml/README.md#image): + + ```bash + image: gitlab.com/groupname/dependency_proxy/containers/alpine:latest + ``` + +GitLab will then pull the Docker image from Docker Hub and will cache the blobs +on the GitLab server. The next time you pull the same image, it will get the latest +information about the image from Docker Hub but will serve the existing blobs +from GitLab. + +The blobs are kept forever, and there is no hard limit on how much data can be +stored. + +## Limitations + +The following limitations apply: + +- Only public groups are supported (authentication is not supported yet). +- Only Docker Hub is supported. +- This feature requires Docker Hub being available. diff --git a/doc/user/packages/index.md b/doc/user/packages/index.md new file mode 100644 index 00000000000..506eb5703a6 --- /dev/null +++ b/doc/user/packages/index.md @@ -0,0 +1,19 @@ +# GitLab Package Registry + +GitLab Packages allows organizations to utilize GitLab as a private repository +for a variety of common package managers. Users are able to build and publish +packages, which can be easily consumed as a dependency in downstream projects. + +The Packages feature allows GitLab to act as a repository for the following: + +| Software repository | Description | Available in GitLab version | +| ------------------- | ----------- | --------------------------- | +| [Container Registry](container_registry/index.md) | The GitLab Container Registry enables every project in GitLab to have its own space to store [Docker](https://www.docker.com/) images. | 8.8+ | +| [Dependency Proxy](dependency_proxy/index.md) **(PREMIUM)** | The GitLab Dependency Proxy sets up a local proxy for frequently used upstream images/packages. | 11.11+ | +| [Maven Repository](maven_repository/index.md) **(PREMIUM)** | The GitLab Maven Repository enables every project in GitLab to have its own space to store [Maven](https://maven.apache.org/) packages. | 11.3+ | +| [NPM Registry](npm_registry/index.md) **(PREMIUM)** | The GitLab NPM Registry enables every project in GitLab to have its own space to store [NPM](https://www.npmjs.com/) packages. | 11.7+ | + +TIP: **Tip:** +Don't you see your package management system supported yet? Consider contributing +to GitLab. This [development documentation](../../development/packages.md) will +guide you through the process. diff --git a/doc/user/packages/maven_repository/img/maven_package_view.png b/doc/user/packages/maven_repository/img/maven_package_view.png Binary files differnew file mode 100644 index 00000000000..2eb4b6f76b4 --- /dev/null +++ b/doc/user/packages/maven_repository/img/maven_package_view.png diff --git a/doc/user/packages/maven_repository/index.md b/doc/user/packages/maven_repository/index.md new file mode 100644 index 00000000000..2c400653fcc --- /dev/null +++ b/doc/user/packages/maven_repository/index.md @@ -0,0 +1,340 @@ +# GitLab Maven Repository **(PREMIUM)** + +> [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/issues/5811) in [GitLab Premium](https://about.gitlab.com/pricing/) 11.3. + +With the GitLab [Maven](https://maven.apache.org) Repository, every +project can have its own space to store its Maven artifacts. + +![GitLab Maven Repository](img/maven_package_view.png) + +## Enabling the Maven Repository + +NOTE: **Note:** +This option is available only if your GitLab administrator has +[enabled support for the Maven repository](../../../administration/packages/index.md).**(PREMIUM ONLY)** + +After the Packages feature is enabled, the Maven Repository will be available for +all new projects by default. To enable it for existing projects, or if you want +to disable it: + +1. Navigate to your project's **Settings > General > Permissions**. +1. Find the Packages feature and enable or disable it. +1. Click on **Save changes** for the changes to take effect. + +You should then be able to see the **Packages** section on the left sidebar. +Next, you must configure your project to authorize with the GitLab Maven +repository. + +## Authenticating to the GitLab Maven Repository + +If a project is private or you want to upload Maven artifacts to GitLab, +credentials will need to be provided for authorization. Support is available for +[personal access tokens](#authenticating-with-a-personal-access-token) and +[CI job tokens](#authenticating-with-a-ci-job-token) only. +[Deploy tokens](../../project/deploy_tokens/index.md) and regular username/password +credentials do not work. + +### Authenticating with a personal access token + +To authenticate with a [personal access token](../../profile/personal_access_tokens.md), +add a corresponding section to your +[`settings.xml`](https://maven.apache.org/settings.html) file: + +```xml +<settings> + <servers> + <server> + <id>gitlab-maven</id> + <configuration> + <httpHeaders> + <property> + <name>Private-Token</name> + <value>REPLACE_WITH_YOUR_PERSONAL_ACCESS_TOKEN</value> + </property> + </httpHeaders> + </configuration> + </server> + </servers> +</settings> +``` + +You should now be able to upload Maven artifacts to your project. + +### Authenticating with a CI job token + +If you're using Maven with GitLab CI/CD, a CI job token can be used instead +of a personal access token. + +To authenticate with a CI job token, add a corresponding section to your +[`settings.xml`](https://maven.apache.org/settings.html) file: + +```xml +<settings> + <servers> + <server> + <id>gitlab-maven</id> + <configuration> + <httpHeaders> + <property> + <name>Job-Token</name> + <value>${env.CI_JOB_TOKEN}</value> + </property> + </httpHeaders> + </configuration> + </server> + </servers> +</settings> +``` + +You can read more on +[how to create Maven packages using GitLab CI/CD](#creating-maven-packages-with-gitlab-cicd). + +## Configuring your project to use the GitLab Maven repository URL + +To download and upload packages from GitLab, you need a `repository` and +`distributionManagement` section in your `pom.xml` file. + +Depending on your workflow and the amount of Maven packages you have, there are +3 ways you can configure your project to use the GitLab endpoint for Maven packages: + +- **Project level**: Useful when you have few Maven packages which are not under + the same GitLab group. +- **Group level**: Useful when you have many Maven packages under the same GitLab + group. +- **Instance level**: Useful when you have many Maven packages under different + GitLab groups or on their own namespace. + +NOTE: **Note:** +In all cases, you need a project specific URL for uploading a package in +the `distributionManagement` section. + +### Project level Maven endpoint + +The example below shows how the relevant `repository` section of your `pom.xml` +would look like: + +```xml +<repositories> + <repository> + <id>gitlab-maven</id> + <url>https://gitlab.com/api/v4/projects/PROJECT_ID/packages/maven</url> + </repository> +</repositories> +<distributionManagement> + <repository> + <id>gitlab-maven</id> + <url>https://gitlab.com/api/v4/projects/PROJECT_ID/packages/maven</url> + </repository> + <snapshotRepository> + <id>gitlab-maven</id> + <url>https://gitlab.com/api/v4/projects/PROJECT_ID/packages/maven</url> + </snapshotRepository> +</distributionManagement> +``` + +The `id` must be the same with what you +[defined in `settings.xml`](#authenticating-to-the-gitlab-maven-repository). + +Replace `PROJECT_ID` with your project ID which can be found on the home page +of your project. + +If you have a self-hosted GitLab installation, replace `gitlab.com` with your +domain name. + +NOTE: **Note:** +For retrieving artifacts, you can use either the +[URL encoded](../../../api/README.md#namespaced-path-encoding) path of the project +(e.g., `group%2Fproject`) or the project's ID (e.g., `42`). However, only the +project's ID can be used for uploading. + +### Group level Maven endpoint + +> [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/8798) in GitLab Premium 11.7. + +If you rely on many packages, it might be inefficient to include the `repository` section +with a unique URL for each package. Instead, you can use the group level endpoint for +all your Maven packages stored within one GitLab group. Only packages you have access to +will be available for download. + +The group level endpoint works with any package names, which means the you +have the flexibility of naming compared to [instance level endpoint](#instance-level-maven-endpoint). +However, GitLab will not guarantee the uniqueness of the package names within +the group. You can have two projects with the same package name and package +version. As a result, GitLab will serve whichever one is more recent. + +The example below shows how the relevant `repository` section of your `pom.xml` +would look like. You still need a project specific URL for uploading a package in +the `distributionManagement` section: + +```xml +<repositories> + <repository> + <id>gitlab-maven</id> + <url>https://gitlab.com/api/v4/groups/my-group/-/packages/maven</url> + </repository> +</repositories> +<distributionManagement> + <repository> + <id>gitlab-maven</id> + <url>https://gitlab.com/api/v4/projects/PROJECT_ID/packages/maven</url> + </repository> + <snapshotRepository> + <id>gitlab-maven</id> + <url>https://gitlab.com/api/v4/projects/PROJECT_ID/packages/maven</url> + </snapshotRepository> +</distributionManagement> +``` + +The `id` must be the same with what you +[defined in `settings.xml`](#authenticating-to-the-gitlab-maven-repository). + +Replace `my-group` with your group name and `PROJECT_ID` with your project ID +which can be found on the home page of your project. + +If you have a self-hosted GitLab installation, replace `gitlab.com` with your +domain name. + +NOTE: **Note:** +For retrieving artifacts, you can use either the +[URL encoded](../../../api/README.md#namespaced-path-encoding) path of the group +(e.g., `group%2Fsubgroup`) or the group's ID (e.g., `12`). + +### Instance level Maven endpoint + +> [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/8274) in GitLab Premium 11.7. + +If you rely on many packages, it might be inefficient to include the `repository` section +with a unique URL for each package. Instead, you can use the instance level endpoint for +all maven packages stored in GitLab and the packages you have access to will be available +for download. + +Note that **only packages that have the same path as the project** are exposed via +the instance level endpoint. + +| Project | Package | Instance level endpoint available | +| ------- | ------- | --------------------------------- | +| `foo/bar` | `foo/bar/1.0-SNAPSHOT` | Yes | +| `gitlab-org/gitlab-ce` | `foo/bar/1.0-SNAPSHOT` | No | +| `gitlab-org/gitlab-ce` | `gitlab-org/gitlab-ce/1.0-SNAPSHOT` | Yes | + +The example below shows how the relevant `repository` section of your `pom.xml` +would look like. You still need a project specific URL for uploading a package in +the `distributionManagement` section: + +```xml +<repositories> + <repository> + <id>gitlab-maven</id> + <url>https://gitlab.com/api/v4/packages/maven</url> + </repository> +</repositories> +<distributionManagement> + <repository> + <id>gitlab-maven</id> + <url>https://gitlab.com/api/v4/projects/PROJECT_ID/packages/maven</url> + </repository> + <snapshotRepository> + <id>gitlab-maven</id> + <url>https://gitlab.com/api/v4/projects/PROJECT_ID/packages/maven</url> + </snapshotRepository> +</distributionManagement> +``` + +The `id` must be the same with what you +[defined in `settings.xml`](#authenticating-to-the-gitlab-maven-repository). + +Replace `PROJECT_ID` with your project ID which can be found on the home page +of your project. + +If you have a self-hosted GitLab installation, replace `gitlab.com` with your +domain name. + +NOTE: **Note:** +For retrieving artifacts, you can use either the +[URL encoded](../../../api/README.md#namespaced-path-encoding) path of the project +(e.g., `group%2Fproject`) or the project's ID (e.g., `42`). However, only the +project's ID can be used for uploading. + +## Uploading packages + +Once you have set up the [authentication](#authenticating-to-the-gitlab-maven-repository) +and [configuration](#configuring-your-project-to-use-the-gitlab-maven-repository-url), +test to upload a Maven artifact from a project of yours: + +```sh +mvn deploy +``` + +You can then navigate to your project's **Packages** page and see the uploaded +artifacts or even delete them. + +## Creating Maven packages with GitLab CI/CD + +Once you have your repository configured to use the GitLab Maven Repository, +you can configure GitLab CI/CD to build new packages automatically. The example below +shows how to create a new package each time the `master` branch is updated: + +1. Create a `ci_settings.xml` file that will serve as Maven's `settings.xml` file. + Add the server section with the same id you defined in your `pom.xml` file. + For example, in our case it's `gitlab-maven`: + + ```xml + <settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"> + <servers> + <server> + <id>gitlab-maven</id> + <configuration> + <httpHeaders> + <property> + <name>Job-Token</name> + <value>${env.CI_JOB_TOKEN}</value> + </property> + </httpHeaders> + </configuration> + </server> + </servers> + </settings> + ``` + +1. Make sure your `pom.xml` file includes the following: + + ```xml + <repositories> + <repository> + <id>gitlab-maven</id> + <url>https://gitlab.com/api/v4/projects/${env.CI_PROJECT_ID}/packages/maven</url> + </repository> + </repositories> + <distributionManagement> + <repository> + <id>gitlab-maven</id> + <url>https://gitlab.com/api/v4/projects/${env.CI_PROJECT_ID}/packages/maven</url> + </repository> + <snapshotRepository> + <id>gitlab-maven</id> + <url>https://gitlab.com/api/v4/projects/${env.CI_PROJECT_ID}/packages/maven</url> + </snapshotRepository> + </distributionManagement> + ``` + + TIP: **Tip:** + You can either let Maven utilize the CI environment variables or hardcode your project's ID. + +1. Add a `deploy` job to your `.gitlab-ci.yml` file: + + ```yaml + deploy: + image: maven:3.3.9-jdk-8 + script: + - 'mvn deploy -s ci_settings.xml' + only: + - master + ``` + +1. Push those files to your repository. + +The next time the `deploy` job runs, it will copy `ci_settings.xml` to the +user's home location (in this case the user is `root` since it runs in a +Docker container), and Maven will utilize the configured CI +[environment variables](../../../ci/variables/README.md#predefined-environment-variables). diff --git a/doc/user/packages/npm_registry/img/npm_package_view.png b/doc/user/packages/npm_registry/img/npm_package_view.png Binary files differnew file mode 100644 index 00000000000..e0634718c02 --- /dev/null +++ b/doc/user/packages/npm_registry/img/npm_package_view.png diff --git a/doc/user/packages/npm_registry/index.md b/doc/user/packages/npm_registry/index.md new file mode 100644 index 00000000000..30de301b96a --- /dev/null +++ b/doc/user/packages/npm_registry/index.md @@ -0,0 +1,147 @@ +# GitLab NPM Registry **(PREMIUM)** + +> [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/issues/5934) in [GitLab Premium](https://about.gitlab.com/pricing/) 11.7. + +With the GitLab NPM Registry, every +project can have its own space to store NPM packages. + +![GitLab NPM Registry](img/npm_package_view.png) + +NOTE: **Note:** +Only [scoped](https://docs.npmjs.com/misc/scope) packages are supported. + +## Enabling the NPM Registry + +NOTE: **Note:** +This option is available only if your GitLab administrator has +[enabled support for the NPM registry](../../../administration/packages/index.md).**(PREMIUM ONLY)** + +After the NPM registry is enabled, it will be available for all new projects +by default. To enable it for existing projects, or if you want to disable it: + +1. Navigate to your project's **Settings > General > Permissions**. +1. Find the Packages feature and enable or disable it. +1. Click on **Save changes** for the changes to take effect. + +You should then be able to see the **Packages** section on the left sidebar. + +Before proceeding to authenticating with the GitLab NPM Registry, you should +get familiar with the package naming convention. + +## Package naming convention + +**Packages must be scoped in the root namespace of the project**. The package +name may be anything but it is preferred that the project name be used unless +it is not possible due to a naming collision. For example: + +| Project | Package | Supported | +| ---------------------- | ----------------------- | --------- | +| `foo/bar` | `@foo/bar` | Yes | +| `foo/bar/baz` | `@foo/baz` | Yes | +| `foo/bar/buz` | `@foo/anything` | Yes | +| `gitlab-org/gitlab-ce` | `@gitlab-org/gitlab-ce` | Yes | +| `gitlab-org/gitlab-ce` | `@foo/bar` | No | + +Now, you can configure your project to authenticate with the GitLab NPM +Registry. + +## Authenticating to the GitLab NPM Registry + +If a project is private or you want to upload an NPM package to GitLab, +credentials will need to be provided for authentication. Support is available for [OAuth tokens](../../../api/oauth2.md#resource-owner-password-credentials-flow) or [personal access tokens](../../profile/personal_access_tokens.md). + +CAUTION: **2FA is only supported with personal access tokens:** +If you have 2FA enabled, you need to use a [personal access token](../../profile/personal_access_tokens.md) with OAuth headers. Standard OAuth tokens won't be able to authenticate to the GitLab NPM Registry. + +### Authenticating with an OAuth token + +To authenticate with an [OAuth token](../../../api/oauth2.md#resource-owner-password-credentials-flow) +or [personal access token](../../profile/personal_access_tokens.md), add a corresponding section to your `.npmrc` file: + +```ini +; Set URL for your scoped packages. +; For example package with name `@foo/bar` will use this URL for download +@foo:registry=https://gitlab.com/api/v4/packages/npm/ + +; Add the token for the scoped packages URL. This will allow you to download +; `@foo/` packages from private projects. +//gitlab.com/api/v4/packages/npm/:_authToken=<your_token> + +; Add token for uploading to the registry. Replace <your_project_id> +; with the project you want your package to be uploaded to. +//gitlab.com/api/v4/projects/<your_project_id>/packages/npm/:_authToken=<your_token> +``` + +Replace `<your_project_id>` with your project ID which can be found on the home page +of your project and `<your_token>` with your OAuth or personal access token. + +If you have a self-hosted GitLab installation, replace `gitlab.com` with your +domain name. + +You should now be able to download and upload NPM packages to your project. + +NOTE: **Note:** +If you encounter an error message with [Yarn](https://yarnpkg.com/en/), see the +[troubleshooting section](#troubleshooting). + +## Uploading packages + +Before you will be able to upload a package, you need to specify the registry +for NPM. To do this, add the following section to the bottom of `package.json`: + +```json + "publishConfig": { + "@foo:registry":"https://gitlab.com/api/v4/projects/<your_project_id>/packages/npm/" + } +``` + +Replace `<your_project_id>` with your project ID, which can be found on the home +page of your project, and replace `@foo` with your own scope. + +If you have a self-hosted GitLab installation, replace `gitlab.com` with your +domain name. + +Once you have enabled it and set up [authentication](#authenticating-to-the-gitlab-npm-registry), +you can upload an NPM package to your project: + +```sh +npm publish +``` + +You can then navigate to your project's **Packages** page and see the uploaded +packages or even delete them. + +If you attempt to publish a package with a name that already exists within +a given scope, you will receive a `403 Forbidden!` error. + +## Uploading a package with the same version twice + +If you upload a package with a same name and version twice, GitLab will show +both packages in the UI, but the GitLab NPM Registry will expose the most recent +one as it supports only one package per version for `npm install`. + +## Troubleshooting + +### Error running yarn with NPM registry + +If you are using [yarn](https://yarnpkg.com/en/) with the NPM registry, you may get +an error message like: + +```sh +yarn install v1.15.2 +warning package.json: No license field +info No lockfile found. +warning XXX: No license field +[1/4] 🔍 Resolving packages... +[2/4] 🚚 Fetching packages... +error An unexpected error occurred: "https://gitlab.com/api/v4/projects/XXX/packages/npm/XXX/XXX/-/XXX/XXX-X.X.X.tgz: Request failed \"404 Not Found\"". +info If you think this is a bug, please open a bug report with the information provided in "/Users/XXX/gitlab-migration/module-util/yarn-error.log". +info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command +``` + +In this case, try adding this to your `.npmrc` file (and replace `<your_oauth_token>` +with your with your OAuth or personal access token): + +```text +//gitlab.com/api/v4/projects/:_authToken=<your_oauth_token> +``` diff --git a/doc/user/permissions.md b/doc/user/permissions.md index 46a3090e268..8232ae44c68 100644 --- a/doc/user/permissions.md +++ b/doc/user/permissions.md @@ -76,8 +76,8 @@ The following table depicts the various user permission levels in a project. | See a list of merge requests | | ✓ | ✓ | ✓ | ✓ | | View project statistics | | ✓ | ✓ | ✓ | ✓ | | View Error Tracking list | | ✓ | ✓ | ✓ | ✓ | -| Pull from [Maven repository](project/packages/maven_repository.md) or [NPM registry](project/packages/npm_registry.md) **(PREMIUM)** | | ✓ | ✓ | ✓ | ✓ | -| Publish to [Maven repository](project/packages/maven_repository.md) or [NPM registry](project/packages/npm_registry.md) **(PREMIUM)** | | | ✓ | ✓ | ✓ | +| Pull from [Maven repository](packages/maven_repository/index.md) or [NPM registry](packages/npm_registry/index.md) **(PREMIUM)** | | ✓ | ✓ | ✓ | ✓ | +| Publish to [Maven repository](packages/maven_repository/index.md) or [NPM registry](packages/npm_registry/index.md) **(PREMIUM)** | | | ✓ | ✓ | ✓ | | Upload [Design Management](project/issues/design_management.md) files **(PREMIUM)** | | | ✓ | ✓ | ✓ | | Create new branches | | | ✓ | ✓ | ✓ | | Push to non-protected branches | | | ✓ | ✓ | ✓ | diff --git a/doc/user/profile/index.md b/doc/user/profile/index.md index 40b7294c3bb..d9144f9b5fd 100644 --- a/doc/user/profile/index.md +++ b/doc/user/profile/index.md @@ -75,7 +75,7 @@ To change your `username`: CAUTION: **Caution:** It is currently not possible to change your username if it contains a -project with [Container Registry](../project/container_registry.md) tags, +project with [Container Registry](../packages/container_registry/index.md) tags, because the project cannot be moved. TIP: **Tip:** diff --git a/doc/user/profile/personal_access_tokens.md b/doc/user/profile/personal_access_tokens.md index d556daa3460..ffe6104698f 100644 --- a/doc/user/profile/personal_access_tokens.md +++ b/doc/user/profile/personal_access_tokens.md @@ -53,7 +53,7 @@ the following table. [2fa]: ../account/two_factor_authentication.md [api]: ../../api/README.md [ce-3749]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3749 -[container registry]: ../project/container_registry.md +[container registry]: ../packages/container_registry/index.md [users]: ../../api/users.md [usage]: ../../api/README.md#personal-access-tokens diff --git a/doc/user/project/container_registry.md b/doc/user/project/container_registry.md index c9eb81b990c..91c9d3171dc 100644 --- a/doc/user/project/container_registry.md +++ b/doc/user/project/container_registry.md @@ -1,317 +1,5 @@ -# GitLab Container Registry +--- +redirect_to: '../packages/container_registry/index.md' +--- -> - [Introduced][ce-4040] in GitLab 8.8. -> - Docker Registry manifest `v1` support was added in GitLab 8.9 to support Docker -> versions earlier than 1.10. -> - Starting from GitLab 8.12, if you have 2FA enabled in your account, you need -> to pass a [personal access token][pat] instead of your password in order to -> login to GitLab's Container Registry. -> - Multiple level image names support was added in GitLab 9.1. - -With the Docker Container Registry integrated into GitLab, every project can -have its own space to store its Docker images. - -This document is the user guide. To learn how to enable GitLab Container -Registry across your GitLab instance, visit the -[administrator documentation](../../administration/container_registry.md). - -You can read more about Docker Registry at <https://docs.docker.com/registry/introduction/>. - -## Enable the Container Registry for your project - -If you cannot find the **Packages > Container Registry** entry under your -project's sidebar, it is not enabled in your GitLab instance. Ask your -administrator to enable GitLab Container Registry following the -[administration documentation](../../administration/container_registry.md). - -If you are using GitLab.com, this is enabled by default so you can start using -the Registry immediately. Currently there is a soft (10GB) size restriction for -registry on GitLab.com, as part of the [repository size limit](repository/index.md). - -Once enabled for your GitLab instance, to enable Container Registry for your -project: - -1. Go to your project's **Settings > General** page. -1. Expand the **Visibility, project features, permissions** section - and enable the **Container Registry** feature on your project. For new - projects this might be enabled by default. For existing projects - (prior GitLab 8.8), you will have to explicitly enable it. -1. Press **Save changes** for the changes to take effect. You should now be able - to see the **Packages > Container Registry** link in the sidebar. - -## Build and push images - -> **Notes:** -> -> - Moving or renaming existing container registry repositories is not supported -> once you have pushed images because the images are signed, and the -> signature includes the repository name. -> - To move or rename a repository with a container registry you will have to -> delete all existing images. - -If you visit the **Packages > Container Registry** link under your project's -menu, you can see the explicit instructions to login to the Container Registry -using your GitLab credentials. - -For example if the Registry's URL is `registry.example.com`, then you should be -able to login with: - -```sh -docker login registry.example.com -``` - -Building and publishing images should be a straightforward process. Just make -sure that you are using the Registry URL with the namespace and project name -that is hosted on GitLab: - -```sh -docker build -t registry.example.com/group/project/image . -docker push registry.example.com/group/project/image -``` - -Your image will be named after the following scheme: - -```text -<registry URL>/<namespace>/<project>/<image> -``` - -GitLab supports up to three levels of image repository names. - -Following examples of image tags are valid: - -```text -registry.example.com/group/project:some-tag -registry.example.com/group/project/image:latest -registry.example.com/group/project/my/image:rc1 -``` - -## Use images from GitLab Container Registry - -To download and run a container from images hosted in GitLab Container Registry, -use `docker run`: - -```sh -docker run [options] registry.example.com/group/project/image [arguments] -``` - -For more information on running Docker containers, visit the -[Docker documentation][docker-docs]. - -## Control Container Registry from within GitLab - -GitLab offers a simple Container Registry management panel. Go to your project -and click **Packages > Container Registry** in the project menu. - -This view will show you all tags in your project and will easily allow you to -delete them. - -## Build and push images using GitLab CI - -> **Note:** -This feature requires GitLab 8.8 and GitLab Runner 1.2. - -Make sure that your GitLab Runner is configured to allow building Docker images by -following the [Using Docker Build](../../ci/docker/using_docker_build.md) -and [Using the GitLab Container Registry documentation](../../ci/docker/using_docker_build.md#using-the-gitlab-container-registry). -Alternatively, you can [build images with Kaniko](../../ci/docker/using_kaniko.md) if the Docker builds are not an option for you. - -## Using with private projects - -> Personal Access tokens were [introduced][ce-11845] in GitLab 9.3. -> Project Deploy Tokens were [introduced][ce-17894] in GitLab 10.7 - -If a project is private, credentials will need to be provided for authorization. -There are two ways to do this: - -- By using a [personal access token](../profile/personal_access_tokens.md). -- By using a [deploy token](../project/deploy_tokens/index.md). - -The minimal scope needed for both of them is `read_registry`. - -Example of using a token: - -```sh -docker login registry.example.com -u <username> -p <token> -``` - -## Troubleshooting the GitLab Container Registry - -### Basic Troubleshooting - -1. Check to make sure that the system clock on your Docker client and GitLab server have - been synchronized (e.g. via NTP). - -1. If you are using an S3-backed Registry, double check that the IAM - permissions and the S3 credentials (including region) are correct. See [the - sample IAM policy](https://docs.docker.com/registry/storage-drivers/s3/) - for more details. - -1. Check the Registry logs (e.g. `/var/log/gitlab/registry/current`) and the GitLab production logs - for errors (e.g. `/var/log/gitlab/gitlab-rails/production.log`). You may be able to find clues - there. - -#### Enable the registry debug server - -The optional debug server can be enabled by setting the registry debug address -in your `gitlab.rb` configuration. - -```ruby -registry['debug_addr'] = "localhost:5001" -``` - -After adding the setting, [reconfigure] GitLab to apply the change. - -Use curl to request debug output from the debug server: - -```bash -curl localhost:5001/debug/health -curl localhost:5001/debug/vars -``` - -#### Docker connection error - -A Docker connection error can occur when there are special characters in either the group, -project or branch name. Special characters can include: - -- Leading underscore -- Trailing hyphen/dash -- Double hyphen/dash - -To get around this, you can [change the group path](../group/index.md#changing-a-groups-path), -[change the project path](../project/settings/index.md#renaming-a-repository) or chanage the branch -name. - -### Advanced Troubleshooting - -NOTE: **Note:** -The following section is only recommended for experts. - -Sometimes it's not obvious what is wrong, and you may need to dive deeper into -the communication between the Docker client and the Registry to find out -what's wrong. We will use a concrete example in the past to illustrate how to -diagnose a problem with the S3 setup. - -#### Unexpected 403 error during push - -A user attempted to enable an S3-backed Registry. The `docker login` step went -fine. However, when pushing an image, the output showed: - -```text -The push refers to a repository [s3-testing.myregistry.com:4567/root/docker-test/docker-image] -dc5e59c14160: Pushing [==================================================>] 14.85 kB -03c20c1a019a: Pushing [==================================================>] 2.048 kB -a08f14ef632e: Pushing [==================================================>] 2.048 kB -228950524c88: Pushing 2.048 kB -6a8ecde4cc03: Pushing [==> ] 9.901 MB/205.7 MB -5f70bf18a086: Pushing 1.024 kB -737f40e80b7f: Waiting -82b57dbc5385: Waiting -19429b698a22: Waiting -9436069b92a3: Waiting -error parsing HTTP 403 response body: unexpected end of JSON input: "" -``` - -This error is ambiguous, as it's not clear whether the 403 is coming from the -GitLab Rails application, the Docker Registry, or something else. In this -case, since we know that since the login succeeded, we probably need to look -at the communication between the client and the Registry. - -The REST API between the Docker client and Registry is [described -here](https://docs.docker.com/registry/spec/api/). Normally, one would just -use Wireshark or tcpdump to capture the traffic and see where things went -wrong. However, since all communications between Docker clients and servers -are done over HTTPS, it's a bit difficult to decrypt the traffic quickly even -if you know the private key. What can we do instead? - -One way would be to disable HTTPS by setting up an [insecure -Registry](https://docs.docker.com/registry/insecure/). This could introduce a -security hole and is only recommended for local testing. If you have a -production system and can't or don't want to do this, there is another way: -use mitmproxy, which stands for Man-in-the-Middle Proxy. - -#### mitmproxy - -[mitmproxy](https://mitmproxy.org/) allows you to place a proxy between your -client and server to inspect all traffic. One wrinkle is that your system -needs to trust the mitmproxy SSL certificates for this to work. - -The following installation instructions assume you are running Ubuntu: - -1. [Install mitmproxy](https://docs.mitmproxy.org/stable/overview-installation/). -1. Run `mitmproxy --port 9000` to generate its certificates. - Enter <kbd>CTRL</kbd>-<kbd>C</kbd> to quit. -1. Install the certificate from `~/.mitmproxy` to your system: - - ```sh - sudo cp ~/.mitmproxy/mitmproxy-ca-cert.pem /usr/local/share/ca-certificates/mitmproxy-ca-cert.crt - sudo update-ca-certificates - ``` - -If successful, the output should indicate that a certificate was added: - -```sh -Updating certificates in /etc/ssl/certs... 1 added, 0 removed; done. -Running hooks in /etc/ca-certificates/update.d....done. -``` - -To verify that the certificates are properly installed, run: - -```sh -mitmproxy --port 9000 -``` - -This will run mitmproxy on port `9000`. In another window, run: - -```sh -curl --proxy http://localhost:9000 https://httpbin.org/status/200 -``` - -If everything is set up correctly, you will see information on the mitmproxy window and -no errors from the curl commands. - -#### Running the Docker daemon with a proxy - -For Docker to connect through a proxy, you must start the Docker daemon with the -proper environment variables. The easiest way is to shutdown Docker (e.g. `sudo initctl stop docker`) -and then run Docker by hand. As root, run: - -```sh -export HTTP_PROXY="http://localhost:9000" -export HTTPS_PROXY="https://localhost:9000" -docker daemon --debug -``` - -This will launch the Docker daemon and proxy all connections through mitmproxy. - -#### Running the Docker client - -Now that we have mitmproxy and Docker running, we can attempt to login and push -a container image. You may need to run as root to do this. For example: - -```sh -docker login s3-testing.myregistry.com:4567 -docker push s3-testing.myregistry.com:4567/root/docker-test/docker-image -``` - -In the example above, we see the following trace on the mitmproxy window: - -![mitmproxy output from Docker](img/mitmproxy-docker.png) - -The above image shows: - -- The initial PUT requests went through fine with a 201 status code. -- The 201 redirected the client to the S3 bucket. -- The HEAD request to the AWS bucket reported a 403 Unauthorized. - -What does this mean? This strongly suggests that the S3 user does not have the right -[permissions to perform a HEAD request](http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectHEAD.html). -The solution: check the [IAM permissions again](https://docs.docker.com/registry/storage-drivers/s3/). -Once the right permissions were set, the error will go away. - -[ce-4040]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4040 -[ce-11845]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/11845 -[ce-17894]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/17894 -[docker-docs]: https://docs.docker.com/engine/userguide/intro/ -[pat]: ../profile/personal_access_tokens.md -[pdt]: ../project/deploy_tokens/index.md -[reconfigure]: ../../administration/restart_gitlab.md#omnibus-gitlab-reconfigure +This document was moved to [another location](../packages/container_registry/index.md). diff --git a/doc/user/project/deploy_tokens/index.md b/doc/user/project/deploy_tokens/index.md index 164d1dddff0..ca5b2f54e30 100644 --- a/doc/user/project/deploy_tokens/index.md +++ b/doc/user/project/deploy_tokens/index.md @@ -97,4 +97,4 @@ docker login -u $CI_DEPLOY_USER -p $CI_DEPLOY_PASSWORD $CI_REGISTRY [ce-17894]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/17894 [ce-11845]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/11845 [ce-18414]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/18414 -[container registry]: ../container_registry.md +[container registry]: ../../packages/container_registry/index.md diff --git a/doc/user/project/index.md b/doc/user/project/index.md index c63d5308536..53c2194cd90 100644 --- a/doc/user/project/index.md +++ b/doc/user/project/index.md @@ -60,7 +60,7 @@ When you create a project in GitLab, you'll have access to a large number of **GitLab CI/CD:** - [GitLab CI/CD](../../ci/README.md): GitLab's built-in [Continuous Integration, Delivery, and Deployment](https://about.gitlab.com/2016/08/05/continuous-integration-delivery-and-deployment-with-gitlab/) tool - - [Container Registry](container_registry.md): Build and push Docker + - [Container Registry](../packages/container_registry/index.md): Build and push Docker images out-of-the-box - [Auto Deploy](../../ci/autodeploy/index.md): Configure GitLab CI/CD to automatically set up your app's deployment @@ -95,8 +95,8 @@ When you create a project in GitLab, you'll have access to a large number of - [Releases](releases/index.md): a way to track deliverables in your project as snapshot in time of the source, build output, and other metadata or artifacts associated with a released version of your code. -- [Maven packages](packages/maven_repository.md): your private Maven repository in GitLab. **(PREMIUM)** -- [NPM packages](packages/npm_registry.md): your private NPM package registry in GitLab. **(PREMIUM)** +- [Maven packages](../packages/maven_repository/index.md): your private Maven repository in GitLab. **(PREMIUM)** +- [NPM packages](../packages/npm_registry/index.md): your private NPM package registry in GitLab. **(PREMIUM)** - [Code owners](code_owners.md): specify code owners for certain files **(STARTER)** - [License Compliance](../application_security/license_compliance/index.md): approve and blacklist licenses for projects. **(ULTIMATE)** - [Dependency List](../application_security/dependency_list/index.md): view project dependencies. **(ULTIMATE)** diff --git a/doc/user/project/issues/img/link_zoom_call_in_issue.png b/doc/user/project/issues/img/link_zoom_call_in_issue.png Binary files differdeleted file mode 100644 index 3153a0a9b07..00000000000 --- a/doc/user/project/issues/img/link_zoom_call_in_issue.png +++ /dev/null diff --git a/doc/user/project/issues/img/zoom-quickaction-button.png b/doc/user/project/issues/img/zoom-quickaction-button.png Binary files differnew file mode 100644 index 00000000000..d6d691b2267 --- /dev/null +++ b/doc/user/project/issues/img/zoom-quickaction-button.png diff --git a/doc/user/project/issues/issue_data_and_actions.md b/doc/user/project/issues/issue_data_and_actions.md index 41a7ed09281..5313975908b 100644 --- a/doc/user/project/issues/issue_data_and_actions.md +++ b/doc/user/project/issues/issue_data_and_actions.md @@ -157,19 +157,6 @@ The plain text title and description of the issue fill the top center of the iss The description fully supports [GitLab Flavored Markdown](../../markdown.md#gitlab-flavored-markdown-gfm), allowing many formatting options. -##### Zoom call links - -> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/62966) in GitLab 12.0. - -Including a link to a [Zoom](https://zoom.us) call in the description of an issue -results in a **Join Zoom meeting** button at the top of the issue, just under the header. - -For example: - -![Link Zoom Call in Issue](img/link_zoom_call_in_issue.png) - -To remove the button, edit the description and remove the Zoom call link. - #### 17. Mentions You can mention a user or a group present in your GitLab instance with `@username` or @@ -259,3 +246,15 @@ Once you write a comment, you can: ![Comment or thread](img/comment-or-discussion.png) You can also close the issue from here, so you don't need to scroll to the top of the issue page. + +#### 26. Zoom Meetings + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/31103) in GitLab 12.3. + +You can attach and remove Zoom meetings to issues using the `/zoom` and `/remove_zoom` [quick actions](../quick_actions.md) as part of +[GitLab Flavored Markdown](../../markdown.md#gitlab-flavored-markdown-gfm). + +Attaching a [Zoom](https://zoom.us) call an issue +results in a **Join Zoom meeting** button at the top of the issue, just under the header. + +![Link Zoom Call in Issue](img/zoom-quickaction-button.png) diff --git a/doc/user/project/maven_packages.md b/doc/user/project/maven_packages.md index 48835a2dac7..4679eed5433 100644 --- a/doc/user/project/maven_packages.md +++ b/doc/user/project/maven_packages.md @@ -1,5 +1,5 @@ --- -redirect_to: 'packages/maven_repository.md' +redirect_to: '../packages/maven_repository/index.md' --- -This document was moved to [another location](packages/maven_repository.md). +This document was moved to [another location](../packages/maven_repository/index.md). diff --git a/doc/user/project/packages/maven.md b/doc/user/project/packages/maven.md index 266225fdb8d..8378b8c78cd 100644 --- a/doc/user/project/packages/maven.md +++ b/doc/user/project/packages/maven.md @@ -1,5 +1,5 @@ --- -redirect_to: 'maven_repository.md' +redirect_to: '../../packages/maven_repository/index.md' --- -This document was moved to [another location](maven_repository.md). +This document was moved to [another location](../../packages/maven_repository/index.md). diff --git a/doc/user/project/packages/maven_packages.md b/doc/user/project/packages/maven_packages.md index 266225fdb8d..8378b8c78cd 100644 --- a/doc/user/project/packages/maven_packages.md +++ b/doc/user/project/packages/maven_packages.md @@ -1,5 +1,5 @@ --- -redirect_to: 'maven_repository.md' +redirect_to: '../../packages/maven_repository/index.md' --- -This document was moved to [another location](maven_repository.md). +This document was moved to [another location](../../packages/maven_repository/index.md). diff --git a/doc/user/project/packages/maven_repository.md b/doc/user/project/packages/maven_repository.md index 491ebc0c068..8378b8c78cd 100644 --- a/doc/user/project/packages/maven_repository.md +++ b/doc/user/project/packages/maven_repository.md @@ -1,340 +1,5 @@ -# GitLab Maven Repository **(PREMIUM)** +--- +redirect_to: '../../packages/maven_repository/index.md' +--- -> [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/issues/5811) in [GitLab Premium](https://about.gitlab.com/pricing/) 11.3. - -With the GitLab [Maven](https://maven.apache.org) Repository, every -project can have its own space to store its Maven artifacts. - -![GitLab Maven Repository](img/maven_package_view.png) - -## Enabling the Maven Repository - -NOTE: **Note:** -This option is available only if your GitLab administrator has -[enabled support for the Maven repository](../../../administration/packages.md).**(PREMIUM ONLY)** - -After the Packages feature is enabled, the Maven Repository will be available for -all new projects by default. To enable it for existing projects, or if you want -to disable it: - -1. Navigate to your project's **Settings > General > Permissions**. -1. Find the Packages feature and enable or disable it. -1. Click on **Save changes** for the changes to take effect. - -You should then be able to see the **Packages** section on the left sidebar. -Next, you must configure your project to authorize with the GitLab Maven -repository. - -## Authenticating to the GitLab Maven Repository - -If a project is private or you want to upload Maven artifacts to GitLab, -credentials will need to be provided for authorization. Support is available for -[personal access tokens](#authenticating-with-a-personal-access-token) and -[CI job tokens](#authenticating-with-a-ci-job-token) only. -[Deploy tokens](../deploy_tokens/index.md) and regular username/password -credentials do not work. - -### Authenticating with a personal access token - -To authenticate with a [personal access token](../../profile/personal_access_tokens.md), -add a corresponding section to your -[`settings.xml`](https://maven.apache.org/settings.html) file: - -```xml -<settings> - <servers> - <server> - <id>gitlab-maven</id> - <configuration> - <httpHeaders> - <property> - <name>Private-Token</name> - <value>REPLACE_WITH_YOUR_PERSONAL_ACCESS_TOKEN</value> - </property> - </httpHeaders> - </configuration> - </server> - </servers> -</settings> -``` - -You should now be able to upload Maven artifacts to your project. - -### Authenticating with a CI job token - -If you're using Maven with GitLab CI/CD, a CI job token can be used instead -of a personal access token. - -To authenticate with a CI job token, add a corresponding section to your -[`settings.xml`](https://maven.apache.org/settings.html) file: - -```xml -<settings> - <servers> - <server> - <id>gitlab-maven</id> - <configuration> - <httpHeaders> - <property> - <name>Job-Token</name> - <value>${env.CI_JOB_TOKEN}</value> - </property> - </httpHeaders> - </configuration> - </server> - </servers> -</settings> -``` - -You can read more on -[how to create Maven packages using GitLab CI/CD](#creating-maven-packages-with-gitlab-cicd). - -## Configuring your project to use the GitLab Maven repository URL - -To download and upload packages from GitLab, you need a `repository` and -`distributionManagement` section in your `pom.xml` file. - -Depending on your workflow and the amount of Maven packages you have, there are -3 ways you can configure your project to use the GitLab endpoint for Maven packages: - -- **Project level**: Useful when you have few Maven packages which are not under - the same GitLab group. -- **Group level**: Useful when you have many Maven packages under the same GitLab - group. -- **Instance level**: Useful when you have many Maven packages under different - GitLab groups or on their own namespace. - -NOTE: **Note:** -In all cases, you need a project specific URL for uploading a package in -the `distributionManagement` section. - -### Project level Maven endpoint - -The example below shows how the relevant `repository` section of your `pom.xml` -would look like: - -```xml -<repositories> - <repository> - <id>gitlab-maven</id> - <url>https://gitlab.com/api/v4/projects/PROJECT_ID/packages/maven</url> - </repository> -</repositories> -<distributionManagement> - <repository> - <id>gitlab-maven</id> - <url>https://gitlab.com/api/v4/projects/PROJECT_ID/packages/maven</url> - </repository> - <snapshotRepository> - <id>gitlab-maven</id> - <url>https://gitlab.com/api/v4/projects/PROJECT_ID/packages/maven</url> - </snapshotRepository> -</distributionManagement> -``` - -The `id` must be the same with what you -[defined in `settings.xml`](#authenticating-to-the-gitlab-maven-repository). - -Replace `PROJECT_ID` with your project ID which can be found on the home page -of your project. - -If you have a self-hosted GitLab installation, replace `gitlab.com` with your -domain name. - -NOTE: **Note:** -For retrieving artifacts, you can use either the -[URL encoded](../../../api/README.md#namespaced-path-encoding) path of the project -(e.g., `group%2Fproject`) or the project's ID (e.g., `42`). However, only the -project's ID can be used for uploading. - -### Group level Maven endpoint - -> [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/8798) in GitLab Premium 11.7. - -If you rely on many packages, it might be inefficient to include the `repository` section -with a unique URL for each package. Instead, you can use the group level endpoint for -all your Maven packages stored within one GitLab group. Only packages you have access to -will be available for download. - -The group level endpoint works with any package names, which means the you -have the flexibility of naming compared to [instance level endpoint](#instance-level-maven-endpoint). -However, GitLab will not guarantee the uniqueness of the package names within -the group. You can have two projects with the same package name and package -version. As a result, GitLab will serve whichever one is more recent. - -The example below shows how the relevant `repository` section of your `pom.xml` -would look like. You still need a project specific URL for uploading a package in -the `distributionManagement` section: - -```xml -<repositories> - <repository> - <id>gitlab-maven</id> - <url>https://gitlab.com/api/v4/groups/my-group/-/packages/maven</url> - </repository> -</repositories> -<distributionManagement> - <repository> - <id>gitlab-maven</id> - <url>https://gitlab.com/api/v4/projects/PROJECT_ID/packages/maven</url> - </repository> - <snapshotRepository> - <id>gitlab-maven</id> - <url>https://gitlab.com/api/v4/projects/PROJECT_ID/packages/maven</url> - </snapshotRepository> -</distributionManagement> -``` - -The `id` must be the same with what you -[defined in `settings.xml`](#authenticating-to-the-gitlab-maven-repository). - -Replace `my-group` with your group name and `PROJECT_ID` with your project ID -which can be found on the home page of your project. - -If you have a self-hosted GitLab installation, replace `gitlab.com` with your -domain name. - -NOTE: **Note:** -For retrieving artifacts, you can use either the -[URL encoded](../../../api/README.md#namespaced-path-encoding) path of the group -(e.g., `group%2Fsubgroup`) or the group's ID (e.g., `12`). - -### Instance level Maven endpoint - -> [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/8274) in GitLab Premium 11.7. - -If you rely on many packages, it might be inefficient to include the `repository` section -with a unique URL for each package. Instead, you can use the instance level endpoint for -all maven packages stored in GitLab and the packages you have access to will be available -for download. - -Note that **only packages that have the same path as the project** are exposed via -the instance level endpoint. - -| Project | Package | Instance level endpoint available | -| ------- | ------- | --------------------------------- | -| `foo/bar` | `foo/bar/1.0-SNAPSHOT` | Yes | -| `gitlab-org/gitlab-ce` | `foo/bar/1.0-SNAPSHOT` | No | -| `gitlab-org/gitlab-ce` | `gitlab-org/gitlab-ce/1.0-SNAPSHOT` | Yes | - -The example below shows how the relevant `repository` section of your `pom.xml` -would look like. You still need a project specific URL for uploading a package in -the `distributionManagement` section: - -```xml -<repositories> - <repository> - <id>gitlab-maven</id> - <url>https://gitlab.com/api/v4/packages/maven</url> - </repository> -</repositories> -<distributionManagement> - <repository> - <id>gitlab-maven</id> - <url>https://gitlab.com/api/v4/projects/PROJECT_ID/packages/maven</url> - </repository> - <snapshotRepository> - <id>gitlab-maven</id> - <url>https://gitlab.com/api/v4/projects/PROJECT_ID/packages/maven</url> - </snapshotRepository> -</distributionManagement> -``` - -The `id` must be the same with what you -[defined in `settings.xml`](#authenticating-to-the-gitlab-maven-repository). - -Replace `PROJECT_ID` with your project ID which can be found on the home page -of your project. - -If you have a self-hosted GitLab installation, replace `gitlab.com` with your -domain name. - -NOTE: **Note:** -For retrieving artifacts, you can use either the -[URL encoded](../../../api/README.md#namespaced-path-encoding) path of the project -(e.g., `group%2Fproject`) or the project's ID (e.g., `42`). However, only the -project's ID can be used for uploading. - -## Uploading packages - -Once you have set up the [authentication](#authenticating-to-the-gitlab-maven-repository) -and [configuration](#configuring-your-project-to-use-the-gitlab-maven-repository-url), -test to upload a Maven artifact from a project of yours: - -```sh -mvn deploy -``` - -You can then navigate to your project's **Packages** page and see the uploaded -artifacts or even delete them. - -## Creating Maven packages with GitLab CI/CD - -Once you have your repository configured to use the GitLab Maven Repository, -you can configure GitLab CI/CD to build new packages automatically. The example below -shows how to create a new package each time the `master` branch is updated: - -1. Create a `ci_settings.xml` file that will serve as Maven's `settings.xml` file. - Add the server section with the same id you defined in your `pom.xml` file. - For example, in our case it's `gitlab-maven`: - - ```xml - <settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"> - <servers> - <server> - <id>gitlab-maven</id> - <configuration> - <httpHeaders> - <property> - <name>Job-Token</name> - <value>${env.CI_JOB_TOKEN}</value> - </property> - </httpHeaders> - </configuration> - </server> - </servers> - </settings> - ``` - -1. Make sure your `pom.xml` file includes the following: - - ```xml - <repositories> - <repository> - <id>gitlab-maven</id> - <url>https://gitlab.com/api/v4/projects/${env.CI_PROJECT_ID}/packages/maven</url> - </repository> - </repositories> - <distributionManagement> - <repository> - <id>gitlab-maven</id> - <url>https://gitlab.com/api/v4/projects/${env.CI_PROJECT_ID}/packages/maven</url> - </repository> - <snapshotRepository> - <id>gitlab-maven</id> - <url>https://gitlab.com/api/v4/projects/${env.CI_PROJECT_ID}/packages/maven</url> - </snapshotRepository> - </distributionManagement> - ``` - - TIP: **Tip:** - You can either let Maven utilize the CI environment variables or hardcode your project's ID. - -1. Add a `deploy` job to your `.gitlab-ci.yml` file: - - ```yaml - deploy: - image: maven:3.3.9-jdk-8 - script: - - 'mvn deploy -s ci_settings.xml' - only: - - master - ``` - -1. Push those files to your repository. - -The next time the `deploy` job runs, it will copy `ci_settings.xml` to the -user's home location (in this case the user is `root` since it runs in a -Docker container), and Maven will utilize the configured CI -[environment variables](../../../ci/variables/README.md#predefined-environment-variables). +This document was moved to [another location](../../packages/maven_repository/index.md). diff --git a/doc/user/project/packages/npm_registry.md b/doc/user/project/packages/npm_registry.md index 48186688da9..e94599cf33a 100644 --- a/doc/user/project/packages/npm_registry.md +++ b/doc/user/project/packages/npm_registry.md @@ -1,147 +1,5 @@ -# GitLab NPM Registry **(PREMIUM)** +--- +redirect_to: '../../packages/npm_registry/index.md' +--- -> [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/issues/5934) in [GitLab Premium](https://about.gitlab.com/pricing/) 11.7. - -With the GitLab NPM Registry, every -project can have its own space to store NPM packages. - -![GitLab NPM Registry](img/npm_package_view.png) - -NOTE: **Note:** -Only [scoped](https://docs.npmjs.com/misc/scope) packages are supported. - -## Enabling the NPM Registry - -NOTE: **Note:** -This option is available only if your GitLab administrator has -[enabled support for the NPM registry](../../../administration/packages.md).**(PREMIUM ONLY)** - -After the NPM registry is enabled, it will be available for all new projects -by default. To enable it for existing projects, or if you want to disable it: - -1. Navigate to your project's **Settings > General > Permissions**. -1. Find the Packages feature and enable or disable it. -1. Click on **Save changes** for the changes to take effect. - -You should then be able to see the **Packages** section on the left sidebar. - -Before proceeding to authenticating with the GitLab NPM Registry, you should -get familiar with the package naming convention. - -## Package naming convention - -**Packages must be scoped in the root namespace of the project**. The package -name may be anything but it is preferred that the project name be used unless -it is not possible due to a naming collision. For example: - -| Project | Package | Supported | -| ---------------------- | ----------------------- | --------- | -| `foo/bar` | `@foo/bar` | Yes | -| `foo/bar/baz` | `@foo/baz` | Yes | -| `foo/bar/buz` | `@foo/anything` | Yes | -| `gitlab-org/gitlab-ce` | `@gitlab-org/gitlab-ce` | Yes | -| `gitlab-org/gitlab-ce` | `@foo/bar` | No | - -Now, you can configure your project to authenticate with the GitLab NPM -Registry. - -## Authenticating to the GitLab NPM Registry - -If a project is private or you want to upload an NPM package to GitLab, -credentials will need to be provided for authentication. Support is available for [OAuth tokens](../../../api/oauth2.md#resource-owner-password-credentials-flow) or [personal access tokens](../../profile/personal_access_tokens.md). - -CAUTION: **2FA is only supported with personal access tokens:** -If you have 2FA enabled, you need to use a [personal access token](../../profile/personal_access_tokens.md) with OAuth headers. Standard OAuth tokens won't be able to authenticate to the GitLab NPM Registry. - -### Authenticating with an OAuth token - -To authenticate with an [OAuth token](../../../api/oauth2.md#resource-owner-password-credentials-flow) -or [personal access token](../../profile/personal_access_tokens.md), add a corresponding section to your `.npmrc` file: - -```ini -; Set URL for your scoped packages. -; For example package with name `@foo/bar` will use this URL for download -@foo:registry=https://gitlab.com/api/v4/packages/npm/ - -; Add the token for the scoped packages URL. This will allow you to download -; `@foo/` packages from private projects. -//gitlab.com/api/v4/packages/npm/:_authToken=<your_token> - -; Add token for uploading to the registry. Replace <your_project_id> -; with the project you want your package to be uploaded to. -//gitlab.com/api/v4/projects/<your_project_id>/packages/npm/:_authToken=<your_token> -``` - -Replace `<your_project_id>` with your project ID which can be found on the home page -of your project and `<your_token>` with your OAuth or personal access token. - -If you have a self-hosted GitLab installation, replace `gitlab.com` with your -domain name. - -You should now be able to download and upload NPM packages to your project. - -NOTE: **Note:** -If you encounter an error message with [Yarn](https://yarnpkg.com/en/), see the -[troubleshooting section](#troubleshooting). - -## Uploading packages - -Before you will be able to upload a package, you need to specify the registry -for NPM. To do this, add the following section to the bottom of `package.json`: - -```json - "publishConfig": { - "@foo:registry":"https://gitlab.com/api/v4/projects/<your_project_id>/packages/npm/" - } -``` - -Replace `<your_project_id>` with your project ID, which can be found on the home -page of your project, and replace `@foo` with your own scope. - -If you have a self-hosted GitLab installation, replace `gitlab.com` with your -domain name. - -Once you have enabled it and set up [authentication](#authenticating-to-the-gitlab-npm-registry), -you can upload an NPM package to your project: - -```sh -npm publish -``` - -You can then navigate to your project's **Packages** page and see the uploaded -packages or even delete them. - -If you attempt to publish a package with a name that already exists within -a given scope, you will receive a `403 Forbidden!` error. - -## Uploading a package with the same version twice - -If you upload a package with a same name and version twice, GitLab will show -both packages in the UI, but the GitLab NPM Registry will expose the most recent -one as it supports only one package per version for `npm install`. - -## Troubleshooting - -### Error running yarn with NPM registry - -If you are using [yarn](https://yarnpkg.com/en/) with the NPM registry, you may get -an error message like: - -```sh -yarn install v1.15.2 -warning package.json: No license field -info No lockfile found. -warning XXX: No license field -[1/4] 🔍 Resolving packages... -[2/4] 🚚 Fetching packages... -error An unexpected error occurred: "https://gitlab.com/api/v4/projects/XXX/packages/npm/XXX/XXX/-/XXX/XXX-X.X.X.tgz: Request failed \"404 Not Found\"". -info If you think this is a bug, please open a bug report with the information provided in "/Users/XXX/gitlab-migration/module-util/yarn-error.log". -info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command -``` - -In this case, try adding this to your `.npmrc` file (and replace `<your_oauth_token>` -with your with your OAuth or personal access token): - -```text -//gitlab.com/api/v4/projects/:_authToken=<your_oauth_token> -``` +This document was moved to [another location](../../packages/npm_registry/index.md). diff --git a/doc/user/project/settings/index.md b/doc/user/project/settings/index.md index e0fb5c57784..66a861faf93 100644 --- a/doc/user/project/settings/index.md +++ b/doc/user/project/settings/index.md @@ -22,7 +22,7 @@ The project description also partially supports [standard markdown](../../markdo ### Sharing and permissions -Set up your project's access, [visibility](../../../public_access/public_access.md), and enable [Container Registry](../container_registry.md) for your projects: +Set up your project's access, [visibility](../../../public_access/public_access.md), and enable [Container Registry](../../packages/container_registry/index.md) for your projects: ![projects sharing permissions](img/sharing_and_permissions_settings.png) diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 4018ce900e1..9e820f00c42 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -400,6 +400,7 @@ module API end class GroupDetail < Group + expose :runners_token, if: lambda { |group, options| options[:user_can_admin_group] } expose :projects, using: Entities::Project do |group, options| projects = GroupProjectsFinder.new( group: group, diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 4ae9b8c70d3..9d1628de7e5 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -173,7 +173,8 @@ module API options = { with: params[:with_projects] ? Entities::GroupDetail : Entities::Group, - current_user: current_user + current_user: current_user, + user_can_admin_group: can?(current_user, :admin_group, group) } group, options = with_custom_attributes(group, options) diff --git a/lib/api/helpers/issues_helpers.rb b/lib/api/helpers/issues_helpers.rb index 8addcd18fe3..e272b13f3ae 100644 --- a/lib/api/helpers/issues_helpers.rb +++ b/lib/api/helpers/issues_helpers.rb @@ -11,6 +11,9 @@ module API params :optional_issues_params_ee do end + params :optional_issue_not_params_ee do + end + def self.update_params_at_least_one_of [ :assignee_id, @@ -35,8 +38,11 @@ module API args = declared_params.merge(args) args.delete(:id) + args[:not] ||= {} args[:milestone_title] ||= args.delete(:milestone) + args[:not][:milestone_title] ||= args[:not]&.delete(:milestone) args[:label_name] ||= args.delete(:labels) + args[:not][:label_name] ||= args[:not]&.delete(:labels) args[:scope] = args[:scope].underscore if args[:scope] args[:sort] = "#{args[:order_by]}_#{args[:sort]}" diff --git a/lib/api/helpers/services_helpers.rb b/lib/api/helpers/services_helpers.rb index 5331de3c035..eba4ebb4b6e 100644 --- a/lib/api/helpers/services_helpers.rb +++ b/lib/api/helpers/services_helpers.rb @@ -1,4 +1,3 @@ -# coding: utf-8 # frozen_string_literal: true module API diff --git a/lib/api/issues.rb b/lib/api/issues.rb index 215178478d0..d06550191ad 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -9,28 +9,35 @@ module API before { authenticate_non_get! } helpers do - params :issues_stats_params do + params :negatable_issue_filter_params do optional :labels, type: Array[String], coerce_with: Validations::Types::LabelsList.coerce, desc: 'Comma-separated list of label names' optional :milestone, type: String, desc: 'Milestone title' - optional :milestone, type: String, desc: 'Return issues for a specific milestone' optional :iids, type: Array[Integer], desc: 'The IID array of issues' optional :search, type: String, desc: 'Search issues for text present in the title, description, or any combination of these' optional :in, type: String, desc: '`title`, `description`, or a string joining them with comma' - optional :created_after, type: DateTime, desc: 'Return issues created after the specified time' - optional :created_before, type: DateTime, desc: 'Return issues created before the specified time' - optional :updated_after, type: DateTime, desc: 'Return issues updated after the specified time' - optional :updated_before, type: DateTime, desc: 'Return issues updated before the specified time' optional :author_id, type: Integer, desc: 'Return issues which are authored by the user with the given ID' optional :author_username, type: String, desc: 'Return issues which are authored by the user with the given username' mutually_exclusive :author_id, :author_username optional :assignee_id, types: [Integer, String], integer_none_any: true, - desc: 'Return issues which are assigned to the user with the given ID' + desc: 'Return issues which are assigned to the user with the given ID' optional :assignee_username, type: Array[String], check_assignees_count: true, - coerce_with: Validations::CheckAssigneesCount.coerce, - desc: 'Return issues which are assigned to the user with the given username' + coerce_with: Validations::CheckAssigneesCount.coerce, + desc: 'Return issues which are assigned to the user with the given username' mutually_exclusive :assignee_id, :assignee_username + end + + params :issues_stats_params do + use :negatable_issue_filter_params + optional :created_after, type: DateTime, desc: 'Return issues created after the specified time' + optional :created_before, type: DateTime, desc: 'Return issues created before the specified time' + optional :updated_after, type: DateTime, desc: 'Return issues updated after the specified time' + optional :updated_before, type: DateTime, desc: 'Return issues updated before the specified time' + + optional :not, type: Hash do + use :negatable_issue_filter_params + end optional :scope, type: String, values: %w[created-by-me assigned-to-me created_by_me assigned_to_me all], desc: 'Return issues for the given scope: `created_by_me`, `assigned_to_me` or `all`' diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb index 9e888368e7b..e09d226a13f 100644 --- a/lib/api/pipelines.rb +++ b/lib/api/pipelines.rb @@ -69,6 +69,19 @@ module API end # rubocop: enable CodeReuse/ActiveRecord + desc 'Gets a the latest pipeline for the project branch' do + detail 'This feature was introduced in GitLab 12.3' + success Entities::Pipeline + end + params do + optional :ref, type: String, desc: 'branch ref of pipeline' + end + get ':id/pipelines/latest' do + authorize! :read_pipeline, latest_pipeline + + present latest_pipeline, with: Entities::Pipeline + end + desc 'Gets a specific pipeline for the project' do detail 'This feature was introduced in GitLab 8.11' success Entities::Pipeline @@ -144,7 +157,15 @@ module API helpers do def pipeline - @pipeline ||= user_project.ci_pipelines.find(params[:pipeline_id]) + strong_memoize(:pipeline) do + user_project.ci_pipelines.find(params[:pipeline_id]) + end + end + + def latest_pipeline + strong_memoize(:latest_pipeline) do + user_project.latest_pipeline_for_ref(params[:ref]) + end end end end diff --git a/lib/gitlab/auth/ldap/dn.rb b/lib/gitlab/auth/ldap/dn.rb index 5df914aa367..0b496da784d 100644 --- a/lib/gitlab/auth/ldap/dn.rb +++ b/lib/gitlab/auth/ldap/dn.rb @@ -1,4 +1,3 @@ -# -*- ruby encoding: utf-8 -*- # frozen_string_literal: true # Based on the `ruby-net-ldap` gem's `Net::LDAP::DN` diff --git a/lib/gitlab/ee_compat_check.rb b/lib/gitlab/ee_compat_check.rb index 20c31e06905..5cd90814ca3 100644 --- a/lib/gitlab/ee_compat_check.rb +++ b/lib/gitlab/ee_compat_check.rb @@ -1,4 +1,3 @@ -# coding: utf-8 # frozen_string_literal: true # rubocop: disable Rails/Output diff --git a/lib/gitlab/profiler.rb b/lib/gitlab/profiler.rb index 3f26b84be20..275151f7fc1 100644 --- a/lib/gitlab/profiler.rb +++ b/lib/gitlab/profiler.rb @@ -1,4 +1,3 @@ -# coding: utf-8 # frozen_string_literal: true module Gitlab diff --git a/lib/gitlab/quick_actions/issuable_actions.rb b/lib/gitlab/quick_actions/issuable_actions.rb index 5cf24823ef5..340ec75c5f1 100644 --- a/lib/gitlab/quick_actions/issuable_actions.rb +++ b/lib/gitlab/quick_actions/issuable_actions.rb @@ -1,4 +1,3 @@ -# coding: utf-8 # frozen_string_literal: true module Gitlab diff --git a/lib/gitlab/slash_commands/presenters/issue_move.rb b/lib/gitlab/slash_commands/presenters/issue_move.rb index ca0644ede95..01f2025ee10 100644 --- a/lib/gitlab/slash_commands/presenters/issue_move.rb +++ b/lib/gitlab/slash_commands/presenters/issue_move.rb @@ -1,4 +1,3 @@ -# coding: utf-8 # frozen_string_literal: true module Gitlab diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 52a68e987f0..d7134d3d25a 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 # frozen_string_literal: true require 'spec_helper' diff --git a/spec/controllers/concerns/send_file_upload_spec.rb b/spec/controllers/concerns/send_file_upload_spec.rb index 3bf0ec799c7..4110be721ad 100644 --- a/spec/controllers/concerns/send_file_upload_spec.rb +++ b/spec/controllers/concerns/send_file_upload_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 # frozen_string_literal: true require 'spec_helper' diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb index b455b55bd11..53d32665b0c 100644 --- a/spec/controllers/projects/jobs_controller_spec.rb +++ b/spec/controllers/projects/jobs_controller_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 # frozen_string_literal: true require 'spec_helper' diff --git a/spec/finders/issues_finder_spec.rb b/spec/finders/issues_finder_spec.rb index ef8749be0be..a17ff1ad50d 100644 --- a/spec/finders/issues_finder_spec.rb +++ b/spec/finders/issues_finder_spec.rb @@ -21,15 +21,28 @@ describe IssuesFinder do let(:expected_issuables) { [issue1, issue2] } end - it_behaves_like 'assignee username filter' do + it_behaves_like 'assignee NOT ID filter' do + let(:params) { { not: { assignee_id: user.id } } } + let(:expected_issuables) { [issue3, issue4] } + end + + context 'filter by username' do + set(:user3) { create(:user) } + before do project2.add_developer(user3) issue3.assignees = [user2, user3] end - set(:user3) { create(:user) } - let(:params) { { assignee_username: [user2.username, user3.username] } } - let(:expected_issuables) { [issue3] } + it_behaves_like 'assignee username filter' do + let(:params) { { assignee_username: [user2.username, user3.username] } } + let(:expected_issuables) { [issue3] } + end + + it_behaves_like 'assignee NOT username filter' do + let(:params) { { not: { assignee_username: [user2.username, user3.username] } } } + let(:expected_issuables) { [issue1, issue2, issue4] } + end end it_behaves_like 'no assignee filter' do @@ -112,6 +125,26 @@ describe IssuesFinder do end end + context 'filtering by NOT group_id' do + let(:params) { { not: { group_id: group.id } } } + + context 'when include_subgroup param not set' do + it 'returns all other group issues' do + expect(issues).to contain_exactly(issue2, issue3, issue4) + end + end + + context 'when include_subgroup param is true', :nested_groups do + before do + params[:include_subgroups] = true + end + + it 'returns all other group and subgroup issues' do + expect(issues).to contain_exactly(issue2, issue3) + end + end + end + context 'filtering by author ID' do let(:params) { { author_id: user2.id } } @@ -120,6 +153,14 @@ describe IssuesFinder do end end + context 'filtering by not author ID' do + let(:params) { { not: { author_id: user2.id } } } + + it 'returns issues not created by that user' do + expect(issues).to contain_exactly(issue1, issue2, issue4) + end + end + context 'filtering by milestone' do let(:params) { { milestone_title: milestone.title } } @@ -128,6 +169,14 @@ describe IssuesFinder do end end + context 'filtering by not milestone' do + let(:params) { { not: { milestone_title: milestone.title } } } + + it 'returns issues not assigned to that milestone' do + expect(issues).to contain_exactly(issue2, issue3, issue4) + end + end + context 'filtering by group milestone' do let!(:group) { create(:group, :public) } let(:group_milestone) { create(:milestone, group: group) } @@ -143,6 +192,14 @@ describe IssuesFinder do it 'returns issues assigned to that group milestone' do expect(issues).to contain_exactly(issue2, issue3) end + + context 'using NOT' do + let(:params) { { not: { milestone_title: group_milestone.title } } } + + it 'returns issues not assigned to that group milestone' do + expect(issues).to contain_exactly(issue1, issue4) + end + end end context 'filtering by no milestone' do @@ -184,10 +241,10 @@ describe IssuesFinder do let(:project_next_8_8) { create(:project, :public) } let(:project_in_group) { create(:project, :public, namespace: group) } - let(:yesterday) { Date.today - 1.day } - let(:tomorrow) { Date.today + 1.day } - let(:two_days_from_now) { Date.today + 2.days } - let(:ten_days_from_now) { Date.today + 10.days } + let(:yesterday) { Date.current - 1.day } + let(:tomorrow) { Date.current + 1.day } + let(:two_days_from_now) { Date.current + 2.days } + let(:ten_days_from_now) { Date.current + 10.days } let(:milestones) do [ @@ -201,7 +258,7 @@ describe IssuesFinder do end before do - milestones.each do |milestone| + @created_issues = milestones.map do |milestone| create(:issue, project: milestone.project || project_in_group, milestone: milestone, author: user, assignees: [user]) end end @@ -210,6 +267,18 @@ describe IssuesFinder do expect(issues.map { |issue| issue.milestone.title }).to contain_exactly('1.1', '8.8', '9.9') expect(issues.map { |issue| issue.milestone.due_date }).to contain_exactly(tomorrow, two_days_from_now, tomorrow) end + + context 'using NOT' do + let(:params) { { not: { milestone_title: Milestone::Upcoming.name } } } + + it 'returns issues not in upcoming milestones for each project or group' do + target_issues = @created_issues.reject do |issue| + issue.milestone&.due_date && issue.milestone.due_date > Date.current + end + @created_issues.select { |issue| issue.milestone&.title == '8.9' } + + expect(issues).to contain_exactly(issue1, issue2, issue3, issue4, *target_issues) + end + end end context 'filtering by started milestone' do @@ -219,10 +288,10 @@ describe IssuesFinder do let(:project_started_1_and_2) { create(:project, :public) } let(:project_started_8) { create(:project, :public) } - let(:yesterday) { Date.today - 1.day } - let(:tomorrow) { Date.today + 1.day } - let(:two_days_ago) { Date.today - 2.days } - let(:three_days_ago) { Date.today - 3.days } + let(:yesterday) { Date.current - 1.day } + let(:tomorrow) { Date.current + 1.day } + let(:two_days_ago) { Date.current - 2.days } + let(:three_days_ago) { Date.current - 3.days } let(:milestones) do [ @@ -248,6 +317,16 @@ describe IssuesFinder do expect(issues.map { |issue| issue.milestone.title }).to contain_exactly('1.0', '2.0', '8.0') expect(issues.map { |issue| issue.milestone.start_date }).to contain_exactly(two_days_ago, yesterday, yesterday) end + + context 'using NOT' do + let(:params) { { not: { milestone_title: Milestone::Started.name } } } + + it 'returns issues not in the started milestones for each project' do + target_issues = Issue.where.not(milestone: Milestone.started) + + expect(issues).to contain_exactly(issue2, issue3, issue4, *target_issues) + end + end end context 'filtering by label' do @@ -256,6 +335,33 @@ describe IssuesFinder do it 'returns issues with that label' do expect(issues).to contain_exactly(issue2) end + + context 'using NOT' do + let(:params) { { not: { label_name: label.title } } } + + it 'returns issues that do not have that label' do + expect(issues).to contain_exactly(issue1, issue3, issue4) + end + + # IssuableFinder first filters using the outer params (the ones not inside the `not` key.) + # Afterwards, it applies the `not` params to that resultset. This means that things inside the `not` param + # do not take precedence over the outer params with the same name. + context 'shadowing the same outside param' do + let(:params) { { label_name: label2.title, not: { label_name: label.title } } } + + it 'does not take precedence over labels outside NOT' do + expect(issues).to contain_exactly(issue3) + end + end + + context 'further filtering outside params' do + let(:params) { { label_name: label2.title, not: { assignee_username: user2.username } } } + + it 'further filters on the returned resultset' do + expect(issues).to be_empty + end + end + end end context 'filtering by multiple labels' do @@ -269,6 +375,14 @@ describe IssuesFinder do it 'returns the unique issues with all those labels' do expect(issues).to contain_exactly(issue2) end + + context 'using NOT' do + let(:params) { { not: { label_name: [label.title, label2.title].join(',') } } } + + it 'returns issues that do not have ALL labels provided' do + expect(issues).to contain_exactly(issue1, issue3, issue4) + end + end end context 'filtering by a label that includes any or none in the title' do @@ -276,18 +390,28 @@ describe IssuesFinder do let(:label) { create(:label, title: 'any foo', project: project2) } let(:label2) { create(:label, title: 'bar none', project: project2) } - it 'returns the unique issues with all those labels' do + before do create(:label_link, label: label2, target: issue2) + end + it 'returns the unique issues with all those labels' do expect(issues).to contain_exactly(issue2) end + + context 'using NOT' do + let(:params) { { not: { label_name: [label.title, label2.title].join(',') } } } + + it 'returns issues that do not have ALL labels provided' do + expect(issues).to contain_exactly(issue1, issue3, issue4) + end + end end context 'filtering by no label' do let(:params) { { label_name: described_class::FILTER_NONE } } it 'returns issues with no labels' do - expect(issues).to contain_exactly(issue1, issue3, issue4) + expect(issues).to contain_exactly(issue1, issue4) end end @@ -309,6 +433,14 @@ describe IssuesFinder do it 'returns issues with title and description match for search term' do expect(issues).to contain_exactly(issue1, issue2) end + + context 'using NOT' do + let(:params) { { not: { search: 'git' } } } + + it 'returns issues with no title and description match for search term' do + expect(issues).to contain_exactly(issue3, issue4) + end + end end context 'filtering by issue term in title' do @@ -317,6 +449,14 @@ describe IssuesFinder do it 'returns issues with title match for search term' do expect(issues).to contain_exactly(issue1) end + + context 'using NOT' do + let(:params) { { not: { search: 'git', in: 'title' } } } + + it 'returns issues with no title match for search term' do + expect(issues).to contain_exactly(issue2, issue3, issue4) + end + end end context 'filtering by issues iids' do @@ -325,6 +465,14 @@ describe IssuesFinder do it 'returns issues with iids match' do expect(issues).to contain_exactly(issue3) end + + context 'using NOT' do + let(:params) { { not: { iids: issue3.iid } } } + + it 'returns issues with no iids match' do + expect(issues).to contain_exactly(issue1, issue2, issue4) + end + end end context 'filtering by state' do @@ -466,6 +614,14 @@ describe IssuesFinder do it 'returns issues that the user thumbsup to' do expect(issues).to contain_exactly(issue1) end + + context 'using NOT' do + let(:params) { { not: { my_reaction_emoji: 'thumbsup' } } } + + it 'returns issues that the user did not thumbsup to' do + expect(issues).to contain_exactly(issue2, issue3, issue4) + end + end end context 'user2 searches by "thumbsup" reaction' do @@ -476,6 +632,14 @@ describe IssuesFinder do it 'returns issues that the user2 thumbsup to' do expect(issues).to contain_exactly(issue2) end + + context 'using NOT' do + let(:params) { { not: { my_reaction_emoji: 'thumbsup' } } } + + it 'returns issues that the user2 thumbsup to' do + expect(issues).to contain_exactly(issue3) + end + end end context 'user searches by "thumbsdown" reaction' do @@ -484,6 +648,14 @@ describe IssuesFinder do it 'returns issues that the user thumbsdown to' do expect(issues).to contain_exactly(issue3) end + + context 'using NOT' do + let(:params) { { not: { my_reaction_emoji: 'thumbsdown' } } } + + it 'returns issues that the user thumbsdown to' do + expect(issues).to contain_exactly(issue1, issue2, issue4) + end + end end end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 4a3ff7e0095..2f481e237a7 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 require 'spec_helper' describe ApplicationHelper do diff --git a/spec/helpers/defer_script_tag_helper_spec.rb b/spec/helpers/defer_script_tag_helper_spec.rb index d10b6f134e4..9ada3ae75ba 100644 --- a/spec/helpers/defer_script_tag_helper_spec.rb +++ b/spec/helpers/defer_script_tag_helper_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 require 'spec_helper' describe DeferScriptTagHelper do diff --git a/spec/lib/container_registry/client_spec.rb b/spec/lib/container_registry/client_spec.rb index bc5fddd12ba..6c2b338bfcd 100644 --- a/spec/lib/container_registry/client_spec.rb +++ b/spec/lib/container_registry/client_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 # frozen_string_literal: true require 'spec_helper' diff --git a/spec/lib/gitlab/encoding_helper_spec.rb b/spec/lib/gitlab/encoding_helper_spec.rb index b24b71522ec..fc08719fb33 100644 --- a/spec/lib/gitlab/encoding_helper_spec.rb +++ b/spec/lib/gitlab/encoding_helper_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 # frozen_string_literal: true require "spec_helper" diff --git a/spec/lib/gitlab/git/blame_spec.rb b/spec/lib/gitlab/git/blame_spec.rb index 0010c0304eb..ac085e2c266 100644 --- a/spec/lib/gitlab/git/blame_spec.rb +++ b/spec/lib/gitlab/git/blame_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 require "spec_helper" describe Gitlab::Git::Blame, :seed_helper do diff --git a/spec/lib/gitlab/git/blob_spec.rb b/spec/lib/gitlab/git/blob_spec.rb index 1c24244c3a6..7f680071969 100644 --- a/spec/lib/gitlab/git/blob_spec.rb +++ b/spec/lib/gitlab/git/blob_spec.rb @@ -1,5 +1,3 @@ -# encoding: utf-8 - require "spec_helper" describe Gitlab::Git::Blob, :seed_helper do diff --git a/spec/lib/gitlab/git/conflict/file_spec.rb b/spec/lib/gitlab/git/conflict/file_spec.rb index afed6c32af6..a6cabd4966a 100644 --- a/spec/lib/gitlab/git/conflict/file_spec.rb +++ b/spec/lib/gitlab/git/conflict/file_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 require 'spec_helper' describe Gitlab::Git::Conflict::File do diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index dccd50bc472..e455c4c99ab 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 require "spec_helper" describe Gitlab::Git::Repository, :seed_helper do diff --git a/spec/lib/gitlab/git_spec.rb b/spec/lib/gitlab/git_spec.rb index 6515be85ae3..505bc470644 100644 --- a/spec/lib/gitlab/git_spec.rb +++ b/spec/lib/gitlab/git_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 require 'spec_helper' describe Gitlab::Git do diff --git a/spec/lib/gitlab/json_logger_spec.rb b/spec/lib/gitlab/json_logger_spec.rb index d3d9fe9948a..3d4f9b5db86 100644 --- a/spec/lib/gitlab/json_logger_spec.rb +++ b/spec/lib/gitlab/json_logger_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 require 'spec_helper' describe Gitlab::JsonLogger do diff --git a/spec/lib/gitlab/path_regex_spec.rb b/spec/lib/gitlab/path_regex_spec.rb index 7dcdad7ff92..0829a2b4334 100644 --- a/spec/lib/gitlab/path_regex_spec.rb +++ b/spec/lib/gitlab/path_regex_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 # frozen_string_literal: true require 'spec_helper' diff --git a/spec/lib/gitlab/project_search_results_spec.rb b/spec/lib/gitlab/project_search_results_spec.rb index e0b9581c75c..d6e50c672e6 100644 --- a/spec/lib/gitlab/project_search_results_spec.rb +++ b/spec/lib/gitlab/project_search_results_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 # frozen_string_literal: true require 'spec_helper' diff --git a/spec/lib/gitlab/regex_spec.rb b/spec/lib/gitlab/regex_spec.rb index e19210d8fbf..3036e3a9754 100644 --- a/spec/lib/gitlab/regex_spec.rb +++ b/spec/lib/gitlab/regex_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 # frozen_string_literal: true require 'spec_helper' diff --git a/spec/lib/gitlab/search/found_blob_spec.rb b/spec/lib/gitlab/search/found_blob_spec.rb index 3496fb29836..a575f6e2f11 100644 --- a/spec/lib/gitlab/search/found_blob_spec.rb +++ b/spec/lib/gitlab/search/found_blob_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 # frozen_string_literal: true require 'spec_helper' diff --git a/spec/lib/gitlab/url_blocker_spec.rb b/spec/lib/gitlab/url_blocker_spec.rb index 6ce002ad70e..0e66e959b24 100644 --- a/spec/lib/gitlab/url_blocker_spec.rb +++ b/spec/lib/gitlab/url_blocker_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 # frozen_string_literal: true require 'spec_helper' diff --git a/spec/models/blob_spec.rb b/spec/models/blob_spec.rb index 62a75bde63b..2efab3076d8 100644 --- a/spec/models/blob_spec.rb +++ b/spec/models/blob_spec.rb @@ -1,4 +1,3 @@ -# encoding: utf-8 # frozen_string_literal: true require 'spec_helper' diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 5b4b9c516a0..67f64822184 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -2027,6 +2027,43 @@ describe Project do end end + describe '#latest_pipeline_for_ref' do + let(:project) { create(:project, :repository) } + let(:second_branch) { project.repository.branches[2] } + + let!(:pipeline_for_default_branch) do + create(:ci_empty_pipeline, project: project, sha: project.commit.id, + ref: project.default_branch) + end + let!(:pipeline_for_second_branch) do + create(:ci_empty_pipeline, project: project, sha: second_branch.target, + ref: second_branch.name) + end + + before do + create(:ci_empty_pipeline, project: project, sha: project.commit.parent.id, + ref: project.default_branch) + end + + context 'default repository branch' do + subject { project.latest_pipeline_for_ref(project.default_branch) } + + it { is_expected.to eq(pipeline_for_default_branch) } + end + + context 'provided ref' do + subject { project.latest_pipeline_for_ref(second_branch.name) } + + it { is_expected.to eq(pipeline_for_second_branch) } + end + + context 'bad ref' do + subject { project.latest_pipeline_for_ref(SecureRandom.uuid) } + + it { is_expected.to be_nil } + end + end + describe '#latest_successful_build_for_sha' do let(:project) { create(:project, :repository) } let(:pipeline) { create_pipeline(project) } diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index 0893dcb39b6..b3acf531ccb 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -59,6 +59,16 @@ describe API::Groups do .to satisfy_one { |group| group['name'] == group1.name } end + it "does not include runners_token information" do + get api("/groups", user1) + + expect(response).to have_gitlab_http_status(200) + expect(response).to include_pagination_headers + expect(json_response).to be_an Array + expect(json_response.length).to eq(1) + expect(json_response.first).not_to include('runners_token') + end + it "does not include statistics" do get api("/groups", user1), params: { statistics: true } @@ -79,6 +89,16 @@ describe API::Groups do expect(json_response.length).to eq(2) end + it "does not include runners_token information" do + get api("/groups", admin) + + expect(response).to have_gitlab_http_status(200) + expect(response).to include_pagination_headers + expect(json_response).to be_an Array + expect(json_response.length).to eq(2) + expect(json_response.first).not_to include('runners_token') + end + it "does not include statistics by default" do get api("/groups", admin) @@ -292,6 +312,7 @@ describe API::Groups do get api("/groups/#{group1.id}") expect(response).to have_gitlab_http_status(200) + expect(json_response).not_to include('runners_token') end it 'returns only public projects in the group' do @@ -350,6 +371,22 @@ describe API::Groups do expect(response).to have_gitlab_http_status(200) expect(json_response['projects']).to be_nil expect(json_response['shared_projects']).to be_nil + expect(json_response).not_to include('runners_token') + end + + it "doesn't return runners_token if the user is not the owner of the group" do + get api("/groups/#{group1.id}", user3) + + expect(response).to have_gitlab_http_status(200) + expect(json_response).not_to include('runners_token') + end + + it "returns runners_token if the user is the owner of the group" do + group1.add_owner(user3) + get api("/groups/#{group1.id}", user3) + + expect(response).to have_gitlab_http_status(200) + expect(json_response).to include('runners_token') end it "does not return a non existing group" do @@ -407,6 +444,13 @@ describe API::Groups do expect(json_response['name']).to eq(group2.name) end + it "returns information of the runners_token for the group" do + get api("/groups/#{group2.id}", admin) + + expect(response).to have_gitlab_http_status(200) + expect(json_response).to include('runners_token') + end + it "does not return a non existing group" do get api("/groups/1328", admin) diff --git a/spec/requests/api/issues/get_group_issues_spec.rb b/spec/requests/api/issues/get_group_issues_spec.rb index c487471e4a1..3ee08758f99 100644 --- a/spec/requests/api/issues/get_group_issues_spec.rb +++ b/spec/requests/api/issues/get_group_issues_spec.rb @@ -437,17 +437,21 @@ describe API::Issues do end context 'with labeled issues' do + let(:group_issue2) { create :issue, project: group_project } let(:label_b) { create(:label, title: 'foo', project: group_project) } let(:label_c) { create(:label, title: 'bar', project: group_project) } before do + create(:label_link, label: group_label, target: group_issue2) create(:label_link, label: label_b, target: group_issue) + create(:label_link, label: label_b, target: group_issue2) create(:label_link, label: label_c, target: group_issue) get api(base_url, user), params: params end let(:issue) { group_issue } + let(:issue2) { group_issue2 } let(:label) { group_label } it_behaves_like 'labeled issues with labels and label_name params' diff --git a/spec/requests/api/issues/get_project_issues_spec.rb b/spec/requests/api/issues/get_project_issues_spec.rb index b7aa3f93451..c10f5b2bd58 100644 --- a/spec/requests/api/issues/get_project_issues_spec.rb +++ b/spec/requests/api/issues/get_project_issues_spec.rb @@ -283,11 +283,14 @@ describe API::Issues do end context 'with labeled issues' do + let(:issue2) { create :issue, project: project } let(:label_b) { create(:label, title: 'foo', project: project) } let(:label_c) { create(:label, title: 'bar', project: project) } before do + create(:label_link, label: label, target: issue2) create(:label_link, label: label_b, target: issue) + create(:label_link, label: label_b, target: issue2) create(:label_link, label: label_c, target: issue) get api('/issues', user), params: params diff --git a/spec/requests/api/issues/issues_spec.rb b/spec/requests/api/issues/issues_spec.rb index f19c2dcc6fe..61a94b682be 100644 --- a/spec/requests/api/issues/issues_spec.rb +++ b/spec/requests/api/issues/issues_spec.rb @@ -427,9 +427,12 @@ describe API::Issues do context 'with labeled issues' do let(:label_b) { create(:label, title: 'foo', project: project) } let(:label_c) { create(:label, title: 'bar', project: project) } + let(:issue2) { create(:issue, author: user, project: project) } before do + create(:label_link, label: label, target: issue2) create(:label_link, label: label_b, target: issue) + create(:label_link, label: label_b, target: issue2) create(:label_link, label: label_c, target: issue) get api('/issues', user), params: params @@ -497,46 +500,74 @@ describe API::Issues do end end - it 'returns an empty array if no issue matches milestone' do - get api("/issues?milestone=#{empty_milestone.title}", user) + context 'filter by milestone' do + it 'returns an empty array if no issue matches milestone' do + get api("/issues?milestone=#{empty_milestone.title}", user) - expect_paginated_array_response([]) - end + expect_paginated_array_response([]) + end - it 'returns an empty array if milestone does not exist' do - get api('/issues?milestone=foo', user) + it 'returns an empty array if milestone does not exist' do + get api('/issues?milestone=foo', user) - expect_paginated_array_response([]) - end + expect_paginated_array_response([]) + end - it 'returns an array of issues in given milestone' do - get api("/issues?milestone=#{milestone.title}", user) + it 'returns an array of issues in given milestone' do + get api("/issues?milestone=#{milestone.title}", user) - expect_paginated_array_response([issue.id, closed_issue.id]) - end + expect_paginated_array_response([issue.id, closed_issue.id]) + end - it 'returns an array of issues in given milestone_title param' do - get api("/issues?milestone_title=#{milestone.title}", user) + it 'returns an array of issues in given milestone_title param' do + get api("/issues?milestone_title=#{milestone.title}", user) - expect_paginated_array_response([issue.id, closed_issue.id]) - end + expect_paginated_array_response([issue.id, closed_issue.id]) + end - it 'returns an array of issues matching state in milestone' do - get api("/issues?milestone=#{milestone.title}&state=closed", user) + it 'returns an array of issues matching state in milestone' do + get api("/issues?milestone=#{milestone.title}&state=closed", user) - expect_paginated_array_response(closed_issue.id) - end + expect_paginated_array_response(closed_issue.id) + end - it 'returns an array of issues with no milestone' do - get api("/issues?milestone=#{no_milestone_title}", author) + it 'returns an array of issues with no milestone' do + get api("/issues?milestone=#{no_milestone_title}", author) - expect_paginated_array_response(confidential_issue.id) - end + expect_paginated_array_response(confidential_issue.id) + end - it 'returns an array of issues with no milestone using milestone_title param' do - get api("/issues?milestone_title=#{no_milestone_title}", author) + it 'returns an array of issues with no milestone using milestone_title param' do + get api("/issues?milestone_title=#{no_milestone_title}", author) - expect_paginated_array_response(confidential_issue.id) + expect_paginated_array_response(confidential_issue.id) + end + + context 'negated' do + it 'returns all issues if milestone does not exist' do + get api('/issues?not[milestone]=foo', user) + + expect_paginated_array_response([issue.id, closed_issue.id]) + end + + it 'returns all issues that do not belong to a milestone but have a milestone' do + get api("/issues?not[milestone]=#{empty_milestone.title}", user) + + expect_paginated_array_response([issue.id, closed_issue.id]) + end + + it 'returns an array of issues with any milestone' do + get api("/issues?not[milestone]=#{no_milestone_title}", user) + + expect_paginated_array_response([issue.id, closed_issue.id]) + end + + it 'returns an array of issues matching state not in milestone' do + get api("/issues?not[milestone]=#{empty_milestone.title}&state=closed", user) + + expect_paginated_array_response(closed_issue.id) + end + end end it 'returns an array of issues found by iids' do diff --git a/spec/requests/api/pipelines_spec.rb b/spec/requests/api/pipelines_spec.rb index 174b3214d13..3a3f0e970a4 100644 --- a/spec/requests/api/pipelines_spec.rb +++ b/spec/requests/api/pipelines_spec.rb @@ -459,6 +459,54 @@ describe API::Pipelines do end end + describe 'GET /projects/:id/pipelines/latest' do + context 'authorized user' do + let(:second_branch) { project.repository.branches[2] } + + let!(:second_pipeline) do + create(:ci_empty_pipeline, project: project, sha: second_branch.target, + ref: second_branch.name, user: user) + end + + before do + create(:ci_empty_pipeline, project: project, sha: project.commit.parent.id, + ref: project.default_branch, user: user) + end + + context 'default repository branch' do + it 'gets the latest pipleine' do + get api("/projects/#{project.id}/pipelines/latest", user) + + expect(response).to have_gitlab_http_status(200) + expect(response).to match_response_schema('public_api/v4/pipeline/detail') + expect(json_response['ref']).to eq(project.default_branch) + expect(json_response['sha']).to eq(project.commit.id) + end + end + + context 'ref parameter' do + it 'gets the latest pipleine' do + get api("/projects/#{project.id}/pipelines/latest", user), params: { ref: second_branch.name } + + expect(response).to have_gitlab_http_status(200) + expect(response).to match_response_schema('public_api/v4/pipeline/detail') + expect(json_response['ref']).to eq(second_branch.name) + expect(json_response['sha']).to eq(second_branch.target) + end + end + end + + context 'unauthorized user' do + it 'does not return a project pipeline' do + get api("/projects/#{project.id}/pipelines/#{pipeline.id}", non_member) + + expect(response).to have_gitlab_http_status(404) + expect(json_response['message']).to eq '404 Project Not Found' + expect(json_response['id']).to be nil + end + end + end + describe 'GET /projects/:id/pipelines/:pipeline_id/variables' do subject { get api("/projects/#{project.id}/pipelines/#{pipeline.id}/variables", api_user) } diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index f52e36e6bcd..2d8ef9c06dc 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- require 'spec_helper' shared_examples 'languages and percentages JSON response' do diff --git a/spec/services/git/branch_push_service_spec.rb b/spec/services/git/branch_push_service_spec.rb index c3a4f3dbe3f..f4d1a1e34cd 100644 --- a/spec/services/git/branch_push_service_spec.rb +++ b/spec/services/git/branch_push_service_spec.rb @@ -197,7 +197,7 @@ describe Git::BranchPushService, services: true do create(:protected_branch, :no_one_can_push, :developers_can_merge, project: project, name: 'master') expect(project).to receive(:execute_hooks) expect(project.default_branch).to eq("master") - expect_any_instance_of(ProtectedBranches::CreateService).not_to receive(:execute) + expect(ProtectedBranches::CreateService).not_to receive(:new) execute_service(project, user, blankrev, 'newrev', ref) diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb index fd9a63b79cc..55254b61ac8 100644 --- a/spec/services/issues/update_service_spec.rb +++ b/spec/services/issues/update_service_spec.rb @@ -1,4 +1,3 @@ -# coding: utf-8 # frozen_string_literal: true require 'spec_helper' diff --git a/spec/support/shared_contexts/finders/issues_finder_shared_contexts.rb b/spec/support/shared_contexts/finders/issues_finder_shared_contexts.rb index 26ab6fbd400..6c96b18d834 100644 --- a/spec/support/shared_contexts/finders/issues_finder_shared_contexts.rb +++ b/spec/support/shared_contexts/finders/issues_finder_shared_contexts.rb @@ -12,6 +12,7 @@ RSpec.shared_context 'IssuesFinder context' do set(:project3) { create(:project, group: subgroup) } set(:milestone) { create(:milestone, project: project1) } set(:label) { create(:label, project: project2) } + set(:label2) { create(:label, project: project2) } set(:issue1) { create(:issue, author: user, assignees: [user], project: project1, milestone: milestone, title: 'gitlab', created_at: 1.week.ago, updated_at: 1.week.ago) } set(:issue2) { create(:issue, author: user, assignees: [user], project: project2, description: 'gitlab', created_at: 1.week.from_now, updated_at: 1.week.from_now) } set(:issue3) { create(:issue, author: user2, assignees: [user2], project: project2, title: 'tanuki', description: 'tanuki', created_at: 2.weeks.from_now, updated_at: 2.weeks.from_now) } @@ -24,6 +25,7 @@ end RSpec.shared_context 'IssuesFinder#execute context' do let!(:closed_issue) { create(:issue, author: user2, assignees: [user2], project: project2, state: 'closed') } let!(:label_link) { create(:label_link, label: label, target: issue2) } + let!(:label_link2) { create(:label_link, label: label2, target: issue3) } let(:search_user) { user } let(:params) { {} } let(:issues) { described_class.new(search_user, params.reverse_merge(scope: scope, state: 'opened')).execute } diff --git a/spec/support/shared_examples/finders/assignees_filter_shared_examples.rb b/spec/support/shared_examples/finders/assignees_filter_shared_examples.rb index a931c4df99f..f1df1052ef2 100644 --- a/spec/support/shared_examples/finders/assignees_filter_shared_examples.rb +++ b/spec/support/shared_examples/finders/assignees_filter_shared_examples.rb @@ -6,12 +6,24 @@ shared_examples 'assignee ID filter' do end end +shared_examples 'assignee NOT ID filter' do + it 'returns issuables not assigned to that user' do + expect(issuables).to contain_exactly(*expected_issuables) + end +end + shared_examples 'assignee username filter' do it 'returns issuables assigned to those users' do expect(issuables).to contain_exactly(*expected_issuables) end end +shared_examples 'assignee NOT username filter' do + it 'returns issuables not assigned to those users' do + expect(issuables).to contain_exactly(*expected_issuables) + end +end + shared_examples 'no assignee filter' do let(:params) { { assignee_id: 'None' } } diff --git a/spec/support/shared_examples/models/cluster_application_core_shared_examples.rb b/spec/support/shared_examples/models/cluster_application_core_shared_examples.rb index 8e58cc7ba22..affe88be475 100644 --- a/spec/support/shared_examples/models/cluster_application_core_shared_examples.rb +++ b/spec/support/shared_examples/models/cluster_application_core_shared_examples.rb @@ -21,4 +21,8 @@ shared_examples 'cluster application core specs' do |application_name| expect(Clusters::Cluster::APPLICATIONS[subject.name]).to eq(described_class) end end + + describe '.association_name' do + it { expect(described_class.association_name).to eq(:"application_#{subject.name}") } + end end diff --git a/spec/support/shared_examples/requests/api/issues_shared_examples.rb b/spec/support/shared_examples/requests/api/issues_shared_examples.rb index 1133e95e44e..d22210edf99 100644 --- a/spec/support/shared_examples/requests/api/issues_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/issues_shared_examples.rb @@ -8,6 +8,13 @@ shared_examples 'labeled issues with labels and label_name params' do end end + shared_examples 'returns negated label names' do + it 'returns label names' do + expect_paginated_array_response(issue2.id) + expect(json_response.first['labels']).to eq([label_b.title, label.title]) + end + end + shared_examples 'returns basic label entity' do it 'returns basic label entity' do expect_paginated_array_response(issue.id) @@ -28,6 +35,20 @@ shared_examples 'labeled issues with labels and label_name params' do it_behaves_like 'returns label names' end + context 'negation' do + context 'array of labeled issues when all labels match with negation' do + let(:params) { { labels: "#{label.title},#{label_b.title}", not: { labels: "#{label_c.title}" } } } + + it_behaves_like 'returns negated label names' + end + + context 'array of labeled issues when all labels match with negation with label params as array' do + let(:params) { { labels: [label.title, label_b.title], not: { labels: [label_c.title] } } } + + it_behaves_like 'returns negated label names' + end + end + context 'when with_labels_details provided' do context 'array of labeled issues when all labels match' do let(:params) { { labels: "#{label.title},#{label_b.title},#{label_c.title}", with_labels_details: true } } |