Qlik Community

Knowledge

Search or browse our knowledge base to find answers to your questions ranging from account questions to troubleshooting error messages. The content is curated and updated by our global Support team

Announcements
Support Case Portal has moved to Qlik Community! Read the FAQs to start exploring Support resources.

How to: Qlik Application Automation for backing up and versioning QCS apps on Github

Vincenzo_Esposito

How to: Qlik Application Automation for backing up and versioning QCS apps on Github

An integrated version control systems always have been among the frequent questions, often reported in RFx. The following article is going to show a step-by-step guide on how to set an Application Automation to push QCS apps, without data, to a github repository when they are published on a (production) space.

Environment

 

This guide does not cover

  • Basic use of Qlik Sense Enterprise SaaS
  • How to connect Qlik Application Automation Connectors 
  • How to create a GitHub Repo

What we are going to achieve

We are going to create a github repository containing all the published apps organized in folders, where the folder name mirror the published space. Since spaces are used to manage the softwer lifecycle and the different environments (Develop, Test, Performance, Production), we wants only applications published to the production spaces get saved and versioned on the github repository.

 

Set the Qlik Sense Enterprise SaaS environment

First of all, since we don't want push every published application up to the git repo, we have to define the production spaces. In this guide we explicitly use the word "Production" in the space description. 

From within a space, click the cog icon on the top right corner and select Edit space

Space setting optionsSpace setting options

 

In the Edit Space dialog window make sure to add the word Production in the description.

Edit Space Dialog windowEdit Space Dialog window

 

Github repository

Create a new github repository, it can be private or public. In either way the Github connector needs to be authenticated with write permission.

Create automation

From your tenant web hub, click on Add new --> New Automation. Give it a name and description, optionally select the more appropiate icons, then click Save.

Create New AutomationCreate New Automation

 

The Start Block

We want trigger this automation every time someone publish an app. In the Start Block select:

  • Run Mode:  Webhook
  • Connector: Qlik Cloud Service
  • Event:  App Published

Start Block PropertiesStart Block Properties

 

In the Test Payload copy/paste this JSON:

 

 

 

 

 

 

 

 

 

 

{
  "cloudEventsVersion": "0.1",
  "source": "com.qlik/engine",
  "contentType": "application/json",
  "eventId": "dbce978f-17cd-4588-bfde-481544b7eb58",
  "eventTime": "2021-09-06T18:31:10Z",
  "eventTypeVersion": "1.0.0",
  "eventType": "com.qlik.v1.app.published",
  "extensions": {
    "spaceId": "<YOUR SPACE ID>",
    "tenantId": "KuGA12XZN0c7A7MUGHTkJuXGx3QVwrdo",
    "userId": "5-dSP_g22ekR3CivrMwXl-IeM-2h0-AD"
  },
  "data": {
    "attributes": {
      "id": "<YOUR ATTRIBUTE ID>",
      "name": "Sample data app",
      "owner": "<OWNER>",
      "originAppId": "<YOUR ORIGINAL APP ID>"
    }
  }
}

 

 

 

 

 

 

 

 

 

 

Anytime an app will be published to a space, Qlik Cloud Service connector will pass all the informations about the published app in the JSON format above. Those informations can be used by downstream blocks. It is not convenient continuosly publish apps to test the process, especially during the build phase. For this reason the Payload Test is used when we hit the RUN button, therefore just replace:

  • <YOUR ATTRIBUTE ID> with the app id we want to emulate for a publish action
  • <YOUR ORIGINAL APP ID> for the purpose of this guide you can set this as app is as well.
  • <YOUR SPACE ID> with the target space id we want emulate for the publish action

because the downstream blocks are going to use only those three pieces of information, we don't need to change other attributes.

Get Space Info

From the Qlik Cloud Service Connector drag and drop in the canvas the Get Space block and attach it to the Start block. Under the Input select App Published > Data > Space Id as Space Id

Get Space BlockGet Space Block

This block is in charge of getting all the informations giving the published space id.

Make it Parametric

Static contents such as the Repository Owner and Name can be used in more blocks. It may be convenient to set variables with static content and use variables in the downstream blocks. Variables make this automation easier to mantain.

On the left hand-side menu click on Basic under BLOCKS and in the submenu select Variable block. Drag it into the canvas under the Get Space block

Variable Block propertiesVariable Block properties

On the variable Input section click on  the Manage Variables button, the variable dialog window will open. Add two new variables (owner and repo, optianally branch) and select type string for both, then click Save.

Variables dialog windowVariables dialog window

You need to use one variable block to set each variable, thuse you need to use two variable blocks chained one after the other to set the Github Owner and Repo.

Condition Block

