DevOps validation for Cloud Integration worksflows

DevOps validation for Cloud Integration worksflows

There are SAP Customers that want to perform a validation of their iflows before they enable to transport the content so they can perform external validation like CPILint or run unit test. 
In Figaf we do copy all iflows to a git repository. It would then be interesting to be able to run some pipeline to perform validation of the setup. We have added into 2306 release. 
On the agent select the Integrate with Git Pipelines. 

Then Figaf will check for a file called pipeline-validation.txt. If there is a Text with Exit code: 1 then it will be showed as an error in Figaf when either performin a transport or checking status.

Here is an example on how it can be used in Github Actions. It does require a bit of work to get it working and you should be making your own attemt to get it working. 

How to get this working. It is a bit more complicated. It will require you know some gradle and git work to get it working. 
1) You neeed to add the gradle.properties to the git repository
2) In the .github/workflows you need to add the files. They are in the included Zip file of the page, see buttom of page. 

3) You chould modify the cpilint xml to your needs for governance. 
4) Check the figaf-validation.yml and make the nessary validations. 
5) Under Settings->Actions ->General make sure you select workflow permissions to Read and Write

This key is needed because Git need to have access to run and commit the changes back into the repository.
Notice there can be some difference if you run in your own repository vs in an orgainsations repoistory.

