= Http

Uploads artifacts, files, and signatures to an HTTP/HTTPS server

.Prerequisites:

 * A HTTP/HTTPS server that accepts POST/PUT requests.
 * Username + Password/Token if authorization is required.

include::partial$legend.adoc[]

[tabs]
====
YAML::
+
[source,yaml]
[subs="+macros"]
----
# icon:dot-circle[]
upload:
  # icon:dot-circle[]
  http:
    # Uploaders require a name.
    # icon:exclamation-triangle[]
    app:

      # Enables or disables the uploader.
      # Valid values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
      # Defaults to `NEVER`.
      # icon:dot-circle[]
      active: ALWAYS

      # Defines the connection timeout in seconds.
      # Defaults to `20`.
      # icon:dot-circle[]
      connectTimeout: 20

      # Defines the read timeout in seconds.
      # Defaults to `60`.
      # icon:dot-circle[]
      readTimeout: 60

      # URL of the HTTP/HTTPS server + path.
      # icon:exclamation-triangle[] icon:file-alt[]
      target: pass:[https://my.server.com/{{projectName}}/{{tagName}}/{{artifactFileName}}]

      # The username required for authorization.
      # If left unspecified, the `JRELEASER_HTTP_${name}_USERNAME`
      # environment variable must be defined.
      # icon:dot-circle[] icon:eye-slash[]
      username: __DO_NOT_SET_HERE__

      # Password for login into the repository.
      # If left unspecified, the `JRELEASER_HTTP_${name}_PASSWORD`
      # environment variable must be defined.
      # icon:dot-circle[] icon:eye-slash[]
      password: __DO_NOT_SET_HERE__

      # The authorization method to use.
      # Valid values are [`NONE`, `BASIC`, `BEARER`].
      # `Basic` requires both username & password.
      # `BEARER` requires a token (set as password).
      # Defaults to `NONE`.
      # icon:dot-circle[]
      authorization: BASIC

      # The method to use for uploading artifacts.
      # Valid values are [`POST`, `PUT`].
      # Defaults to `PUT`.
      # icon:dot-circle[]
      method: POST

      # Additional headers to be sent to the server.
      # Values accept xref:configuration:name-templates.adoc[].
      # icon:dot-circle[] icon:file-alt[]
      headers:
        'X-ARTIFACT-PLATFORM': '{{artifactPlatform}}'

      # Upload files.
      # Defaults to `true`.
      # icon:dot-circle[]
      files: true

      # Upload distribution artifacts.
      # Defaults to `true`.
      # icon:dot-circle[]
      artifacts: true

      # Upload signatures.
      # Defaults to `true`.
      # icon:dot-circle[]
      signatures: true

      # Additional properties used when evaluating templates.
      # icon:dot-circle[]
      extraProperties:
        # Key will be capitalized and prefixed with `http`, i.e, `httpFoo`.
        foo: bar
----
TOML::
+
[source,toml]
[subs="+macros"]
----
# Uploaders require a name.
# icon:exclamation-triangle[]
[upload.http.app]

  # Enables or disables the uploader.
  # Valid values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
  # Defaults to `NEVER`.
  # icon:dot-circle[]
  active = "ALWAYS"

  # Defines the connection timeout in seconds.
  # Defaults to `20`.
  # icon:dot-circle[]
  connectTimeout = 20

  # Defines the read timeout in seconds.
  # Defaults to `60`.
  # icon:dot-circle[]
  readTimeout = 60

  # URL of the HTTP/HTTPS server + path.
  # The artifact file name will be appended automatically.
  # icon:exclamation-triangle[] icon:file-alt[]
  target = "pass:[https://my.server.com/{{projectName}}/{{tagName}}/{{artifactFileName}}]"

  # The username required for authorization.
  # If left unspecified, the `JRELEASER_HTTP_${name}_USERNAME`
  # environment variable must be defined.
  # icon:dot-circle[] icon:eye-slash[]
  username = "__DO_NOT_SET_HERE__"

  # Password for login into the repository..
  # If left unspecified, the `JRELEASER_HTTP_${name}_PASSWORD`
  # environment variable must be defined.
  # icon:dot-circle[] icon:eye-slash[]
  password = "__DO_NOT_SET_HERE__"

  # The authorization method to use.
  # Valid values are [`NONE`, `BASIC`, `BEARER`].
  # `Basic` requires both username & password.
  # `BEARER` requires a token (set as password).
  # Defaults to `NONE`.
  # icon:dot-circle[]
  authorization = "BASIC"

  # The method to use for uploading artifacts.
  # Valid values are [`POST`, `PUT`].
  # Defaults to `PUT`.
  # icon:dot-circle[]
  method = "POST"

  # Additional headers to be sent to the server.
  # Values accept xref:configuration:name-templates.adoc[].
  # icon:dot-circle[] icon:file-alt[]
  headers."X-ARTIFACT-PLATFORM" = "{{artifactPlatform}}"

  # Upload files.
  # Defaults to `true`.
  # icon:dot-circle[]
  files = true

  # Upload distribution artifacts.
  # Defaults to `true`.
  # icon:dot-circle[]
  artifacts = true

  # Upload signatures.
  # Defaults to `true`.
  # icon:dot-circle[]
  signatures = true

  # Additional properties used when evaluating templates.
  # icon:dot-circle[]
  extraProperties.foo = "bar"
  # Key will be capitalized and prefixed with `http`, i.e, `httpFoo`.
----
JSON::
+
[source,json]
[subs="+macros"]
----
{
  // icon:dot-circle[]
  "upload": {
    // icon:dot-circle[]
    "http": {
      // Uploaders require a name.
      // icon:exclamation-triangle[]
      "app": {

        // Enables or disables the uploader.
        // Valid values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
        // Defaults to `NEVER`.
        // icon:dot-circle[]
        "active": "ALWAYS",

        // Defines the connection timeout in seconds.
        // Defaults to `20`.
        // icon:dot-circle[]
        "connectTimeout": 20,

        // Defines the read timeout in seconds.
        // Defaults to `60`.
        // icon:dot-circle[]
        "readTimeout": 60,

        // URL of the HTTP/HTTPS server + path.
        // The artifact file name will be appended automatically.
        // icon:exclamation-triangle[] icon:file-alt[]
        "target": "pass:[https://my.server.com/{{projectName}}/{{tagName}}/{{artifactFileName}}]",

        // The username required for authorization.
        // If left unspecified, the `JRELEASER_HTTP_${name}_USERNAME`
        // environment variable must be defined.
        // icon:dot-circle[] icon:eye-slash[]
        "username": "__DO_NOT_SET_HERE__",

        // Password for login into the repository.
        // If left unspecified, the `JRELEASER_HTTP_${name}_PASSWORD`
        // environment variable must be defined.
        // icon:dot-circle[] icon:eye-slash[]
        "password": "__DO_NOT_SET_HERE__",

        // The authorization method to use.
        // Valid values are [`NONE`, `BASIC`, `BEARER`].
        // `Basic` requires both username & password.
        // `BEARER` requires a token (set as password).
        // Defaults to `NONE`.
        // icon:dot-circle[]
        "authorization": "BASIC",

        // The method to use for uploading artifacts.
        // Valid values are [`POST`, `PUT`].
        // Defaults to `PUT`.
        // icon:dot-circle[]
        "method": "POST",

        // Additional headers to be sent to the server.
        // Values accept xref:configuration:name-templates.adoc[].
        // icon:dot-circle[] icon:file-alt[]
        "headers": {
          "X-ARTIFACT-PLATFORM": "{{artifactPlatform}}"
        },

        // Upload files.
        // Defaults to `true`.
        // icon:dot-circle[]
        "files": true,

        // Upload distribution artifacts.
        // Defaults to `true`.
        // icon:dot-circle[]
        "artifacts": true,

        // Upload signatures.
        // Defaults to `true`.
        // icon:dot-circle[]
        "signatures": true,

        // Additional properties used when evaluating templates.
        // icon:dot-circle[]
        "extraProperties": {
          // Key will be capitalized and prefixed with `http`, i.e, `httpFoo`.
          "foo": "bar"
        }
      }
    }
  }
}
----
Maven::
+
[source,xml]
[subs="+macros,verbatim"]
----
<jreleaser>
  <!--
    icon:dot-circle[]
  -->
  <upload>
    <!--
      icon:dot-circle[]
    -->
    <http>
      <!--
        Uploaders require a name.
        icon:exclamation-triangle[]
      -->
      <app>
        <!--
          Enables or disables the distribution.
          Valid values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
          Defaults to `ALWAYS`.
          icon:dot-circle[]
        -->
        <active>ALWAYS</active>

        <!--
          Defines the connection timeout in seconds.
          Defaults to `20`.
          icon:dot-circle[]
        -->
        <connectTimeout>20</connectTimeout>

        <!--
          Defines the read timeout in seconds.
          Defaults to `60`.
          icon:dot-circle[]
        -->
        <readTimeout>60</readTimeout>

        <!--
          URL of the HTTP/HTTPS server + path.
          The artifact file name will be appended automatically.
          icon:exclamation-triangle[] icon:file-alt[]
        -->
        <target>pass:[https:my.zulipchat.com/api/v1]</target>

        <!--
          The username required for authorization.
          If left unspecified, the `JRELEASER_HTTP_${name}_USERNAME`
          environment variable must be defined.
          icon:dot-circle[] icon:eye-slash[]
        -->
        <username>__DO_NOT_SET_HERE__</username>

        <!--
          Password for login into the repository.
          If left unspecified, the `JRELEASER_HTTP_${name}_PASSWORD`
          environment variable must be defined.
          icon:dot-circle[] icon:eye-slash[]
        -->
        <password>__DO_NOT_SET_HERE__</password>

        <!--
          The authorization method to use.
          Valid values are [`NONE`, `BASIC`, `BEARER`].
          `Basic` requires both username & password.
          `BEARER` requires a token (set as password).
          Defaults to `NONE`.
          icon:dot-circle[]
        -->
        <authorization>BASIC</authorization>

        <!--
          The method to use for uploading artifacts.
          Valid values are [`POST`, `PUT`].
          Defaults to `PUT`.
          icon:dot-circle[]
        -->
        <method>POST</method>

        <!--
          Additional headers to be sent to the server.
          Values accept xref:configuration:name-templates.adoc[].
          icon:dot-circle[] icon:file-alt[]
        -->
        <headers>
          <X-ARTIFACT-PLATFORM>{{artifactPlatform}}</X-ARTIFACT-PLATFORM>
        </headers>

        <!--
          Upload files.
          Defaults to `true`.
          icon:dot-circle[]
        -->
        <files>true</files>

        <!--
          Upload distribution artifacts.
          Defaults to `true`.
          icon:dot-circle[]
        -->
        <artifacts>true</artifacts>

        <!--
          Upload signatures.
          Defaults to `true`.
          icon:dot-circle[]
        -->
        <signatures>true</signatures>

        <!--
          Additional properties used when evaluating templates.
          icon:dot-circle[]
        -->
        <extraProperties>
          <!--
            Key will be capitalized and prefixed with `http`, i.e, `httpFoo`.
          -->
          <foo>bar</foo>
        </extraProperties>
      </app>
    </http>
  </upload>
</jreleaser>
----
Gradle::
+
[source,groovy]
[subs="+macros"]
----
jreleaser {
  // icon:dot-circle[]
  upload {
    // icon:dot-circle[]
    http {
      // Uploaders require a name.
      // icon:exclamation-triangle[]
      app {

        // Enables or disables the uploader.
        // Valid values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
        // Defaults to `NEVER`.
        // icon:dot-circle[]
        active = 'ALWAYS'

        // Defines the connection timeout in seconds.
        // Defaults to `20`.
        // icon:dot-circle[]
        connectTimeout = 20

        // Defines the read timeout in seconds.
        // Defaults to `60`.
        // icon:dot-circle[]
        readTimeout = 60

        // URL of the HTTP/HTTPS server + path.
        // The artifact file name will be appended automatically.
        // icon:exclamation-triangle[] icon:file-alt[]
        target = 'pass:[https://my.server.com/{{projectName}}/{{tagName}}/{{artifactFileName}}]'

        // The username required for authorization.
        // If left unspecified, the `JRELEASER_HTTP_${name}_USERNAME`
        // environment variable must be defined.
        // icon:dot-circle[] icon:eye-slash[]
        username = '__DO_NOT_SET_HERE__'

        // Password for login into the repository.
        // If left unspecified, the `JRELEASER_HTTP_${name}_PASSWORD`
        // environment variable must be defined.
        // icon:dot-circle[] icon:eye-slash[]
        password = '__DO_NOT_SET_HERE__'

        // The authorization method to use.
        // Valid values are [`NONE`, `BASIC`, `BEARER`].
        // `Basic` requires both username & password.
        // `BEARER` requires a token (set as password).
        // Defaults to `NONE`.
        // icon:dot-circle[]
        authorization = 'BASIC'

        // The method to use for uploading artifacts.
        // Valid values are [`POST`, `PUT`].
        // Defaults to `PUT`.
        // icon:dot-circle[]
        method = 'POST'

        // Additional headers to be sent to the server.
        // Values accept xref:configuration:name-templates.adoc[].
        // icon:dot-circle[] icon:file-alt[]
        headers.put('X-ARTIFACT-PLATFORM', '{{artifactPlatform}}')

        // Upload files.
        // Defaults to `true`.
        // icon:dot-circle[]
        files = true

        // Upload distribution artifacts.
        // Defaults to `true`.
        // icon:dot-circle[]
        artifacts = true

        // Upload signatures.
        // Defaults to `true`.
        // icon:dot-circle[]
        signatures = true

        // Additional properties used when evaluating templates.
        // Key will be capitalized and prefixed with `http`, i.e, `httpFoo`.
        // icon:dot-circle[]
        extraProperties.put('foo', 'bar')
      }
    }
  }
}
----
====

== Target

The target is the URL to upload the artifacts to.

An example configuration can look like
`target: 'https://artifacts.company.com:8081/upload/{{projectName}}/{{tagName}}/{{artifactFileName}}'`.

And will result in a final deployment like
`pass:[https://artifacts.company.com:8081/upload/app/v1.0.0/app-1.0.0.zip]`.

== Username

You can have the username set in the configuration as shown above or you can have it read from an environment variable.
The configured name of the HTTP 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_HTTP_NAME_USERNAME`. If your instance is named `production`,
you can store the username in the environment variable `JRELEASER_HTTP_PRODUCTION_USERNAME`. The name will be
transformed to uppercase.

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

== Password

The password will be stored in an environment variable. The configured name of the HTTP 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_HTTP_NAME_PASSWORD`. If your instance is named `production`,
you need to store the secret in the environment variable `JRELEASER_HTTP_PRODUCTION_PASSWORD`. The name will be
transformed to uppercase.

