Skip to content
This repository has been archived by the owner on Feb 23, 2021. It is now read-only.

Command Line Interface for the SAP Commerce Cloud Portal (CCv2 aka Commerce Cloud in the Public Cloud)

License

Notifications You must be signed in to change notification settings

SAP-archive/commerce-ccv2ctl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Archived
With the 2102 release of the Cloud Portal, the offical APIs now cover all features of ccv2ctl

Please use the official API / CLI instead of this tool.

ccv2ctl - SAP Commerce Cloud Portal CLI

REUSE status

This tool allows you to:

  • get data about builds and create (=start) new builds:

    ccv2ctl get build 20180930.2
    # data about a specific build
    
    ccv2ctl get build --all
    # data of all builds
    
    ccv2ctl create build --name some-name --branch production
    # create a new build
    
    ccv2ctl logs 20180930.2
    # dump build log to stdout
    
  • check the data about running deployments

    ccv2ctl get deployment d1
    
  • trigger a deployment

    ccv2ctl create deployment --build 20180930.3 --environment d1
    
  • get data about previous deployments

    ccv2ctl get deploymenthistory d1
    
  • get data about initial passwords

    ccv2ctl get initialpassword d1
    
  • get customer properties

    ccv2ctl get customerproperties d1 --aspect hcs_common
    
  • set customer properties

    ccv2ctl set customerproperties d1 --aspect hcs_common --propertyfile hcs_common.properties
    # set properties from file hcs_common.properties
    
    echo accstore.environment=dev | ccv2ctl set customerproperties d1 --aspect hcs_common
    # set properties from stdin
    

Every command has a detailed help available, make sure to check it! (use ccv2ctl help as an entry point)

Since Go compiles executables as statically linked binaries, you can easily distribute this tool to you CI/CD servers (Jenkins, for example) and use it to automate builds and deployments to the Commerce Cloud.

Installation

Authentication is done via the client certificate for a S-User, the SAP Passport

The S-User needs to be configured as CUSTOMER_DEVELOPER or CUSTOMER_SYS_ADMIN in the CCV2 Cloud Portal.

Make sure to disable two-factor authentication when you add the S-User to your subscription!
If you enable 2FA even once, you cannot get rid of it without a support ticket.

You need to export the certificate and the key into two PEM-encoded files so they can be used for ccv2ctl (you will be prompted for the keystore password):

openssl pkcs12 -in /path/to/store.pfx -nokeys -nodes | openssl x509 -out certfile.pem
openssl pkcs12 -in /path/to/store.pfx -nocerts -nodes |  openssl rsa -out keyfile.pem
  1. Download the pre-built binary for your OS from the Github releases, rename it to ccv2ctl
  1. Put the binary somewhere on your $PATH

  2. Create the config file .ccv2ctl.yaml in your home directory with following content:

     certfile: /path/to/certfile.pem
     # Path to PEM-encoded SAP Passport client certificate
    
     keyfile: /path/to/keyfile.pem
     # Path to PEM-encoded key of SAP Passport client certificate
    
     # subscription: c0deba5ec0deba5ec0deba5ec0deba5e
     # (optional) Default subscription-ID to use for all commands. You can find the ID in the URL of the cloud portal.
     # https://portal.commerce.ondemand.com/subscription/c0deba5ec0deba5ec0deba5ec0deba5e/...
     #                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
     # cookiejar: /path/to/jar
     # (optional) path to HTTP cookie jar to avoid DDOSing the portal.
     # Default value: $HOME/.ccv2jar
    

    I recommend configuring the default subscription, provided you only work on a single project.

  3. Enjoy

You can provide all configuration options also on the commend line or as environment variables (prefixed with CCV2_)
Check the output of ccv2ctl help for further details.

How it works

It simulates the single-sign-on flow of the frontend using a SAP Passport client certificate.

Once we have an authenticated session, we can call the same REST APIs that the Cloud Portal uses.

Support

If you encounter any bugs or have an idea for a new feature, please submit a new issue in this repository.

Contributing

Any contributions are welcome!

Please:

  1. Fork the repository
  2. Implement and
  3. Test your changes
  4. Format the code (gofmt -l -s -w .)
  5. Open a new pull request

Developer Certificate of Origin (DCO)

Due to legal reasons, contributors will be asked to accept a DCO before they submit the first pull request to this projects, this happens in an automated fashion during the submission process. SAP uses the standard DCO text of the Linux Foundation.