Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

This is just a recommendation and you should try this in your environment to see if it works correctly.

Approach

  • WebLogic resource properties file will be copied to <Endpoint Working Directory>/wlresources/<Project Id> at the end of successful deployment. This means that at the end of deployment we are trying remember artifact state of last deployment.
  • At start of Deployment, we will compare project version artifacts folder files with previously deployed files and will deploy only changed files.

You can achieve this by using following workflow. Create new Deploy Workflow and copy following Source in that workflow. You can also modify existing Workflow with source.

Deploy WebLogic Resource (with Change Detection)
<?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>
                           <ns0:NameInCallee>DATASOURCES_CREATED</ns0:NameInCallee>
                        </ns0:OutputValue>
                        <ns0:OutputValue>
                           <ns0:NameInCallee>EIS_ENTRIES_CREATED</ns0:NameInCallee>
                        </ns0:OutputValue>
                        <ns0:OutputValue>
                           <ns0:NameInCallee>JMS_OBJECTS_CREATED</ns0:NameInCallee>
                        </ns0:OutputValue>
                        <ns0:OutputValue>
                           <ns0:NameInCallee>WORK_MANAGERS_CREATED</ns0:NameInCallee>
                        </ns0:OutputValue>
                     </ns0:PluginOutputs>
                     <ns0:UserOutputs/>
                  </ns0:InvokePlugin>
               </ns0:Step>
               <ns0:Step>
                  <ns1:Name>Copy Files to State Folder</ns1:Name>
                  <ns1:StepId>2.2</ns1:StepId>
                  <ns0:InvokePlugin>
                     <ns0:PluginName>FlexagonShellPlugin</ns0:PluginName>
                     <ns0:PluginOperation>execute</ns0:PluginOperation>
                     <ns0:consumesArtifacts>false</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`
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>
                        <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>true</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>false</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:InvokePlugin>
               </ns0:Step>
            </ns0:Steps>
         </ns0:If>
      </ns0:Step>
   </ns0: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.

Here is code for two shell plugin operations for your quick reference, code for Shell plugin is also part of Workflow XML provided above in this page.

Prepare Files for Deployment
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
Copy Files to State Folder
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



  • No labels