Here is the pipelinefile that you should add. If you use other platform use this as inspiration they will probaly have a little different setup. 
And you should trigger it to perform the steps that you need for it. 
  1. name: Figaf Pipeline

    on:
    push:
    branches:
    - '**'

    jobs:
    figaf-validations:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout repository
    uses: actions/checkout@v2
    with:
    fetch-depth: 0
    token: ${{ secrets.GITHUB_TOKEN }}

    - name: Set up Java 11
    uses: actions/setup-java@v2
    with:
    distribution: 'adopt'
    java-version: '11'

    - name: Download and extract CPI Lint
    run: |
    curl -L -o cpilint.zip https://github.com/mwittrock/cpilint/releases/download/v1.0.4/cpilint-1.0.4.zip
    unzip -o cpilint.zip
    rm cpilint.zip
    chmod +x cpilint-1.0.4/bin/cpilint

    - name: Setup Gradle
    uses: gradle/gradle-build-action@v2
    with:
    gradle-version: 7.4

    - name: Get changed IFlow directories
    run: |
    changedIflowDirs=$(git diff --name-only --diff-filter=d HEAD^ | grep -E '.*/IntegrationFlow/[^/]+' | awk -F/ '{print $1"/"$2"/"$3}' | sort | uniq)
    echo "Changed IFlow Directories: $changedIflowDirs"

    EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
    echo "changedIflowDirs<<$EOF" >> ${GITHUB_ENV}
    echo "${changedIflowDirs}" >> ${GITHUB_ENV}
    echo "$EOF" >> ${GITHUB_ENV}

    - name: CPI Lint validation
    run: |
    if [ -z "${{ env.changedIflowDirs }}" ]; then
    echo "No IFlow changes detected, skipping CPI Lint validation"
    exit 0
    fi

    readarray -t changedIflowDirs <<< "${{ env.changedIflowDirs }}"

    for integrationFlowDir in "${changedIflowDirs[@]}"
    do
    echo "integrationFlowDir: $integrationFlowDir"
    iflowName="$(basename "$integrationFlowDir")"
    packageName="$(basename "$(dirname "$(dirname "$integrationFlowDir")")")"
    (cd "$integrationFlowDir" && zip -r "../$iflowName.zip" .)

    cpilintCommand="${{ github.workspace }}/cpilint-1.0.4/bin/cpilint -rules=${{ github.workspace }}/.github/workflows/cpilint.xml -files=\"../$iflowName.zip\""
    echo "Executing cpilint: $cpilintCommand"
    cpilintStatus=0
    output=$(cd "$integrationFlowDir" && eval $cpilintCommand 2>&1) || cpilintStatus=$?

    if [ -z "$cpilintStatus" ]; then
    cpilintStatus=0
    fi

    echo "CPI Lint output: $output"
    echo "CPI Lint exit code: $cpilintStatus"

    echo "Validation name: CPI Lint" > "$integrationFlowDir/pipeline-validation.txt"
    echo "Execution time: $(date +'%Y-%m-%d %H:%M:%S')" >> "$integrationFlowDir/pipeline-validation.txt"
    echo "Exit code: $cpilintStatus" >> "$integrationFlowDir/pipeline-validation.txt"
    echo -e "Output: $output\n" >> "$integrationFlowDir/pipeline-validation.txt"

    rm -f "$integrationFlowDir.zip"
    done

    - name: Run unit tests
    run: |
    if [ -z "${{ env.changedIflowDirs }}" ]; then
    echo "No IFlow changes detected, skipping Unit tests validation"
    exit 0
    fi

    readarray -t changedIflowDirs <<< "${{ env.changedIflowDirs }}"

    for integrationFlowDir in "${changedIflowDirs[@]}"
    do
    iflowName="$(basename "$integrationFlowDir")"
    packageName="$(basename "$(dirname "$(dirname "$integrationFlowDir")")")"
    runTestsCommand="gradle :$packageName:iflow-$iflowName:test"
    echo "Executing runTestsCommand: $runTestsCommand"
    runTestsStatus=0
    output=$(eval $runTestsCommand 2>&1) || runTestsStatus=$?
    if [ -z "$runTestsStatus" ]; then
    runTestsStatus=0
    fi
    echo "Unit tests output: $output"
    echo "Unit tests exit code: $runTestsStatus"

    echo "Validation name: Unit tests" >> "$integrationFlowDir/pipeline-validation.txt"
    echo "Execution time: $(date +'%Y-%m-%d %H:%M:%S')" >> "$integrationFlowDir/pipeline-validation.txt"
    echo "Exit code: $runTestsStatus" >> "$integrationFlowDir/pipeline-validation.txt"
    echo -e "Output: $output\n" >> "$integrationFlowDir/pipeline-validation.txt"
    done

    - name: Commit and push changes
    run: |
    if [[ $(git status --porcelain) ]]; then
    git config --local user.email "irt@figaf.com"
    git config --local user.name "Figaf"
    git add .
    git commit -m "Update pipeline-validation.txt"
    git push
    else
    echo "No changes to commit"
    fi





    • Related Articles

    • How to add MessagingSend Role to a Cloud Foundry user

      If you are using SAP Cloud Integration on Cloud Foundry then you probably have noticed you cannot add the default ESBMessage Send (MessagingSend) role to your user. You will need to create a role collection to support this.  In your BTP cockpit go to ...
    • Create Service Keys for SAP CPI Cloud Foundry

      For SAP CPI Cloud Foundry you have an option to use Service Keys to send messages. The Figaf Tool will not test the properties are correct before running tests.  We need to create keys for both API and for Integration flow API access To create a ...
    • Connect to SAP Integration Suite /Cloud Foundry

      To connecto SAP Cloud Foundry we have enabled a new way of connecting using SAML. This is because the public APIs of SAP Cloud Integration is not as good as the private APIs used in the Web.  You can read more about the a setup and security behind it ...
    • Create a git repository for SAP Cloud Integration

      In this guide you will see how you can create a git repository for your SAP CPI/Cloud Integration system.  Before you start you need 1. Have installed Figaf 2. Have connected it with a SAP CPI tenant 1. Create a git repository on forinstance github ...
    • Custom migration of SAP PI Communication Channels to Cloud Integration

      We have templates that allows you to make migrations SAP PI/PO channels to SAP Cloud Integration Faster. In 2309 this has been moved into the main Figaf Tool and gotten a viewer that will allow you to update the templates faster. On the migration ...