summaryrefslogtreecommitdiff
path: root/doc/user/packages/nuget_repository/index.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/user/packages/nuget_repository/index.md')
-rw-r--r--doc/user/packages/nuget_repository/index.md32
1 files changed, 32 insertions, 0 deletions
diff --git a/doc/user/packages/nuget_repository/index.md b/doc/user/packages/nuget_repository/index.md
index a55d69d40fe..9fb50ce71fb 100644
--- a/doc/user/packages/nuget_repository/index.md
+++ b/doc/user/packages/nuget_repository/index.md
@@ -236,3 +236,35 @@ Where:
- `<package_id>` is the package ID.
- `<package_version>` (Optional) is the package version.
+
+## Publishing a NuGet package with CI/CD
+
+> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/36424) in GitLab 13.3.
+
+If you’re using NuGet with GitLab CI/CD, a CI job token can be used instead of a personal access token or deploy token.
+The token inherits the permissions of the user that generates the pipeline.
+
+This example shows how to create a new package each time the `master` branch
+is updated:
+
+1. Add a `deploy` job to your `.gitlab-ci.yml` file:
+
+ ```yaml
+ image: mcr.microsoft.com/dotnet/core/sdk:3.1
+
+ stages:
+ - deploy
+
+ deploy:
+ stage: deploy
+ script:
+ - dotnet restore -p:Configuration=Release
+ - dotnet build -c Release
+ - dotnet pack -c Release
+ - dotnet nuget add source "$CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/packages/nuget/index.json" --name gitlab --username gitlab-ci-token --password $CI_JOB_TOKEN --store-password-in-clear-text
+ - dotnet nuget push "bin/Release/*.nupkg" --source gitlab
+ only:
+ - master
+ ```
+
+1. Commit the changes and push it to your GitLab repository to trigger a new CI build.