2021-10-30 14:50:23 +02:00
# Artifactory
2017-12-02 22:03:06 +02:00
2021-09-28 03:43:00 +02:00
Publish your artifacts to an Artifactory instance.
2017-12-02 22:03:06 +02:00
## How it works
2017-12-10 19:17:29 +02:00
You can declare multiple Artifactory instances.
2017-12-02 22:03:06 +02:00
All binaries generated by your `builds` section will be pushed to
each configured Artifactory.
If you have only one Artifactory instance,
the configuration is as easy as adding the
2022-09-17 05:13:09 +02:00
upload target, and a username to your `.goreleaser.yaml` file:
2017-12-02 22:03:06 +02:00
```yaml
artifactories:
2017-12-09 19:17:37 +02:00
- name: production
2017-12-09 21:54:04 +02:00
target: http://< Your-Instance > :8081/artifactory/example-repo-local/{{ .ProjectName }}/{{ .Version }}/
2017-12-02 22:03:06 +02:00
username: goreleaser
```
Prerequisites:
2018-05-28 15:49:38 +02:00
- A running Artifactory instances
2022-08-12 14:44:54 +02:00
- A user + password / client x509 certificate / API key with grants to upload an artifact
2017-12-02 22:03:06 +02:00
### Target
2017-12-09 21:54:04 +02:00
The `target` is the URL to upload the artifacts to (_without_ the name of the artifact).
2017-12-02 22:03:06 +02:00
2017-12-09 21:54:04 +02:00
An example configuration for `goreleaser` in upload mode `binary` with the target can look like
2017-12-02 22:03:06 +02:00
2018-02-19 01:37:59 +02:00
```yaml
- mode: binary
target: 'http://artifacts.company.com:8081/artifactory/example-repo-local/{{ .ProjectName }}/{{ .Version }}/{{ .Os }}/{{ .Arch }}{{ if .Arm }}{{ .Arm }}{{ end }}'
2017-12-02 22:03:06 +02:00
```
2018-02-19 01:37:59 +02:00
and will result in a final deployment like `http://artifacts.company.com:8081/artifactory/example-repo-local/goreleaser/1.0.0/Darwin/x86_64/goreleaser` .
2017-12-02 22:03:06 +02:00
2018-02-19 01:37:59 +02:00
Supported variables:
2017-12-02 22:03:06 +02:00
2018-05-28 15:49:38 +02:00
- Version
- Tag
- ProjectName
- Os
- Arch
- Arm
2017-12-09 21:54:04 +02:00
2020-05-10 21:57:11 +02:00
!!! info
Variables _Os_ , _Arch_ and _Arm_ are only supported in upload mode `binary` .
2017-12-02 22:03:06 +02:00
2018-08-25 22:26:06 +02:00
### Username
2017-12-02 22:03:06 +02:00
Your configured username needs to be authenticated against your Artifactory.
2022-09-17 05:13:09 +02:00
You can have the username set in the configuration file as shown above, or you
can have it read from an environment variable. The configured name of your
Artifactory instance will be used to build the environment variable name. This
way we support authentication for multiple instances. This also means that the
`name` per configured instance needs to be unique per GoReleaser configuration.
2018-08-25 22:26:06 +02:00
The name of the environment variable will be `ARTIFACTORY_NAME_USERNAME` .
If your instance is named `production` , you can store the username in the
environment variable `ARTIFACTORY_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 / API Key
2023-06-05 18:08:57 +02:00
The password or API key will be stored in an environment variable.
2017-12-20 12:32:21 +02:00
The configured name of your Artifactory instance will be used.
2017-12-09 19:17:37 +02:00
With this way we support auth for multiple instances.
This also means that the `name` per configured instance needs to be unique
per goreleaser configuration.
2017-12-02 22:03:06 +02:00
2017-12-09 19:17:37 +02:00
The name of the environment variable will be `ARTIFACTORY_NAME_SECRET` .
If your instance is named `production` , you need to store the secret in the
environment variable `ARTIFACTORY_PRODUCTION_SECRET` .
The name will be transformed to uppercase.
2017-12-02 22:03:06 +02:00
2022-08-12 14:44:54 +02:00
### Client authorization with x509 certificate (mTLS / mutual TLS)
If your artifactory server supports authorization with mTLS (client certificates), you can provide them by specifying
the location of an x509 certificate/key pair of pem-encode files.
```yaml
artifactories:
- name: production
target: http://< Your-Instance > :8081/artifactory/example-repo-local/{{ .ProjectName }}/{{ .Version }}/
client_x509_cert: path/to/client.cert.pem
client_x509_key: path/to/client.key.pem
```
This will offer the client certificate during the TLS handshake, which your artifactory server may use to authenticate
and authorize you to upload.
2018-09-06 21:19:19 +02:00
### Server authentication
You can authenticate your Artifactory TLS server adding a trusted X.509
certificate chain in your configuration.
The trusted certificate chain will be used to validate the server certificates.
2018-09-08 21:33:46 +02:00
You can set the trusted certificate chain using the `trusted_certificates`
setting the artifactory section with PEM encoded certificates on a YAML literal
block like this:
2018-09-06 21:19:19 +02:00
```yaml
2018-09-08 21:33:46 +02:00
puts:
- name: "some artifactory server with a private TLS certificate"
#...(other settings)...
trusted_certificates: |
-----BEGIN CERTIFICATE-----
MIIDrjCCApagAwIBAgIIShr2zchZo+8wDQYJKoZIhvcNAQENBQAwNTEXMBUGA1UE
...(edited content)...
TyzMJasj5BPZrmKjJb6O/tOtEIJ66xPSBTxPShkEYHnB7A==
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIDrjCCApagAwIBAgIIShr2zchZo+8wDQYJKoZIhvcNAQENBQAwNTEXMBUGA1UE
...(edited content)...
TyzMJasj5BPZrmKjJb6O/tOtEIJ66xPSBTxPShkEYHnB7A==
-----END CERTIFICATE-----
2018-09-06 21:19:19 +02:00
```
2017-12-02 22:03:06 +02:00
## Customization
Of course, you can customize a lot of things:
```yaml
2021-12-23 02:52:01 +02:00
# .goreleaser.yaml
2017-12-02 22:03:06 +02:00
artifactories:
# You can have multiple Artifactory instances.
-
2017-12-09 19:17:37 +02:00
# Unique name of your artifactory instance. Used to identify the instance
name: production
2022-03-19 22:44:34 +02:00
# IDs of the artifacts you want to upload.
ids:
- foo
- bar
# File extensions to filter for.
# This might be useful if you have multiple packages with different
# extensions with the same ID, and need to upload each extension to
# a different place (e.g. nFPM packages).
2022-09-11 21:54:51 +02:00
#
2023-04-02 22:16:21 +02:00
# Since: v1.7
2022-03-19 22:44:34 +02:00
exts:
- deb
- rpm
2017-12-09 21:54:04 +02:00
# Upload mode. Valid options are `binary` and `archive` .
# If mode is `archive` , variables _Os_ , _Arch_ and _Arm_ for target name are not supported.
# In that case these variables are empty.
2023-04-02 22:16:21 +02:00
#
# Default: 'archive'
2017-12-09 21:54:04 +02:00
mode: archive
2022-03-19 22:44:34 +02:00
2017-12-02 22:03:06 +02:00
# URL of your Artifactory instance + path to deploy to
2017-12-09 21:54:04 +02:00
target: http://artifacts.company.com:8081/artifactory/example-repo-local/{{ .ProjectName }}/{{ .Version }}/
2022-03-19 22:44:34 +02:00
2023-04-23 19:22:25 +02:00
# Tells goreleaer not to append the artifact name to the target URL. You must do this manually
custom_artifact_name: true
2017-12-02 22:03:06 +02:00
# User that will be used for the deployment
2017-12-03 00:34:29 +02:00
username: deployuser
2022-03-19 22:44:34 +02:00
2022-08-12 14:44:54 +02:00
# Client certificate and key (when provided, added as client cert to TLS connections)
2023-04-02 22:16:21 +02:00
#
# Since: v1.11
2022-08-12 14:44:54 +02:00
client_x509_cert: /path/to/client.cert.pem
client_x509_key: /path/to/client.key.pem
2023-04-02 22:16:21 +02:00
# Upload checksums.
2018-06-25 07:06:52 +02:00
checksum: true
2022-03-19 22:44:34 +02:00
2023-04-02 22:16:21 +02:00
# Upload signatures.
2018-06-25 07:06:52 +02:00
signature: true
2022-03-19 22:44:34 +02:00
2018-09-08 21:33:46 +02:00
# Certificate chain used to validate server certificates
trusted_certificates: |
-----BEGIN CERTIFICATE-----
MIIDrjCCApagAwIBAgIIShr2zchZo+8wDQYJKoZIhvcNAQENBQAwNTEXMBUGA1UE
...(edited content)...
TyzMJasj5BPZrmKjJb6O/tOtEIJ66xPSBTxPShkEYHnB7A==
-----END CERTIFICATE-----
2017-12-02 22:03:06 +02:00
```
2017-12-10 18:41:57 +02:00
These settings should allow you to push your artifacts into multiple Artifactories.
2022-03-19 22:44:34 +02:00
!!! tip
Learn more about the [name template engine ](/customization/templates/ ).