DevOps: Continuous Deployment Using Git, Jenkins, and WinCC OA

Why DevOps with WinCC OA is cool!

In the IT world, you would NEVER, EVER, make edits to a production system without going through proper quality assurance change acceptance. However, in the industrial world, for some reason, it has been acceptable to test and commit changes on production systems without the need for isolated development testing prior to deployment. Shouldn’t we be asking, why?

Is it because…

  • There is not enough time to set up this type of development environment;
  • IT tools are not readily available for use;
  • There is no awareness of DevOps tools or how to use them (know-how);

Understanding that IT and OT worlds are converging at an exponential pace, we need to help educate our industry about DevOps practices and the tools that are readily available in modern SCADA packages like WinCC Open Architecture. In our previous DevOps blog posts, we showed you how to integrate Jenkins and Git into your WinCC OA projects to facilitate automated unit testing. 

In this blog post, we are going to bring it all together by setting up Continuous Deployment utilizing WinCC OA, Git, and Jenkins. This tutorial expects you to have the same set up as in the previous blogs and to have followed the previous tutorials to set up both your Git and Jenkins integration.


Step 1: Create a class to hold your Unit Tests

WinCC OA does not natively interact with an outside system like Jenkins to manage development deployments and it is good practice to use something like Unit Tests to determine if your code should be deployed to a production system. I have modified the code from our previous blog post and created a new class to accomplish this. The major changes from this file to the automatically generated one from the High-Speed Programming module is that I am using the base level function of oaAssertEqual() to get the result of pass or fail instead of writing it to the project UI.  I have two tests in this file and both are very simple and I know they will pass, in a real project these would need to be written in a way so that they would help prevent errors.

Step 2: Create a WinCC OA Web Server for Jenkins to hook into

We need some way for Jenkins to integrate into WinCC OA and a webhook is the easiest way to accomplish this.  The following script will start a web server, make a single endpoint available, create an instance of the TstUnitTestDemo class from before, runs the two tests, and return a result.

Step 3: Add your server to your console

The easiest way to do this is to drag the file onto the Console and it will automatically add it.  Make sure that you start the Control Manager.

Step 4: Update your Jenkins file

This Jenkins file has a little bit of logic in it mostly checking if the tests from WinCC OA pass or fail and if they do pass to run a git pull command.

Step 5: Set up a development environment

This is a little bit of a chore because not every file is stored in the Git repository, however, what worked for me was to copy the project to a different computer, deleting the .git folder, git cloning my repository, and then copying those files into my project.  Git cloning will link your repository to your local project.

Step 6: Makes changes and push them to the repository

If everything is set up correctly when you make a push to your git repository Jenkins will recognize the change and execute your scripts. After Jenkins has run the scripts, if you look at your production system you will notice the changes to Scripts or Panels are now live on your production server.

Note(s) and Limitations

This set up is very limiting but exposes the power of these tools working together.  I would also connect something like Slack to your Jenkins to notify your other developers that changes have been made.  Also, this type of Continuous Delivery is only as good as the guidelines in your development team’s practices. If the team is lax on the Unit Tests this will not do you much good.  Another thing to keep in mind is that the git version control set up inside of WinCC OA is built to track changes in panels, pictures, and scripts.

2 thoughts on “DevOps: Continuous Deployment Using Git, Jenkins, and WinCC OA”

  1. Hi. Great idea. You know, that in testframework is is a parser to j-unit format which can be imported by Jenkins pipeline native? It help by analysing new bugs. I can get you more tips about Jenkins and wincc oa.

  2. I haven’t looked into the J-Unit parser at all I will put that on my list of things to investigate.
    Thanks 🙂

Leave a Comment

Your email address will not be published. Required fields are marked *