Run Scala/SBT via Databricks Connect from Azure Pipelines

- task: UsePythonVersion@0
  displayName: 'Use Python 3.7'
  inputs:
    versionSpec: 3.7

- script: |
      pip install -U databricks-connect==7.3.8      
  displayName: 'Install Databricks Connect'

- script: |
      echo "y
      <host>
      <token>
      <cluster_id>
      <org_id>
      <port>" | databricks-connect configure      
displayName: 'Configure DBConnect'

# this is important - run dbc get-jar-dir, and set the value back to az pipeline variable
- script: |
      jd=`databricks-connect get-jar-dir`
      echo "##vso[task.setvariable variable=dbcJarDir]$jd"      
  displayName: 'Get DBC Jar Dir'
  
# important - pass jar dir as env variable to SBT
- task: CmdLine@2
  inputs:
    script: sbt run
  env:
    dbcJarDir: '$(dbcJarDir)'

And here is how SBT picks up DBC jar dir:

build.sbt:

// ...

// configure Databricks Connect
val dbcJarDir = sys.env.getOrElse("dbcJarDir", "")
unmanagedBase := new java.io.File(dbcJarDir)

// ...

Em, excuse me! Have Android 📱 and use Databricks? You might be interested in my totally free (and ad-free) Pocket Bricks . You can get it from Google Play too: Get it on Google Play


To contact me, send an email anytime or leave a comment below.