Skip to content

Instantly share code, notes, and snippets.

@pvillard31
Created March 22, 2023 11:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pvillard31/b4249b26029827bc6d9e4406e7fb8bb9 to your computer and use it in GitHub Desktop.
Save pvillard31/b4249b26029827bc6d9e4406e7fb8bb9 to your computer and use it in GitHub Desktop.
deploy.sh for automated deployment of flows via NiFi Registry scripted hook
#!/bin/bash
LOG="/hadoopfs/fs1/automation/nifi-cli.log"
echo $@ >> $LOG
EVENT=$1
BUCKET=$2
FLOW=$3
VERSION=$4
AUTHOR=$5
COMMENT="${@:6}"
# We want to do something only when a new version of a flow is being versioned
if [[ "$EVENT" == "CREATE_FLOW_VERSION" ]]; then
# We want to deploy in production only when the comment contains the keyword "PRODREADY"
if [[ "$COMMENT" == *"PRODREADY"* ]]; then
PG=`grep $FLOW /hadoopfs/fs1/automation/mapping.tsv | awk '{print $2}'`
# echo "Process Group - " $PG >> $LOG
PCP=`grep $FLOW /hadoopfs/fs1/automation/mapping.tsv | awk '{print $3}'`
# echo "Parameter Context Provider - " $PCP >> $LOG
# Upgrade the flow to the latest version
/opt/cloudera/parcels/CFM/TOOLKIT/bin/cli.sh nifi pg-change-version --processGroupId $PG >> $LOG
# Refresh everything with the Parameter Context Provider
/opt/cloudera/parcels/CFM/TOOLKIT/bin/cli.sh nifi fetch-params --paramProviderId $PCP --applyParameters --sensitiveParamPattern "sens_.*" >> $LOG
# Start associated controller services in the process group
/opt/cloudera/parcels/CFM/TOOLKIT/bin/cli.sh nifi pg-enable-services --processGroupId $PG >> $LOG
# Start the process group
/opt/cloudera/parcels/CFM/TOOLKIT/bin/cli.sh nifi pg-start --processGroupId $PG >> $LOG
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment