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 2 Current »

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)
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 | awk -F'/' '{print $NF}'`\n\
          STATE_FOLDER=`echo $FD_TEMP_DIR/../../../../wlresources/$PROJECT_ID`\nmkdir\
          \ -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\
          for file in $files\ndo\n    echo $file - see if it needs to be deployed\n\
          \    mainfilechanged=yes\n    envfilechanged=no\n     \n    diff $file $STATE_FOLDER/$file\
          \ 1>/dev/null 2>/dev/null\n    if [[ \"$?\" == \"0\" ]]\n    then\n    \
          \    mainfilechanged=no\n        echo ---- $file NOT changed since last\
          \ deployment.\n    else\n        echo ++++ $file changed since last deployment.\n\
          \    fi\n     \n    if [[ -f $FD_ENVIRONMENT_CODE/$file ]]\n    then\n \
          \       diff $FD_ENVIRONMENT_CODE/$file $STATE_FOLDER/$FD_ENVIRONMENT_CODE/$file\
          \ 1>/dev/null 2>/dev/null\n        if [[ \"$?\" != \"0\" ]]\n        then\n\
          \            envfilechanged=yes\n            echo ++++ $FD_ENVIRONMENT_CODE/$file\
          \ changed since last deployment.\n        else\n            echo ---- $FD_ENVIRONMENT_CODE/$file\
          \ NOT changed since last deployment.\n        fi\n    fi\n     \n    if\
          \ [[ $mainfilechanged == \"yes\" || $envfilechanged == \"yes\" ]]\n    then\n\
          \        echo $file - wll be deployed\n        changesdetected=yes\n   \
          \     cp $file $DEPLOY_FOLDER/$file\n        if [[ -f $FD_ENVIRONMENT_CODE/$file\
          \ ]]\n        then\n            cp $FD_ENVIRONMENT_CODE/$file $DEPLOY_FOLDER/$FD_ENVIRONMENT_CODE/$file\n\
          \        fi\n    else\n        echo $file - wll NOT be deployed\n    fi\n\
          \     \ndone\n \nsetOutput CHANGES_DETECTED $changesdetected"
        isExpression: false
      isEncrypted: false
    - name: FDSHELL_INP_STOP_ON_ERROR
      value:
        value: 'false'
        isExpression: false
      isEncrypted: false
    - name: FDSHELL_INP_DISABLE_ECHO
      value:
        value: 'true'
        isExpression: false
      isEncrypted: false
    - name: FDSHELL_INP_RESTRICT_ENVIRONMENT
      value:
        value: FD_INSTANCE_CODE
        isExpression: true
      isEncrypted: false
    - name: FDSHELL_INP_NO_SECURE_VARIABLES
      value:
        value: 'true'
        isExpression: false
      isEncrypted: 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 Configurations
      type: INVOKE_PLUGIN
      data:
        pluginName: FlexagonWeblogicPlugin
        pluginOperation: createOrUpdateWeblogicConfig
        endpointInstanceOverride:
          isExpression: false
        consumesArtifacts: true
        producesArtifacts: false
        endpointSelection:
          choice: All
        endpointExecution:
          choice: Any
          stopOnError: false
        inputs:
        - name: FILE_PATH_TO_PROPERTIES
          value:
            value: FD_TEMP_DIR + "/resources"
            isExpression: true
          isEncrypted: false
        outputs:
        - output: FDWLS_OUT_IS_RESTART_REQUIRED
        - output: DATASOURCES_CREATED
        - output: EIS_ENTRIES_CREATED
        - output: JMS_OBJECTS_CREATED
        - output: WORK_MANAGERS_CREATED
        userInputs: []
        userOutputs: []
    - id: '2.2'
      name: Copy Files to State Folder
      type: INVOKE_PLUGIN
      data:
        pluginName: FlexagonShellPlugin
        pluginOperation: execute
        endpointInstanceOverride:
          isExpression: false
        consumesArtifacts: false
        producesArtifacts: false
        endpointSelection:
          choice: All
        endpointExecution:
          choice: Any
          stopOnError: false
        inputs:
        - name: FDSHELL_INP_CODE_SNIPPET
          value:
            value: |-
              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
            isExpression: false
          isEncrypted: false
        - name: FDSHELL_INP_STOP_ON_ERROR
          value:
            value: 'true'
            isExpression: false
          isEncrypted: false
        - name: FDSHELL_INP_DISABLE_ECHO
          value:
            value: 'false'
            isExpression: false
          isEncrypted: false
        - name: FDSHELL_INP_RESTRICT_ENVIRONMENT
          value:
            value: FD_INSTANCE_CODE
            isExpression: true
          isEncrypted: false
        - name: FDSHELL_INP_NO_SECURE_VARIABLES
          value:
            value: 'true'
            isExpression: false
          isEncrypted: false
        outputs: []
        userInputs: []
        userOutputs: []

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