Skip to main content

Package component

The package component builds and optionally publishes packages from a project directory.

Package versions and publish tags

Package builds should use predictable versions and publish tags so consumers can choose a stable release, a default-branch build, or a branch/MR build without guessing which artifact they are installing.

Use this matrix for package types that generate CI package versions or publish tags, including npm packages:

General Matrix

Git refTaggedResulting package versions and tags
mainyesx.x.x SemVer release tag, plus 0.0.0 as latest stable
mainnomain, 0.0.0+main, 0.0.0+<commit_hash>
merge request branchno0.0.0+<commit_hasht>
other-branchyesx.x.x SemVer release tag
other-branchno0.0.0+<commit_hash>

npm Matrix

Git refTaggedPackage versionnpm dist-tag
mainyes, newest stable releasex.x.x SemVer release taglatest
mainyes, older stable releasex.x.x SemVer release tagrelease-x.x.x
mainno0.0.0-sha.<commit_hash>sha.<commit_hash>
merge request branchno0.0.0-sha.<commit_hash>sha.<commit_hash>
other-branchyes, prereleasex.x.x-<prerelease> SemVer prerelease tagprerelease-x.x.x-<prerelease>
other-branchno0.0.0-sha.<commit_hash>sha.<commit_hash>

npm dist-tags cannot be valid SemVer ranges, so generated prerelease versions such as 0.0.0-sha.<commit_hash> are published with the matching install tag sha.<commit_hash>.

npm scope validation

GitLab instance-level npm installs require scoped package names where @scope matches the root namespace that hosts the package. For example, packages hosted below xrow-public/... must use a package name such as @xrow-public/package-name.

When registry: instance is selected, the component enforces that convention before publishing and publishes through the GitLab group npm endpoint. When registry: project or registry: group is selected, the component only warns on a scope mismatch because those endpoints can still publish packages whose scope differs from the root namespace.

.NET packages

.NET projects are handled with type: dotnet. Auto detection selects dotnet when the package path contains a .csproj file or packages.config.

For GitLab package registry restores, the component configures a NuGet package source named GitLab. If you provide your own NuGet.Config, use the same source name:

<packageSources>
<clear />
<add key="GitLab" value="https://gitlab.com/api/v4/projects/<project-id>/packages/nuget/index.json" />
</packageSources>

Credentials for that source are read from the standard NuGet environment variable NuGetPackageSourceCredentials_GitLab. When it is not set, the component fills it from CI_JOB_TOKEN for GitLab CI restores. Publishing uses NUGET_API_KEY when available and otherwise falls back to CI_JOB_TOKEN.

Inputs

NameDescriptionDefaultType
------------
imageBuilder image to use for the build package jobs. Like a S2I Image from the Red Hat Catalog.string
nameName for the package/project.${CI_PROJECT_NAME}string
needsThe jobs that this job depends on.[]array
pathShould the pipeline fail if the test fails?.string
registrySelects the registry to use for the package.projectstring
remote-registry-tokenThe authentication token for the remote registry.string
remote-registry-urlThe URL of the remote registry to use for the package.string
remote-registry-userThe username for the remote registry.string
rulesThe jobs that this job depends on.[{"if":"$CI_PIPELINE_SOURCE == \"schedule\"","when":"never"},{"if":"$CI_PIPELINE_SOURCE == \"merge_request_event\"","when":"never"},{"when":"on_success"}]array
scanning-allow-failureShould the pipeline fail if scanning the built package fails?trueboolean
scanning-enabledShould the package be scanned?trueboolean
scanning-severityWhat level of severity should cause scanning of the built package to fail?CRITICALstring
stageThe pipeline stage that the job will belong to.buildstring
tagsThe runners that this job depends on.[]array
typeautostring