Skip to Content
Technical Articles
Author's profile photo Fatih Pense

Sync CPI Content for Git and Backups with CPISync (Open-Source)

If you want to track your packages in Git or have regular backups, CPISync provides the easiest, structured & automated way to achieve your goal. It comes under 10 MB and without any dependencies.

Update 2021-02-06: v0.2.0 here with changed config rules, new features, and bug fixes. You can check the changelog here.

 

CPI%20Sync%20-%20It%20is%20raining%20packages%21

CPI Sync – It is raining packages and artifacts!

Quick Setup & Start

  1. Download the latest release for Windows or Linux:

https://github.com/pizug/cpi-sync/releases/latest

  1. Create an empty folder & put cpisync.exe inside:

  1. Copy example configuration JSON and create “cpi-sync.json” file. Change the fields accordingly, and don’t worry about making mistakes! CPI Sync will validate the config file and give helpful error messages.
{
  "cpisync": "0.2.0",

  "tenant": {
    "management_host": "change-tmn.hci.eu1change.hana.ondemand.com",
    "credential": {
      "s_user": {
        "username": "S000change",
        "password_environment_variable": "CPI_PASSWORD"
      }
    }
  },
  "packages": {
    "filter_rules": [
      { "type": "single", "id": "TrainingPackage" },
      { "type": "single", "id": "eDocumentElectronicInvoicingforYou" },
      { "type": "single", "id": "MYPACKAGE" }
    ]
  }
}
  1. Now you can run double-click on “cpisync.exe”

  1. It will ask for your S-user password interactively. Then, if everything is correct it will download the artifacts in packages you have specified.

Since this was the quick start, we went with S-user. For regular usage, I recommend setting up an OAuth client for your CPI management node(“tmn”).

If you need to run it via jobs, run it for CI/CD or want more configuration, you can find further instructions & documentation on GitHub:

https://github.com/pizug/cpi-sync

If you similar have use cases and ideas, you can contact me or create an issue on the repository!

Thanks for reading!

