โ10-10-2024 06:12 AM
Hi
I am trying to use Asset Bundles to deploy a job with email notifications active only on production environment.
I tried to use such if statement but it does not seem to do anything.
resources:
jobs:
Master_Load:
name: Master Load
email_notifications:
${{ if eq(${var.env}, 'prd') }}:
on_failure:
- user1@smth.com
- user2@smth.com
Is it possible to even use if statements in a job definition?
Best!
โ10-10-2024 07:09 AM
Hi @kunex ,
You don't have to use if condition. The recommended approach is to use define "shared" configuration at the top level resources mapping and then when you need environment specific configuration use targets top level-level mapping to override configuration.
The settings in the top-level workspace, artifacts, and resources mappings are used if they are not specified in a targets mapping, but any conflicting settings are overridden by the settings within a target.
โ10-10-2024 07:09 AM
Hi @kunex ,
You don't have to use if condition. The recommended approach is to use define "shared" configuration at the top level resources mapping and then when you need environment specific configuration use targets top level-level mapping to override configuration.
The settings in the top-level workspace, artifacts, and resources mappings are used if they are not specified in a targets mapping, but any conflicting settings are overridden by the settings within a target.
โ10-10-2024 07:46 AM
Thanks @szymon_dybczak
Here it is not that simple, it is not a simple variable but two emails starting with a dash thus i was wondering if i can use if statement, which was btw suggested incorrectly by chatgpt ๐
As a walkaround i could use a variable based on a single email which would be a distribution group containing those people.
โ10-10-2024 08:04 AM
Okay i made it work with a variable, it was pretty easy. The variable accepted multiline text easily.
Thanks!
databricks.yml
targets:
dev:
mode: development
...
variables:
notifications:
default:
- user1@smth.com
- user2@smth.com
job:
resources:
jobs:
Master_Load:
name: Master Load
email_notifications:
on_failure:
${var.notifications}
on_duration_warning_threshold_exceeded:
${var.notifications}
Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโt want to miss the chance to attend and share knowledge.
If there isnโt a group near you, start one and help create a community that brings people together.
Request a New Group