GitLab

Uploads artifacts, files, and signatures to a GitLab instance via its Packages option.

NOTE

Only generic packages are supported at the moment.

Legend:

  • required

  • optional

  • may use environment variable

  • accepts Name Templates

  • YAML

  • TOML

  • JSON

  • Maven

  • Gradle

# 
upload:
  # 
  gitlab:
    # Uploaders require a name.
    # 
    app:

      # Enables or disables the uploader.
      # Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
      # Defaults to `NEVER`.
      # 
      active: ALWAYS

      # Defines the connection timeout in seconds.
      # Defaults to `20`.
      # 
      connectTimeout: 20

      # Defines the read timeout in seconds.
      # Defaults to `60`.
      # 
      readTimeout: 60

      # Upload files.
      # Defaults to `true`.
      # 
      files: true

      # Upload distribution artifacts.
      # Defaults to `true`.
      # 
      artifacts: true

      # Release checksum files.
      # Defaults to `true`.
      # 
      checksums: true

      # Upload signatures.
      # Defaults to `true`.
      # 
      signatures: true

      # Additional properties used when evaluating templates.
      # 
      extraProperties:
        # Key will be capitalized and prefixed with `gitlab`, i.e, `gitlabFoo`.
        foo: bar

      # The GitLab host url.
      # 
      host: gitlab.com

      # Token with write access to the repository.
      # If left unspecified, the `JRELEASER_GITLAB_${name}_TOKEN`
      # environment variable must be defined.
      #  
      token: __DO_NOT_SET_HERE__

      # The package name to use.
      # If unspecified, will use the uploader's name.
      #  
      packageName: app

      # The package version to use.
      # If unspecified, will use the project's version.
      #  
      packageVersion: '{{projectVersion}}'

      # The id of the GitLab repository.
      # 
      projectIdentifier: 12345678
# Uploaders require a name.
# 
[upload.gitlab.app]

  # Enables or disables the uploader.
  # Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
  # Defaults to `NEVER`.
  # 
  active = "ALWAYS"

  # Defines the connection timeout in seconds.
  # Defaults to `20`.
  # 
  connectTimeout = 20

  # Defines the read timeout in seconds.
  # Defaults to `60`.
  # 
  readTimeout = 60

  # Upload files.
  # Defaults to `true`.
  # 
  files = true

  # Upload distribution artifacts.
  # Defaults to `true`.
  # 
  artifacts = true

  # Release checksum files.
  # Defaults to `true`.
  # 
  checksums = true

  # Upload signatures.
  # Defaults to `true`.
  # 
  signatures = true

  # Additional properties used when evaluating templates.
  # 
  extraProperties.foo = "bar"
  # Key will be capitalized and prefixed with `gitlab`, i.e, `gitlabFoo`.

  # The GitLab host url.
  # 
  host = "gitlab.com"

  # Token with write access to the repository.
  # If left unspecified, the `JRELEASER_GITLAB_${name}_TOKEN`
  # environment variable must be defined.
  #  
  token = "__DO_NOT_SET_HERE__"

  # The package name to use.
  # If unspecified, will use the uploader's name.
  #  
  packageName = "app"

  # The package version to use.
  # If unspecified, will use the project's version.
  #  
  packageVersion = "{{projectVersion}}"

  # The id of the GitLab repository.
  # 
  projectIdentifier = "12345678"
{
  // 
  "upload": {
    // 
    "gitlab": {
      // Uploaders require a name.
      // 
      "app": {

        // Enables or disables the uploader.
        // Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
        // Defaults to `NEVER`.
        // 
        "active": "ALWAYS",

        // Defines the connection timeout in seconds.
        // Defaults to `20`.
        // 
        "connectTimeout": 20,

        // Defines the read timeout in seconds.
        // Defaults to `60`.
        // 
        "readTimeout": 60,

        // Upload files.
        // Defaults to `true`.
        // 
        "files": true,

        // Upload distribution artifacts.
        // Defaults to `true`.
        // 
        "artifacts": true,

        // Release checksum files.
        // Defaults to `true`.
        // 
        "checksums": true,

        // Upload signatures.
        // Defaults to `true`.
        // 
        "signatures": true,

        // Additional properties used when evaluating templates.
        // 
        "extraProperties": {
          // Key will be capitalized and prefixed with `gitlab`, i.e, `gitlabFoo`.
          "foo": "bar"
        },

        // The GitLab host url.
        // 
        "host": "gitlab.com",

        // Token with write access to the repository.
        // If left unspecified, the `JRELEASER_GITLAB_${name}_TOKEN`
        // environment variable must be defined.
        //  
        "token": "__DO_NOT_SET_HERE__",

        // The package name to use.
        // If unspecified, will use the uploader's name.
        //  
        "packageName": "app",

        // The package version to use.
        // If unspecified, will use the project's version.
        //  
        "packageVersion": "{{projectVersion}}",

        // The id of the GitLab repository.
        // 
        "projectIdentifier": "12345678"
      }
    }
  }
}
<jreleaser>
  <!--
    
  -->
  <upload>
    <!--
      
    -->
    <gitlab>
      <!--
        Uploaders require a name.
        
      -->
      <app>
        <!--
          Enables or disables the distribution.
          Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
          Defaults to `NEVER`.
          
        -->
        <active>ALWAYS</active>

        <!--
          Defines the connection timeout in seconds.
          Defaults to `20`.
          
        -->
        <connectTimeout>20</connectTimeout>

        <!--
          Defines the read timeout in seconds.
          Defaults to `60`.
          
        -->
        <readTimeout>60</readTimeout>

        <!--
          Upload files.
          Defaults to `true`.
          
        -->
        <files>true</files>

        <!--
          Upload distribution artifacts.
          Defaults to `true`.
          
        -->
        <artifacts>true</artifacts>

        <!--
          Release checksum files.
          Defaults to `true`.
          
        -->
        <checksums>true</checksums>

        <!--
          Upload signatures.
          Defaults to `true`.
          
        -->
        <signatures>true</signatures>

        <!--
          Additional properties used when evaluating templates.
          
        -->
        <extraProperties>
          <!--
            Key will be capitalized and prefixed with `gitlab`, i.e, `gitlabFoo`.
          -->
          <foo>bar</foo>
        </extraProperties>

        <!--
           The GitLab host url.
           
        -->
        <host>gitlab.com</host>

        <!--
           Token with write access to the repository.
           If left unspecified, the `JRELEASER_GITLAB_${name}_TOKEN`
           environment variable must be defined.
            
        -->
        <token>__DO_NOT_SET_HERE__</token>

        <!--
           The package name to use.
           If unspecified, will use the uploader's name.
            
        -->
        <packageName>app</packageName>

        <!--
           The package version to use.
           If unspecified, will use the project's version.
            
        -->
        <packageVersion>{{projectVersion}}</packageVersion>

        <!--
           The id of the GitLab repository.
           
        -->
        <projectIdentifier>12345678</projectIdentifier>
      </app>
    </gitlab>
  </upload>
