= Twitter

Tweets a new release. You must register a new Twitter application and obtain the set of credentials. Follow the
instructions from link:https://developer.twitter.com/en/portal/projects-and-apps[Twitter] to complete this task.
Note: Remember to set permissions to include Write access and make sure to re-generate access tokens if you changed permissions.

include::partial$legend.adoc[]

[tabs]
====
YAML::
+
[source,yaml]
[subs="+macros"]
----
announce:
  # icon:dot-circle[]
  twitter:

    # Enable or disable this announcer.
    # 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

    # The consumer key.
    # If left unspecified, the `JRELEASER_TWITTER_CONSUMER_KEY`
    # environment variable must be defined.
    # icon:exclamation-triangle[] icon:eye-slash[]
    consumerKey: __DO_NOT_SET_HERE__

    # The consumer token.
    # If left unspecified, the `JRELEASER_TWITTER_CONSUMER_TOKEN`
    # environment variable must be defined.
    # icon:exclamation-triangle[] icon:eye-slash[]
    consumerToken: __DO_NOT_SET_HERE__

    # The access token.
    # If left unspecified, the `JRELEASER_TWITTER_ACCESS_TOKEN`
    # environment variable must be defined.
    # icon:exclamation-triangle[] icon:eye-slash[]
    accessToken: __DO_NOT_SET_HERE__

    # The access token secret.
    # If left unspecified, the `JRELEASER_TWITTER_ACCESS_TOKEN`_SECRET`
    # environment variable must be defined.
    # icon:exclamation-triangle[] icon:eye-slash[]
    accessTokenSecret: __DO_NOT_SET_HERE__

    # The announcement message.
    # Review the available xref:configuration:name-templates.adoc[].
    # icon:dot-circle[] icon:file-alt[]
    status: icon:rocket[] {{projectNameCapitalized}} {{projectVersion}} has been released! {{releaseNotesUrl}}

    # Additional properties used when evaluating templates.
    # icon:dot-circle[] icon:file-alt[]
    extraProperties:
      # Key will be capitalized and prefixed with `twitter`, i.e, `twitterFoo`.
      foo: bar
----
TOML::
+
[source,toml]
[subs="+macros"]
----
# icon:dot-circle[]
[announce.twitter]

  # Enable or disable this announcer.
  # 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

  # The consumer key.
  # If left unspecified, the `JRELEASER_TWITTER_CONSUMER_KEY`
  # environment variable must be defined.
  # icon:exclamation-triangle[] icon:eye-slash[]
  consumerKey = "__DO_NOT_SET_HERE__"

  # The consumer token.
  # If left unspecified, the `JRELEASER_TWITTER_CONSUMER_TOKEN`
  # environment variable must be defined.
  # icon:exclamation-triangle[] icon:eye-slash[]
  consumerToken = "__DO_NOT_SET_HERE__"

  # The access token.
  # If left unspecified, the `JRELEASER_TWITTER_ACCESS_TOKEN`
  # environment variable must be defined.
  # icon:exclamation-triangle[] icon:eye-slash[]
  accessToken = "__DO_NOT_SET_HERE__"

  # The access token secret.
  # If left unspecified, the `JRELEASER_TWITTER_ACCESS_TOKEN`_SECRET`
  # environment variable must be defined.
  # icon:exclamation-triangle[] icon:eye-slash[]
  accessTokenSecret = "__DO_NOT_SET_HERE__"

  # The announcement message.
  # Review the available xref:configuration:name-templates.adoc[].
  # icon:dot-circle[] icon:file-alt[]
  status = "icon:rocket[] {{projectNameCapitalized}} {{projectVersion}} has been released! {{releaseNotesUrl}}"

  # Additional properties used when evaluating templates.
  # icon:dot-circle[] icon:file-alt[]
  extraProperties.foo = "bar"
  # Key will be capitalized and prefixed with `twitter`, i.e, `twitterFoo`.