Assigned Tags

      14 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Giovanni D'Introno
      Giovanni D'Introno

      Hi Fatih,
      I tried the tool, but I got this error:
      reqwest::Error { kind: Decode, source: Error("missing field `d`", line: 1, column: 101) }
      The json config I am using is:

      {
      "cpisync": "0.1.0",

      "tenant": {
      "management_host": "****.hana.ondemand.com",
      "credential": {
      "s_user": {
      "username": "S00******"
      }
      }
      },
      "packages": [
      {
      "id": "AI_ModelCompany"
      }
      ]
      }

      Author's profile photo Fatih Pense
      Fatih Pense
      Blog Post Author

      Hi Giovanni,

      From the configuration point of view, everything seems correct, and the API check is successful. You can also delete the hostname from the comment.

      Maybe cpisync should show the response body when an error happens...

      Are you sure the package with that ID exists? You should use the Technical Name of the package, click on edit and it will show up there.

      You can also create a GitHub issue or contact me directly.

      Regards,
      Fatih

      Author's profile photo Sokratis Papachristos
      Sokratis Papachristos

      Hello Fatih Pense ,

      Thank you for the helpful blog!! I face a similar issue. Could you please give me a hint on what goes wrong?

      Config:

      {
        "cpisync": "0.1.0",
        "tenant": {
          "management_host": "*******.hci.eu2.hana.ondemand.com",
          "credential": {
            "s_user": {
              "username": "P*********"
            }
          }
        },
        "packages": [
          { "id": "ExternalLandingPageDataInteg**************************" }
        ]
      }
      Response:

       

      Start CPI Sync?
      Press any key to continue...
      Would you like to enter a password for user: P********* to connect host: ********.hci.eu2.hana.ondemand.com?
      Password:
      Processing Package: Package { id: "ExternalLandingPageDataInteg******************", local_dir: None }
      reqwest::Error { kind: Decode, source: Error("missing field `d`", line: 1, column: 67) }
      Press any key to continue...

      Author's profile photo Fatih Pense
      Fatih Pense
      Blog Post Author

      Hello Sokratis,

      Glad it is helpful!

      This error means, these steps are correct:

      1. Configuration can be parsed correctly
      2. Credentials are correct and the tool can access the API

      Then, it can't find the package ID.

      Maybe you have entered Flow ID?

      We can also discuss in detail one-to-one.

      Best regards,
      Fatih Pense

       

      Author's profile photo Saurabh Kabra
      Saurabh Kabra

      Hello Fatih Pense ,

      Thanks as always for bringing out such utilities which makes our life easier.

      One question...When I try to use this it works fine but only copy first 15 iflows from the package though my package has 70+ iflows. Do you know if this is by design that only first 15 iflows are fetched or some timeout caused this issue?

      Thanks

      Saurabh

      Author's profile photo Fatih Pense
      Fatih Pense
      Blog Post Author

      Hello Saurabh,

      Thanks for the feedback 🙂

      There is no limitation but there may be bugs I intend to fix this weekend 😉 Does your 16th iflow has a long ID by any chance? Also, is there an error on the command line? You can share it, masking private data.

      I also intend to change the config structure with each version. If you have a use-case that you want better support, you can always give feedback about your dream cpi sync tool.

      I plan to add:

      • filtering package with regex,
      • a  way to exclude packages,
      • inform the user if a package name is used instead of the package id
      • maybe an option to disable zip extraction if you just want backup (not using Git)
      • maybe a field to set target local directory for all packages

      There is also another bug: the tool should skip configure-only packages, but it is not related to your case.

      Best regards,
      Fatih

      Author's profile photo Saurabh Kabra
      Saurabh Kabra

      Hello Fatih,

      I dint check the error earlier because as soon as the tool hits an error it automatically closes the application window. Hence this time instead of running cpisync.exe directly, I call it via cmd and hence I was able to see the error as follow for my 16th iflow:

      thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 123, kind: Other, message: "The filename, directory name, or volume label syntax is incorrect." }', src\main.rs:304:66
      note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

      I just paste the snapshot here from the error that I get in CMD:

      Author's profile photo Sokratis Papachristos
      Sokratis Papachristos

      Fatih Pense So far it was running fine on my side. Today i downloaded the latest version and also used the latest Config schema. Since then i get the exact same error as Saurabh Kabra

      Author's profile photo Fatih Pense
      Fatih Pense
      Blog Post Author

      Hello Sokratis Papachristos and Saurabh Kabra ! We are looking into the issue privately and I will update a new release when the problem is solved for both of you.

      Regards,
      Fatih

      Author's profile photo Manuel Seeger
      Manuel Seeger

      Very cool tool Fatih!

      I found some strange behavior when I tried to run this on a (minimal) docker base image. Example:node:12-alpine

      On node:12-alpine, the shell cannot find the executable. The same image runs fine if I build it on node:12 instead of node:12-alpine.

      I was wondering if there are some system level requirements cpisync expects that the alpine minimal base images don't bring with them.

      It's not a blocker for us as we can build our container on node:12, it just means huge images for a simple script + cpisync. We would prefer an alpine image to keep the container footprint down.

      Maybe you can try to run cpisync in an alpine based container and see if you can reproduce this problem.

      Best regards,

      Manuel

      Author's profile photo Fatih Pense
      Fatih Pense
      Blog Post Author

      Hello Manuel,

      Thanks for the feedback! You are right. Alpine uses "musl libc", so I added a new binary to the release page. I have made a small test run on the Alpine image. Can you try this binary? "cpi-sync-musl"

      It is great to see cpi-sync being used in different ways. If you have feature requests/ new use-cases for this tool or other free tools you can always message me.

      For the Git use-case, I noticed "parameters.prop" files generate comments with a timestamp that changes over time even if nothing has been changed by the developers. I can add an option to remove those comments in the next release.

      Best regards,
      Fatih Pense

      Author's profile photo Manuel Seeger
      Manuel Seeger

      Hi Fatih,

      Thanks for the update and the new release. Works perfectly on Alpine now!

      We have our custom logic to detect a change which needs to go to git (in our case on new artifact versions in CPI) so the parameters.prop didn't bother us.

      Already live and is now auto-committing every version change in CPI to git. Very cool!

      PS I would also like to encourage anyone interested in building Git integration with the CPI API to vote on the influence improvement I have submitted for support of version history in the API: https://influence.sap.com/sap/ino/#/idea/261529

       

      Author's profile photo Fatih Pense
      Fatih Pense
      Blog Post Author

      Hi Manuel,

      Great news! I'm glad it helped your case. I will get happiness points each time it auto-commits 🙂

      I have also cast my vote on the influence program.

      By the way, I have noticed the tool currently doesn't sync value mappings. I will add the feature but I can prioritize if it is important for your case. If the custom logic is using "/IntegrationDesigntimeArtifacts", I would suggest also checking "/ValueMappingDesigntimeArtifacts"

      I think I will just write value mappings in the same folder as integration flows. In CPI, you can create flows and value mappings with the same ID! But, it is certainly not a best practice, and monitoring pages get confused. It can be undefined behavior. 🙂

      Regards,
      Fatih

      Author's profile photo mahendra joshi
      mahendra joshi

      Hey I read your article and it was nice!