温馨提示:本文翻译自stackoverflow.com,查看原文请点击:bash - How do I use databricks-cli without manual configuration

bash - 如何在不进行手动配置的情况下使用databricks-cli

发布于 2020-03-29 13:13:32

我想使用databricks cli:

databricks clusters list

但这需要一个手动步骤,需要与用户进行交互工作:

databricks configure --token

有没有一种方法可以使用databricks cli而无需人工干预,以便可以将其作为ci / cd管道的一部分运行?

查看更多

提问者
Mor Shemesh
被浏览
71
Mor Shemesh 2018-08-14 16:34

以下bash脚本自动配置了databricks cli:

echo "configuring databrick-cli authentication"

declare DATABRICKS_URL="https://westeurope.azuredatabricks.net"
declare DATABRICKS_ACCESS_TOKEN="authentication_token_generated_from_databricks_ux"

declare dbconfig=$(<~/.databrickscfg)
if [[ $dbconfig = *"host = "* && $dbconfig = *"token = "* ]]; then
  echo "file [~/.databrickscfg] is already configured"
else
  if [[ -z "$DATABRICKS_URL" || -z "$DATABRICKS_ACCESS_TOKEN" ]]; then
    echo "file [~/.databrickscfg] is not configured, but [DATABRICKS_URL],[DATABRICKS_ACCESS_TOKEN] env vars are not set"
  else
    echo "populating [~/.databrickscfg]"
    > ~/.databrickscfg
    echo "[DEFAULT]" >> ~/.databrickscfg
    echo "host = $DATABRICKS_URL" >> ~/.databrickscfg
    echo "token = $DATABRICKS_ACCESS_TOKEN" >> ~/.databrickscfg
    echo "" >> ~/.databrickscfg
  fi
fi

发布
问题

分享
好友

手机
浏览

扫码手机浏览