We want only production spaces app are backed up and versioned on the github repository and this is the right moment to check it.

On the left hand-side menu click on Basic under BLOCKS, in the submenu select Condition block, move it into the canvas under your last variable block

Condition Block propertiesCondition Block properties

In the IF statement, click on the little down arrow icon and select the Get Space  block, then Description. Next select Contain and in the last box just write Production. This statement will return true when the target space description will contain the word Production.

Get App Information

We need some information about the published app to use later downstream in the process. From the Qlik Cloud Service Connector, select the Get App Information block and drop it in the YES branch under the Condition block. In the App Id box select App Published > Data > Attributes > id.

 

Get App Information propertiesGet App Information properties

Export App

Next step is to export the published app. From the Qlik Cloud Service Connector, select the Export App to Base 64 Encoded File block and drop it under the previous block. In the App Id select:

App Published > Data > Attributes > Original App Id

Export App to Base 64 Encoded FileExport App to Base 64 Encoded File

Move to Github

Now we are ready to move the file into GitHub repo created earlier. In case of file update, we need to get the SHA signature of the file being replaced, for this reason we need to use the Get Repository Content block. This block return several informations giving the file name, we are only interested in the SHA signature.

From the GitHub Connector, select the Get Repository Content block and drop it under the previous block. In the input section fill the fields as follow. 

  • User: Variable Owner
  • Repo: Variable Repo
  • Path: Get Space > Name / Get App information > Info > Attributes > Name .qvf

Get Repository ContentGet Repository Content

As you can see from the above image, the path was built using the space name as folder name and the app name as file name. We also added the slash (/) between the folder and file name, and the file extension (.qvf).

The first time we push a new App, the related file does not exist yet on the Github repo, thuse this block will return an error, but we don't want to block the whole process. For this reason we want to just raise a warning.

In the Settings section select Warnings as On Error action, as showed in the following image.

On Error actionOn Error action

We are ready now to push the file up to the GitHub repository. From the GitHub Connector, select the Create or Update  File Contents block and drop it under the previous block. Under the Input section fill the properties as follow:

  • Owner : Get it from the variable
  • Repository: Get it from the variable
  • Message : Get App Information > Info > Attributes > Description
  • PathGet Space > Name / Get App information > Info > Attributes > Name .qvf
  • Base 64 File Content: Get it from the previous block
  • Branch: Main (or use a variable)
  • File Sha: Get Repository Content > Sha

IMPORTANT : If you map the Message field, then you must set a message on the the publish action or the automation will fail. You can optionally avoid mapping the message field. Thanks to @Alvaro_Palacios  for the find

Create or Update File ContentsCreate or Update File Contents

 

Alert

So far so good, we have the app saved into GitHub repo, the next three bloks are used to alert the App owner and users interested in a new published version. Let's start getting the user e-mail.

From the Qlik Cloud Service Connector, select the Get User  block and similarly as already done so far, in the User Id fields select

App Published > Extensions > User Id

Next attach the Send Mail block and fill the fields as reported in the following image. This block will send some useful information to the app owner.

Send Mail PropertiesSend Mail PropertiesThe last step is send a message on a pre-defined Microsoft Teams Channel alerting a new version of the app has been published and available. 

From Microsoft Teams Select Send Message block and fill the fields as showed in the following image

Send Message PropertiesSend Message Properties

And this is how the alert message in the Team channel looks like.

Message in teamsMessage in teams

 

Import Process

Going through all these steps is the best way to getting start with the Qlik Application Automation logic, but if you are in a hurry and just need this process to work, all you need to do is download the attached JSON, right click on an empty space in the canvas and select upload workspace

Upload processUpload process

Once uploaded, remember to authenticate all the involved connectors and change the variables value.

 

Update

September 23: Thanks to some of you who have tested this automation, it turns out the Get Repository Content Block have an hard limit on the file size, leading the automation to fails updating file greather then 1Mb. That block can easly replaced by the Get Repository Content and filter the file we are interested in.

Schermata da 2021-09-23 09-57-52.png

 Here attached the Fixed version.

The information in this article is provided as-is and to be used at own discretion. Depending on tool(s) used, customization(s), and/or other factors ongoing support on the solution below may not be provided by Qlik Support.

Tags (1)
Labels (2)
Attachments
Comments
Alvaro_Palacios
Support
Support

Great stuff!! The tutorial is certainly very clear and it was easy for me to follow. I'm going to import the automation in my tenant to set it up with my own GitHub account. Finally I can do some versioning of my Qlik Sense apps in an automated way!!! Well done 🙂

Version history
Revision #:
21 of 21
Last update:
3 weeks ago
Updated by: