This presentation accompanies a recent Expert Session, with video content including demos of the following topics: found here!
DevOps is a process for taking planned changes through development, through testing, and into production, where they can be accessed by end users. One test instance typically has automated tests (integration testing) which ensure application logic is preserved in spite of whatever changes the developers are making, and often there is another test instance to ensure the application is usable (UAT testing) and able to handle a production load (load testing).
So, a DevOps Pipeline starts with a task manager tasking out planned changes, where each task will become a branch in the repository. Each time a new branch is created, a new pipe is needed, which in this case, is produced by Docker Hub. Developers then make changes within that pipe, which then flow along the pipe into testing. In this diagram, testing is shown as the valve which when open (i.e. when tests all pass) then allows the changes to flow along the pipe into production. A good DevOps process has good flow along the various pipelines, with as much automated or scripted as possible to reduce the chances for errors in deployments. In order to create a seamless pipeline, whether or not it winds up automated, several third party tools are useful:
Container software is a very good way to improve the maintainability and updatability of a ThingWorx instance, while minimizing the amount of resources needed to host each component.
1. Create Docker Image
Consult the Help Center if need be. Update your YML file with everything you need before starting the image: see the example in the PTC community. License the instance using the license management website. Follow the instructions from Docker for installing those tools: Docker itself (docker) and Docker Compose (docker-compose).
2. Save Docker Image in Docker Repo
Docker Hub has some free options, and if a license is purchased, can host more than a single Docker image and tag. It is also possible to set up your own Docker registry.
3. Access the image in Docker Desktop
Download Docker Desktop and sign-in to the Docker account which hosts the repository. Create some folders for storing the h2.env file and the ThingworxStorage and ThingWorxPlatform mounted folders. Remember to license these containers as well. Developers login to the license management site themselves and put those into the ThingWorxPlatform mounted folder (“license_capability_response.bin”).
Git is a very versatile tool that can be used through many different mediums, like Azure DevOps or Github Desktop. To get started as a totally new Git user, try downloading Github Desktop on your local machine and create a local repository with the provided sample code.
This can then be cloned on a Linux machine, presumably whichever instance hosts the integration ThingWorx instance, using the provided scripts (once they are configured). Remember to install Git on the Linux machine, if necessary (sudo apt-get install git).
A sample ThingWorx application (which is not officially supported, and provided just as an example on how to do DevOps related tasks in ThingWorx) is attached to this post in a zip file, containing two directories, one for scripts and one for ThingWorx entities. Copy the Git scripts and config file into the top level, above the repository folder, and update the GitConfig.sh file with the URL for your Git repository and your login credentials. Then these scripts can be used to sync your Linux server with your Git repository, which any developer could easily update from their local machine. This also ensures changes are secure, and enables the potential use of other DevOps procedures like tasks, epics, and corresponding branches of code.
Steps to DevOps using the provided code as an example:
Clone the repository into the SystemRepository or any other created repository, use the provided scripts in a Linux environment. Import the DeploymentUtilities entity, which again is scripted for Linux or for use with a development IDE with bash support. Then import the ThingWorx application from source control or use the script (which itself makes use of that DeploymentUtilities entity).
Now create some local changes, add things, etc. and try out the UpdateApplication script or export to source control and then push to the Git repo. Data and localization table exports are also possible.
Run the tests using the provided IntegrationTester thing or create your own by overriding the IntegrationTestTS thing shape, or use the TestTwxApplication script from a Linux terminal.
Design a process for your application which allows for easy application exports and updates to and from a repository, so that developers can easily send in their changes, which can then be easily loaded and tested in another environment.
DevOps is a complex topic and every PTC customer will have their own process based around their unique requirements and applications. In the future, more mature pipeline solutions will be covered, ones that involve also publishing to Solution Central for easier deployment between various testing instances and production.