----
JSON::
+
[source,json]
[subs="+macros"]
----
{
  "announce": {
    // icon:dot-circle[]
    "twitter": {

      // Enable or disable this announcer.
      // 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,

      // The consumer key.
      // If left unspecified, the `JRELEASER_TWITTER_CONSUMER_KEY`
      // environment variable must be defined.
      // icon:exclamation-triangle[] icon:eye-slash[]
      "consumerKey": "__DO_NOT_SET_HERE__",

      // The consumer token.
      // If left unspecified, the `JRELEASER_TWITTER_CONSUMER_TOKEN`
      // environment variable must be defined.
      // icon:exclamation-triangle[] icon:eye-slash[]
      "consumerToken": "__DO_NOT_SET_HERE__",

      // The access token.
      // If left unspecified, the `JRELEASER_TWITTER_ACCESS_TOKEN`
      // environment variable must be defined.
      // icon:exclamation-triangle[] icon:eye-slash[]
      "accessToken": "__DO_NOT_SET_HERE__",

      // The access token secret.
      // If left unspecified, the `JRELEASER_TWITTER_ACCESS_TOKEN`_SECRET`
      // environment variable must be defined.
      // icon:exclamation-triangle[] icon:eye-slash[]
      "accessTokenSecret": "__DO_NOT_SET_HERE__",

      // The announcement message.
      // Review the available xref:configuration:name-templates.adoc[].
      // icon:dot-circle[] icon:file-alt[]
      "status": "icon:rocket[] {{projectNameCapitalized}} {{projectVersion}} has been released! {{releaseNotesUrl}}",

      // Additional properties used when evaluating templates.
      // icon:dot-circle[] icon:file-alt[]
      "extraProperties": {
        // Key will be capitalized and prefixed with `twitter`, i.e, `twitterFoo`.
        "foo": "bar"
      }
    }
  }    
}
----
Maven::
+
[source,xml]
[subs="+macros,verbatim"]
----
<jreleaser>
  <!--
    icon:dot-circle[]
  -->
  <announce>
    <!--
      icon:dot-circle[]
    -->
    <twitter>
      
      <!--
        Enable or disable this announcer.
        Valid values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
        Defaults to `NEVER`.
        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>

      <!--
        The consumer key.
        If left unspecified, the `JRELEASER_TWITTER_CONSUMER_KEY`
        environment variable must be defined.
        icon:exclamation-triangle[] icon:eye-slash[]
      -->
      <consumerKey>__DO_NOT_SET_HERE__</consumerKey>
  
      <!--
        The consumer token.
        If left unspecified, the `JRELEASER_TWITTER_CONSUMER_TOKEN` 
        environment variable must be defined.
        icon:exclamation-triangle[] icon:eye-slash[]
      -->
      <consumerToken>__DO_NOT_SET_HERE__</consumerToken>
  
      <!--
        The access token.
        If left unspecified, the `JRELEASER_TWITTER_ACCESS_TOKEN` 
        environment variable must be defined.
        icon:exclamation-triangle[] icon:eye-slash[]
      -->
      <accessToken>__DO_NOT_SET_HERE__</accessToken>
  
      <!--
        The access token secret.
        If left unspecified, the `JRELEASER_TWITTER_ACCESS_TOKEN`_SECRET`
        environment variable must be defined.
        icon:exclamation-triangle[] icon:eye-slash[]
      -->
      <accessTokenSecret>__DO_NOT_SET_HERE__</accessTokenSecret>
  
      <!--
        The announcement message.
        Review the available xref:configuration:name-templates.adoc[].
        icon:dot-circle[] icon:file-alt[]
      -->
      <status>icon:rocket[] {{projectNameCapitalized}} {{projectVersion}} has been released! {{releaseNotesUrl}}</status>

      <!--
        Additional properties used when evaluating templates.
        icon:dot-circle[] icon:file-alt[]
      -->
      <extraProperties>
        <!--
          Key will be capitalized and prefixed with `twitter`, i.e, `twitterFoo`.
        -->
        <foo>bar</foo>
      </extraProperties>
    </twitter>
  </announce>
</jreleaser>
----
Gradle::
+
[source,groovy]
[subs="+macros"]
----
jreleaser {
  announce {
    // icon:dot-circle[]
    twitter {

      // Enable or disable this announcer.
      // Valid values are [`NEVER`, `ALWAYS`, `RELEASE`, `SNAPSHOT`].
      // Defaults to `NEVER`.
      // icon:dot-circle[]
      active =  true

      // 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

      // The consumer key.
      // If left unspecified, the `JRELEASER_TWITTER_CONSUMER_KEY`
      // environment variable must be defined.
      // icon:exclamation-triangle[] icon:eye-slash[]
      consumerKey = '__DO_NOT_SET_HERE__'

      // The consumer token.
      // If left unspecified, the `JRELEASER_TWITTER_CONSUMER_TOKEN`
      // environment variable must be defined.
      // icon:exclamation-triangle[] icon:eye-slash[]
      consumerToken = '__DO_NOT_SET_HERE__'

      // The access token.
      // If left unspecified, the `JRELEASER_TWITTER_ACCESS_TOKEN`
      // environment variable must be defined.
      // icon:exclamation-triangle[] icon:eye-slash[]
      accessToken = '__DO_NOT_SET_HERE__'

      // The access token secret.
      // If left unspecified, the `JRELEASER_TWITTER_ACCESS_TOKEN`_SECRET`
      // environment variable must be defined.
      // icon:exclamation-triangle[] icon:eye-slash[]
      accessTokenSecret = '__DO_NOT_SET_HERE__'

      // The announcement message.
      // Review the available xref:configuration:name-templates.adoc[].
      // icon:dot-circle[] icon:file-alt[]
      status = 'icon:rocket[] {{projectNameCapitalized}} {{projectVersion}} has been released! {{releaseNotesUrl}}'

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

The template file may be initialized using the `template` command.

