...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<?xml version="1.0" encoding="UTF-8"?> <ns0:WorkFlow xmlns:ns1="http://flexagon.com/flexdeploy/workflow/common" xmlns:ns0="http://flexagon.com/flexdeploy/workflow"> <ns1:Name>Deploy Resources</ns1:Name> <ns1:Description>Performs change detection of properties files.</ns1:Description> <ns0:Inputs/> <ns0:Variables> <ns0:Variable> <ns1:Name>ChangesDetected</ns1:Name> <ns1:Type>String</ns1:Type> <ns0:returnAsOutput>false</ns0:returnAsOutput> <ns1:isConstant>false</ns1:isConstant> </ns0:Variable> </ns0:Variables> <ns0:Steps> <ns0:Step> <ns1:Name>Prepare Files for Deployment</ns1:Name> <ns1:StepId>1</ns1:StepId> <ns0:InvokePlugin> <ns0:PluginName>FlexagonShellPlugin</ns0:PluginName> <ns0:PluginOperation>execute</ns0:PluginOperation> <ns0:consumesArtifacts>true</ns0:consumesArtifacts> <ns0:producesArtifacts>false</ns0:producesArtifacts> <ns0:EndpointSelection> <ns0:EndpointSelectionChoice>All</ns0:EndpointSelectionChoice> </ns0:EndpointSelection> <ns0:EndpointExecutionChoice>Any</ns0:EndpointExecutionChoice> <ns0:PluginInputs> <ns0:PluginInput> <ns0:Name>FDSHELL_INP_CODE_SNIPPET</ns0:Name> <ns0:ValueType>Text</ns0:ValueType> <ns0:Encrypted>false</ns0:Encrypted> <ns1:Type>String</ns1:Type> <ns0:Text>cd $FD_TEMP_DIR cd ../.. PROJECT_ID=`pwd | awk -F'/' '{print $NF}'` STATE_FOLDER=`echo $FD_TEMP_DIR/../../../../wlresources/$PROJECT_ID` mkdir -p $STATE_FOLDER DEPLOY_FOLDER=$FD_TEMP_DIR/resources mkdir -p $DEPLOY_FOLDER changesdetected=no cd $FD_ARTIFACTS_DIR files=`ls *.properties` for file in $files do echo $file - see if it needs to be deployed mainfilechanged=yes envfilechanged=no diff $file $STATE_FOLDER/$file 1>/dev/null 2>/dev/null if [[ "$?" == "0" ]] then mainfilechanged=no echo ---- $file NOT changed since last deployment. else echo ++++ $file changed since last deployment. fi if [[ -f $FD_ENVIRONMENT_CODE/$file ]] then diff $FD_ENVIRONMENT_CODE/$file $STATE_FOLDER/$FD_ENVIRONMENT_CODE/$file 1>/dev/null 2>/dev/null if [[ "$?" != "0" ]] then envfilechanged=yes echo ++++ $FD_ENVIRONMENT_CODE/$file changed since last deployment. else echo ---- $FD_ENVIRONMENT_CODE/$file NOT changed since last deployment. fi fi if [[ $mainfilechanged == "yes" || $envfilechanged == "yes" ]] then echo $file - wll be deployed changesdetected=yes cp $file $DEPLOY_FOLDER/$file if [[ -f $FD_ENVIRONMENT_CODE/$file ]] then cp $FD_ENVIRONMENT_CODE/$file $DEPLOY_FOLDER/$FD_ENVIRONMENT_CODE/$file fi else echo $file - wll NOT be deployed fi done setOutput CHANGES_DETECTED $changesdetected</ns0:Text> </ns0:PluginInput> <ns0:PluginInput> <ns0:Name>FDSHELL_INP_STOP_ON_ERROR</ns0:Name> <ns0:ValueType>Text</ns0:ValueType> <ns0:Encrypted>false</ns0:Encrypted> <ns1:Type>Boolean</ns1:Type> <ns0:Text>false</ns0:Text> </ns0:PluginInput> <ns0:PluginInput> <ns0:Name>FDSHELL_INP_DISABLE_ECHO</ns0:Name> <ns0:ValueType>Text</ns0:ValueType> <ns0:Encrypted>false</ns0:Encrypted> <ns1:Type>Boolean</ns1:Type> <ns0:Text>true</ns0:Text> </ns0:PluginInput> <ns0:PluginInput> <ns0:Name>FDSHELL_INP_RESTRICT_ENVIRONMENT</ns0:Name> <ns0:ValueType>Expression</ns0:ValueType> <ns0:Encrypted>false</ns0:Encrypted> <ns1:Type>String</ns1:Type> <ns0:Value> <ns0:Expression>FD_INSTANCE_CODE</ns0:Expression> </ns0:Value> </ns0:PluginInput> <ns0:PluginInput> <ns0:Name>FDSHELL_INP_NO_SECURE_VARIABLES</ns0:Name> <ns0:ValueType>Text</ns0:ValueType> <ns0:Encrypted>false</ns0:Encrypted> <ns1:Type>Boolean</ns1:Type> <ns0:Text>true</ns0:Text> </ns0:PluginInput> </ns0:PluginInputs> <ns0:UserInputs/> <ns0:PluginOutputs/> <ns0:UserOutputs> <ns0:OutputValue> <ns0:NameInCallee>CHANGES_DETECTED</ns0:NameInCallee> <ns0:NameInCaller>ChangesDetected</ns0:NameInCaller> </ns0:OutputValue> </ns0:UserOutputs> </ns0:InvokePlugin> </ns0:Step> <ns0:Step> <ns1:Name>Changes Detected</ns1:Name> <ns1:StepId>2</ns1:StepId> <ns0:If> <ns0:Condition> <ns0:Expression>"yes".equals(ChangesDetected)</ns0:Expression> </ns0:Condition> <ns0:Steps> <ns0:Step> <ns1:Name>Create or Update WebLogic Configurations</ns1:Name> <ns1:StepId>2.1</ns1:StepId> <ns0:InvokePlugin> <ns0:PluginName>FlexagonWeblogicPlugin</ns0:PluginName> <ns0:PluginOperation>createOrUpdateWeblogicConfig</ns0:PluginOperation> <ns0:consumesArtifacts>false</ns0:consumesArtifacts> <ns0:producesArtifacts>false</ns0:producesArtifacts> <ns0:PluginInputs> <ns0:PluginInput> <ns0:Name>FILE_PATH_TO_PROPERTIES</ns0:Name> <ns0:ValueType>Expression</ns0:ValueType> <ns0:Encrypted>false</ns0:Encrypted> <ns1:Type>String</ns1:Type> <ns0:Value> <ns0:Expression>FD_TEMP_DIR + "/resources"</ns0:Expression> </ns0:Value> </ns0:PluginInput> </ns0:PluginInputs> <ns0:UserInputs/> <ns0:PluginOutputs> <ns0:OutputValue> <ns0:NameInCallee>FDWLS_OUT_IS_RESTART_REQUIRED</ns0:NameInCallee> </ns0:OutputValue> <ns0:OutputValue> name: Deploy Resources description: Performs change detection of properties files. inputs: [] variables: - code: ChangesDetected dataType: String returnAsOutput: false constant: false encrypted: false scope: LOCAL steps: - id: '1' name: Prepare Files for Deployment type: INVOKE_PLUGIN data: pluginName: FlexagonShellPlugin pluginOperation: execute endpointInstanceOverride: isExpression: false consumesArtifacts: true producesArtifacts: false endpointSelection: choice: All endpointExecution: choice: Any stopOnError: false inputs: - name: FDSHELL_INP_CODE_SNIPPET value: value: "cd $FD_TEMP_DIR\ncd ../..\nPROJECT_ID=`pwd | <ns0:NameInCallee>DATASOURCES_CREATED</ns0:NameInCallee>awk -F'/' '{print $NF}'`\n\ STATE_FOLDER=`echo $FD_TEMP_DIR/../../../../wlresources/$PROJECT_ID`\nmkdir\ \ </ns0:OutputValue> -p $STATE_FOLDER\nDEPLOY_FOLDER=$FD_TEMP_DIR/resources\nmkdir -p $DEPLOY_FOLDER\n\ \ \nchangesdetected=no\n \ncd $FD_ARTIFACTS_DIR\nfiles=`ls *.properties`\n\ <ns0:OutputValue> for file in $files\ndo\n echo $file - see if it needs to be deployed\n\ <ns0:NameInCallee>EIS_ENTRIES_CREATED</ns0:NameInCallee> \ mainfilechanged=yes\n envfilechanged=no\n \n diff $file </ns0:OutputValue>$STATE_FOLDER/$file\ \ 1>/dev/null 2>/dev/null\n if [[ \"$?\" == \"0\" ]]\n <ns0:OutputValue> then\n \ \ mainfilechanged=no\n <ns0:NameInCallee>JMS_OBJECTS_CREATED</ns0:NameInCallee> echo ---- $file NOT changed since last\ \ deployment.\n else\n </ns0:OutputValue> echo ++++ $file changed since last deployment.\n\ \ <ns0:OutputValue> fi\n \n if [[ -f $FD_ENVIRONMENT_CODE/$file ]]\n then\n \ <ns0:NameInCallee>WORK_MANAGERS_CREATED</ns0:NameInCallee> \ diff $FD_ENVIRONMENT_CODE/$file $STATE_FOLDER/$FD_ENVIRONMENT_CODE/$file\ \ </ns0:OutputValue>1>/dev/null 2>/dev/null\n if [[ \"$?\" != \"0\" ]]\n </ns0:PluginOutputs>then\n\ \ <ns0:UserOutputs/> envfilechanged=yes\n </ns0:InvokePlugin> echo ++++ $FD_ENVIRONMENT_CODE/$file\ </ns0:Step>\ changed since last deployment.\n else\n <ns0:Step> echo ---- $FD_ENVIRONMENT_CODE/$file\ <ns1:Name>Copy Files to State Folder</ns1:Name> \ NOT changed since last deployment.\n fi\n fi\n <ns1:StepId>2.2</ns1:StepId> \n if\ \ <ns0:InvokePlugin>[[ $mainfilechanged == \"yes\" || $envfilechanged == \"yes\" ]]\n then\n\ <ns0:PluginName>FlexagonShellPlugin</ns0:PluginName> \ echo $file - wll be deployed\n <ns0:PluginOperation>execute</ns0:PluginOperation> changesdetected=yes\n \ \ cp <ns0:consumesArtifacts>false</ns0:consumesArtifacts>$file $DEPLOY_FOLDER/$file\n if [[ -f $FD_ENVIRONMENT_CODE/$file\ <ns0:producesArtifacts>false</ns0:producesArtifacts>\ ]]\n then\n cp <ns0:EndpointSelection>$FD_ENVIRONMENT_CODE/$file $DEPLOY_FOLDER/$FD_ENVIRONMENT_CODE/$file\n\ \ fi\n else\n <ns0:EndpointSelectionChoice>All</ns0:EndpointSelectionChoice> echo $file - wll NOT be deployed\n fi\n\ </ns0:EndpointSelection> \ \ndone\n \nsetOutput CHANGES_DETECTED $changesdetected" <ns0isExpression:EndpointExecutionChoice>Any</ns0:EndpointExecutionChoice> false isEncrypted: false - <ns0:PluginInputs>name: FDSHELL_INP_STOP_ON_ERROR value: value: 'false' <ns0isExpression:PluginInput> false isEncrypted: false - name: FDSHELL_INP_DISABLE_ECHO value: <ns0:Name>FDSHELL_INP_CODE_SNIPPET</ns0:Name> value: 'true' isExpression: false isEncrypted: false - <ns0name:ValueType>Text</ns0:ValueType> FDSHELL_INP_RESTRICT_ENVIRONMENT value: value: FD_INSTANCE_CODE <ns0:Encrypted>false</ns0:Encrypted> isExpression: true isEncrypted: false - name: FDSHELL_INP_NO_SECURE_VARIABLES <ns1:Type>String</ns1:Type>value: value: 'true' isExpression: false isEncrypted: <ns0:Text>cd $FD_TEMP_DIR cd ../.. PROJECT_ID=`pwd | awk -F'/' '{print $NF}'` STATE_FOLDER=`echo $FD_TEMP_DIR/../../../../wlresources/$PROJECT_ID` echo 'Clear $STATE_FOLDER and refresh with new artifacts for next deployment' rm -rf $STATE_FOLDER mkdir -p $STATE_FOLDER cd $FD_ARTIFACTS_DIR cp -R * $STATE_FOLDER</ns0:Text> </ns0:PluginInput> false outputs: [] userInputs: [] userOutputs: - output: CHANGES_DETECTED variable: ChangesDetected - id: '2' name: Changes Detected type: IF data: condition: '"yes".equals(ChangesDetected)' elseIfBlock: [] steps: - id: '2.1' name: Create or Update WebLogic <ns0:PluginInput>Configurations type: INVOKE_PLUGIN data: pluginName: FlexagonWeblogicPlugin <ns0:Name>FDSHELL_INP_STOP_ON_ERROR</ns0:Name> pluginOperation: createOrUpdateWeblogicConfig endpointInstanceOverride: <ns0:ValueType>Text</ns0:ValueType> isExpression: false consumesArtifacts: true producesArtifacts: false <ns0:Encrypted>false</ns0:Encrypted> endpointSelection: choice: All endpointExecution: <ns1:Type>Boolean</ns1:Type> choice: Any stopOnError: false <ns0inputs:Text>true</ns0:Text> - name: FILE_PATH_TO_PROPERTIES value: </ns0:PluginInput> value: FD_TEMP_DIR + "/resources" <ns0isExpression:PluginInput> true isEncrypted: false outputs: <ns0:Name>FDSHELL_INP_DISABLE_ECHO</ns0:Name> - output: FDWLS_OUT_IS_RESTART_REQUIRED - output: DATASOURCES_CREATED - output: EIS_ENTRIES_CREATED <ns0:ValueType>Text</ns0:ValueType> - output: JMS_OBJECTS_CREATED - output: WORK_MANAGERS_CREATED <ns0:Encrypted>false</ns0:Encrypted> userInputs: [] userOutputs: [] - id: '2.2' name: <ns1:Type>Boolean</ns1:Type> Copy Files to State Folder type: INVOKE_PLUGIN data: <ns0pluginName:Text>false</ns0:Text> FlexagonShellPlugin pluginOperation: execute endpointInstanceOverride: </ns0:PluginInput> isExpression: false consumesArtifacts: false <ns0producesArtifacts:PluginInput> false endpointSelection: choice: All <ns0:Name>FDSHELL_INP_RESTRICT_ENVIRONMENT</ns0:Name> endpointExecution: choice: Any <ns0:ValueType>Expression</ns0:ValueType> stopOnError: false inputs: - name: FDSHELL_INP_CODE_SNIPPET <ns0:Encrypted>false</ns0:Encrypted> value: value: |- <ns1:Type>String</ns1:Type> cd $FD_TEMP_DIR cd ../.. <ns0:Value> PROJECT_ID=`pwd | awk -F'/' '{print $NF}'` <ns0:Expression>FD_INSTANCE_CODE</ns0:Expression>STATE_FOLDER=`echo $FD_TEMP_DIR/../../../../wlresources/$PROJECT_ID` echo 'Clear $STATE_FOLDER and refresh with new artifacts for next deployment' </ns0:Value> rm -rf $STATE_FOLDER </ns0:PluginInput> mkdir -p $STATE_FOLDER <ns0:PluginInput>cd $FD_ARTIFACTS_DIR cp -R * $STATE_FOLDER <ns0:Name>FDSHELL_INP_NO_SECURE_VARIABLES</ns0:Name> isExpression: false isEncrypted: false <ns0:ValueType>Text</ns0:ValueType> - name: FDSHELL_INP_STOP_ON_ERROR value: value: 'true' <ns0:Encrypted>false</ns0:Encrypted> isExpression: false isEncrypted: false <ns1:Type>Boolean</ns1:Type> - name: FDSHELL_INP_DISABLE_ECHO value: <ns0:Text>true</ns0:Text> value: 'false' isExpression: false </ns0:PluginInput> isEncrypted: false - name: FDSHELL_INP_RESTRICT_ENVIRONMENT </ns0:PluginInputs> value: value: FD_INSTANCE_CODE <ns0:UserInputs/> isExpression: true <ns0:PluginOutputs/>isEncrypted: false - name: FDSHELL_INP_NO_SECURE_VARIABLES <ns0value:UserOutputs/> value: 'true' </ns0:InvokePlugin> isExpression: false </ns0:Step> isEncrypted: false </ns0outputs:Steps> [] </ns0userInputs:If> [] </ns0:Step> </ns0userOutputs:Steps> </ns0:WorkFlow> [] |
Now you can use this workflow on your WebLogic resources project. Here is what workflow design looks like.
WebLogic plugin createOrUpdateWeblogicConfig operation is used to perform deployment. But there are two shell plugin operations used, 1) Find changed files 2) update state folder with latest files that were deployed.
...