|
| 1 | +package analytics |
| 2 | + |
| 3 | +import static org.edx.jenkins.dsl.AnalyticsConstants.common_authorization |
| 4 | +import static org.edx.jenkins.dsl.AnalyticsConstants.common_log_rotator |
| 5 | +import static org.edx.jenkins.dsl.AnalyticsConstants.common_publishers |
| 6 | +import static org.edx.jenkins.dsl.AnalyticsConstants.secure_scm_parameters |
| 7 | +import static org.edx.jenkins.dsl.AnalyticsConstants.secure_scm |
| 8 | + |
| 9 | + |
| 10 | +class AmplitudeUserPropertiesBackfill { |
| 11 | + public static def job = { dslFactory, allVars -> |
| 12 | + dslFactory.job("amplitude-user-properties-backfill") { |
| 13 | + logRotator common_log_rotator(allVars) |
| 14 | + authorization common_authorization(allVars) |
| 15 | + parameters secure_scm_parameters(allVars) |
| 16 | + parameters { |
| 17 | + stringParam('ANALYTICS_TOOLS_URL', allVars.get('ANALYTICS_TOOLS_URL'), 'URL for the analytics tools repo.') |
| 18 | + stringParam('ANALYTICS_TOOLS_BRANCH', allVars.get('ANALYTICS_TOOLS_BRANCH'), 'Branch of analytics tools repo to use.') |
| 19 | + stringParam('NOTIFY', allVars.get('NOTIFY','$PAGER_NOTIFY'), 'Space separated list of emails to send notifications to.') |
| 20 | + stringParam('PYTHON_VENV_VERSION', 'python3.7', 'Python virtual environment version to used.') |
| 21 | + stringParam('AMPLITUDE_DATA_SOURCE_TABLE', '', 'Table name that has data which needs to be updated on Amplitude. It should have format like database.schema.table.') |
| 22 | + stringParam('COLUMNS_TO_UPDATE', '', 'Columns that you want to update. Separate multiple columns with commas.') |
| 23 | + stringParam('RESPONSE_TABLE', '', 'Output table which will store the updated data along with response from API endpoint.') |
| 24 | + stringParam('AMPLITUDE_OPERATION_NAME', '', 'Amplitude user property operation name. e.g: set or setOnce.') |
| 25 | + } |
| 26 | + environmentVariables { |
| 27 | + env('KEY_PATH', allVars.get('KEY_PATH')) |
| 28 | + env('PASSPHRASE_PATH', allVars.get('PASSPHRASE_PATH')) |
| 29 | + env('USER', allVars.get('USER')) |
| 30 | + env('ACCOUNT', allVars.get('ACCOUNT')) |
| 31 | + env('AMPLITUDE_VAULT_KV_PATH', allVars.get('AMPLITUDE_VAULT_KV_PATH')) |
| 32 | + env('AMPLITUDE_VAULT_KV_VERSION', allVars.get('AMPLITUDE_VAULT_KV_VERSION')) |
| 33 | + } |
| 34 | + multiscm secure_scm(allVars) << { |
| 35 | + git { |
| 36 | + remote { |
| 37 | + url('$ANALYTICS_TOOLS_URL') |
| 38 | + branch('$ANALYTICS_TOOLS_BRANCH') |
| 39 | + credentials('1') |
| 40 | + } |
| 41 | + extensions { |
| 42 | + relativeTargetDirectory('analytics-tools') |
| 43 | + pruneBranches() |
| 44 | + cleanAfterCheckout() |
| 45 | + } |
| 46 | + } |
| 47 | + } |
| 48 | + wrappers { |
| 49 | + timestamps() |
| 50 | + credentialsBinding { |
| 51 | + usernamePassword('ANALYTICS_VAULT_ROLE_ID', 'ANALYTICS_VAULT_SECRET_ID', 'analytics-vault'); |
| 52 | + } |
| 53 | + } |
| 54 | + publishers common_publishers(allVars) |
| 55 | + steps { |
| 56 | + shell(dslFactory.readFileFromWorkspace('dataeng/resources/amplitude-properties-backfill.sh')) |
| 57 | + } |
| 58 | + } |
| 59 | + } |
| 60 | +} |
0 commit comments