feat(jfrog): add option to customize server id for JFrog CLI (#158)
Co-authored-by: Victor Urvantsev <victoru@jfrog.com>
This commit is contained in:
@@ -19,6 +19,12 @@ variable "jfrog_url" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "jfrog_server_id" {
|
||||||
|
type = string
|
||||||
|
description = "The server ID of the JFrog instance for JFrog CLI configuration"
|
||||||
|
default = "0"
|
||||||
|
}
|
||||||
|
|
||||||
variable "username_field" {
|
variable "username_field" {
|
||||||
type = string
|
type = string
|
||||||
description = "The field to use for the artifactory username. i.e. Coder username or email."
|
description = "The field to use for the artifactory username. i.e. Coder username or email."
|
||||||
@@ -79,6 +85,7 @@ resource "coder_script" "jfrog" {
|
|||||||
script = templatefile("${path.module}/run.sh", {
|
script = templatefile("${path.module}/run.sh", {
|
||||||
JFROG_URL : var.jfrog_url,
|
JFROG_URL : var.jfrog_url,
|
||||||
JFROG_HOST : local.jfrog_host,
|
JFROG_HOST : local.jfrog_host,
|
||||||
|
JFROG_SERVER_ID : var.jfrog_server_id,
|
||||||
ARTIFACTORY_USERNAME : local.username,
|
ARTIFACTORY_USERNAME : local.username,
|
||||||
ARTIFACTORY_EMAIL : data.coder_workspace.me.owner_email,
|
ARTIFACTORY_EMAIL : data.coder_workspace.me.owner_email,
|
||||||
ARTIFACTORY_ACCESS_TOKEN : data.coder_external_auth.jfrog.access_token,
|
ARTIFACTORY_ACCESS_TOKEN : data.coder_external_auth.jfrog.access_token,
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ fi
|
|||||||
# flows.
|
# flows.
|
||||||
export CI=true
|
export CI=true
|
||||||
# Authenticate JFrog CLI with Artifactory.
|
# Authenticate JFrog CLI with Artifactory.
|
||||||
echo "${ARTIFACTORY_ACCESS_TOKEN}" | jf c add --access-token-stdin --url "${JFROG_URL}" --overwrite 0
|
echo "${ARTIFACTORY_ACCESS_TOKEN}" | jf c add --access-token-stdin --url "${JFROG_URL}" --overwrite "${JFROG_SERVER_ID}"
|
||||||
# Set the configured server as the default.
|
# Set the configured server as the default.
|
||||||
jf c use 0
|
jf c use "${JFROG_SERVER_ID}"
|
||||||
|
|
||||||
# Configure npm to use the Artifactory "npm" repository.
|
# Configure npm to use the Artifactory "npm" repository.
|
||||||
if [ -z "${REPOSITORY_NPM}" ]; then
|
if [ -z "${REPOSITORY_NPM}" ]; then
|
||||||
|
|||||||
@@ -23,6 +23,12 @@ variable "jfrog_url" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "jfrog_server_id" {
|
||||||
|
type = string
|
||||||
|
description = "The server ID of the JFrog instance for JFrog CLI configuration"
|
||||||
|
default = "0"
|
||||||
|
}
|
||||||
|
|
||||||
variable "artifactory_access_token" {
|
variable "artifactory_access_token" {
|
||||||
type = string
|
type = string
|
||||||
description = "The admin-level access token to use for JFrog."
|
description = "The admin-level access token to use for JFrog."
|
||||||
@@ -112,6 +118,7 @@ resource "coder_script" "jfrog" {
|
|||||||
script = templatefile("${path.module}/run.sh", {
|
script = templatefile("${path.module}/run.sh", {
|
||||||
JFROG_URL : var.jfrog_url,
|
JFROG_URL : var.jfrog_url,
|
||||||
JFROG_HOST : local.jfrog_host,
|
JFROG_HOST : local.jfrog_host,
|
||||||
|
JFROG_SERVER_ID : var.jfrog_server_id,
|
||||||
ARTIFACTORY_USERNAME : local.username,
|
ARTIFACTORY_USERNAME : local.username,
|
||||||
ARTIFACTORY_EMAIL : data.coder_workspace.me.owner_email,
|
ARTIFACTORY_EMAIL : data.coder_workspace.me.owner_email,
|
||||||
ARTIFACTORY_ACCESS_TOKEN : artifactory_scoped_token.me.access_token,
|
ARTIFACTORY_ACCESS_TOKEN : artifactory_scoped_token.me.access_token,
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ fi
|
|||||||
# flows.
|
# flows.
|
||||||
export CI=true
|
export CI=true
|
||||||
# Authenticate JFrog CLI with Artifactory.
|
# Authenticate JFrog CLI with Artifactory.
|
||||||
echo "${ARTIFACTORY_ACCESS_TOKEN}" | jf c add --access-token-stdin --url "${JFROG_URL}" --overwrite 0
|
echo "${ARTIFACTORY_ACCESS_TOKEN}" | jf c add --access-token-stdin --url "${JFROG_URL}" --overwrite "${JFROG_SERVER_ID}"
|
||||||
# Set the configured server as the default.
|
# Set the configured server as the default.
|
||||||
jf c use 0
|
jf c use "${JFROG_SERVER_ID}"
|
||||||
|
|
||||||
# Configure npm to use the Artifactory "npm" repository.
|
# Configure npm to use the Artifactory "npm" repository.
|
||||||
if [ -z "${REPOSITORY_NPM}" ]; then
|
if [ -z "${REPOSITORY_NPM}" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user