</jreleaser>
jreleaser {
  // 
  upload {
    // 
    gitlab {
      // Uploaders require a name.
      // 
      app {

        // Enables or disables the uploader.
        // Supported values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
        // Defaults to `NEVER`.
        // 
        active = 'ALWAYS'

        // Defines the connection timeout in seconds.
        // Defaults to `20`.
        // 
        connectTimeout = 20

        // Defines the read timeout in seconds.
        // Defaults to `60`.
        // 
        readTimeout = 60

        // Upload files.
        // Defaults to `true`.
        // 
        files = true

        // Upload distribution artifacts.
        // Defaults to `true`.
        // 
        artifacts = true

        // Release checksum files.
        // Defaults to `true`.
        // 
        checksums = true

        // Upload signatures.
        // Defaults to `true`.
        // 
        signatures = true

        // Additional properties used when evaluating templates.
        // Key will be capitalized and prefixed with `gitlab`, i.e, `gitlabFoo`.
        // 
        extraProperties.put('foo', 'bar')

        // The GitLab host url.
        // 
        host = 'gitlab.com'

        // Token with write access to the repository.
        // If left unspecified, the `JRELEASER_GITLAB_${name}_TOKEN`
        // environment variable must be defined.
        //  
        token = '__DO_NOT_SET_HERE__'

        // The package name to use.
        // If unspecified, will use the uploader's name.
        //  
        packageName = 'app'

        // The package version to use.
        // If unspecified, will use the project's version.
        //  
        packageVersion = '{{projectVersion}}'

        // The id of the GitLab repository.
        // 
        projectIdentifier = '12345678'
      }
    }
  }
}

Host

You can have the host set in the configuration as shown above, or you can have it read from an environment variable. The configured name of the GitLab server will be used to build the environment variable name. This means that the name per configured instance needs to be unique.

The name of the environment variable will be JRELEASER_GITLAB_NAME_HOST. If your instance is named production, you can store the host in the environment variable JRELEASER_GITLAB_PRODUCTION_HOST. The name will be transformed to uppercase.

If a configured host is found in the configuration file, then the environment variable is not used at all.

Alternatives to JRELEASER_GITLAB_NAME_HOST are (in order):

  • JRELEASER_GITLAB_NAME_HOST

  • JRELEASER_GITLAB_HOST

Token

The password will be stored in an environment variable. The configured name of the GitLab server will be used. This means that the name per configured instance needs to be unique.

The name of the environment variable will be JRELEASER_GITLAB_NAME_TOKEN. If your instance is named production, you need to store the secret in the environment variable JRELEASER_GITLAB_PRODUCTION_TOKEN. The name will be transformed to uppercase.

Alternatives to JRELEASER_GITLAB_NAME_TOKEN are (in order):

  • JRELEASER_GITLAB_NAME_TOKEN

  • JRELEASER_GITLAB_TOKEN

UploadUrl

The uploadUrl is the URL to upload the artifacts to.

An example configuration may look like uploadUrl: 'https://{{host}}/api/v4/projects/{{projectIdentifier}}/packages/generic/{{packageName}}/{{packageVersion}}/{{artifactFile}}'.

And will result in a final deployment like https://gitlab.com/api/v4/projects/12345678/packages/generic/app/1.0.0/app-1.0.0.zip.

DownloadUrl

The downloadUrl is the URL used to download artifacts from.

An example configuration may look like downloadUrl: 'https://{{host}}/api/v4/projects/{{projectIdentifier}}/packages/generic/{{packageName}}/{{packageVersion}}/{{artifactFile}}'.

And will result in a final URL like https://gitlab.com/api/v4/projects/12345678/packages/generic/app/1.0.0/app-1.0.0.zip.

Skip Upload

Distributions and Artifacts may define extra properties that may stop them from being uploaded. These properties must conform to the following rules:

  • skipUpload: skipped from all uploaders.

  • skipUpload<type>: skipped from the typed uploader.

  • skipUpload<type><name>: skipped from the typed and named uploader.

Where <type> resolves to Gitlab and <name> resolves to the capitalized name of the GitLab instance, such that:

  • if the name is foo the resulting property key is skipUploadGitlabFoo.

  • if the name is fooBar the resulting property key is skipUploadGitlabFooBar.

  • if the name is foo-bar the resulting property key is skipUploadGitlabFooBar.