Continuous Build Server

jking22
2014-03-22
2024-03-15
  • jking22 - 2014-03-22

    Just a suggestion...

    Has anyone at Codesys considered offering an automated build server solution?

    We've had a bit of success with Cruisecontrol.NET for automating build/packaging with Codesys 2.3.

    I can imagine with 3.x would be quite a bit more flexible.
    With every SVN commit or by request:
    Checkout --> Roll Version Number-->Build --> Unit Test --> Static Analysis --> Create Documentation --> Package --> Deploy

     
  • Anonymous - 2014-03-24

    Originally created by: M.Schaber

    Hi,

    Such solutions exist, both inside 3S and at some customers sites.

    They usually utilize Python Scripting, the SVN AddOn and the Test-Manager AddOn, and several improvmenents in CODESYS were implemented (and others planned) due to the experience and feedback we got from our customers.

    However, there is no product offer of a CI server yet. I'm not sure whether that is a good idea - the customers have different work flows, different CI systems and a different server infrastructure where they want CODESYS to be integrated.

    So I think that 3S and our OEMs can provide the building blocks, but I doubt we will be able to create a complete "one-size-fits-all" solution to the CI problem in the form of a hypothetic "CODESYS CI Server" product. However, I'll take this suggestion into our product management.

    HTH,
    Markus

     
  • DavidCozens - 2014-03-24

    We perform CI utilising Codesys 3.5.4 on a Jenkins build cluster. As part of this we use the SVN, static analysis and test manager plugins, these are typically invoked by using python scripts running codesys from the command line. We also use the automation platform.

    Our CI system builds our entire codesys offering including the PLC firmware, automation platform components and packages to extend codesys. We test the firmware using googletest. We test the automation platform with NUnit. We use Jenkins to upgrade virtual machines with the new packages and to upgrade out PLCs. Jenkins then invokes Test Manager to run tests on Codesys Control V3 and on each of our PLCs. These tests include unit tests and functional tests. We use python scripting from within Test Manager to drive LabView to stimulate and test the PLC IO system.

    On every build we get a full set of all of the items we would ship if we choose to release. We also have the confidence of many thousands of tests being run.

    The only step that we are missing from the build sequence you show is rolling the version number. Version number changes are still manual. However each codesys build is identifiable as the SVN plugin includes the SVN version information in some global variables available in each project or library.

    There is effort required to learn how to use these tools, there is investment required to build a CI system like this. But once you have worked like this you will not turn back.

    There are parts of this process that could be improved, however that appears to be happening. The tools have improved over the time we have been using them and they continue to do so.

     
  • Anonymous - 2014-03-25

    Originally created by: M.Schaber

    Hi,

    I just wanted to add that the "Roll Version Number" part can be done two ways:

    1. Using the SVN_VERSION_INFO object as mentioned by David Cozens.

    2. The scripting interface also allows access to the Project Information object, so you can increase the project version number (like increasing once each build, or encoding the date and time), or set it to a value derived from the SVN revision if you want.
      HTH,
      Markus

     
  • DavidCozens - 2014-03-25

    Markus is it possible when using the scripting interface to also update the versions of libraries referenced within the library manager? This would be very interesting, we have a few instances of libraries that reference other libraries. We also have Template projects that should be updated to have reference to the current version of libraries. If I can script the library manager interface then we will move to this method for versioning in the very near future.

     
  • Anonymous - 2014-03-25

    Originally created by: M.Schaber

    Hi, David,

    You can use the script interface to modify the referenced libraries in a library manager object.

    However, you should carefully check whether placeholders may be the better solution for your problem than hardcoding library references (whether those are updated via script or manually).

    I did attach two python scripts working on the lib man object as examples.

    LibManPrintAllDeps.py [657 Bytes]

    LibManObjectTest.py [1.13 KiB]

     
  • Bakkertje - 2016-01-13

    Hi,

    We are busy to set-up a Continuous build system and I have the a question about this.
    Is it possible to run the Static Analysis from the Test Manager and add the results (or a summary) to the test report?
    Or to run the Static Analysis by starting Codesys with a command line option? (and save the results in a file)

    Regards, Bakkertje

    I use Codesys V3.5 SP7 Patch 2, Test Manager 4.0.1.1, Static Analysis 4.0.2.0 and SVN 4.0.3.0

     
  • mkeller - 2016-01-14

    Hi.

    We have the improvement SAN-22 listed in our Jira tracker and it will provide a scripting API for the Static Analysis.

    For now, you could manually configure the rules in the project settings and use a test script to execute the command "Run Static Analysis" and add the messages to the test report.

    BR
    Martin

     
  • Bakkertje - 2016-01-14

    Hi Martin,

    Thanks for the reply.

    What do you mean with: >Zitat:
    use a test script to execute the command "Run Static Analysis" and add the messages to the test report.

    Run the command TestManager.Scripting with ExecuteScript ?
    If the answer is yes. Do you have an example of this script? (I'am a newbie with Python scripts )

    Regards, Bakkertje

     
  • mkeller - 2016-01-14

    Hi Bakkertje.

    Bakkertje hat geschrieben:
    Run the command TestManager.Scripting with ExecuteScript ?
    If the answer is yes. Do you have an example of this script? (I'am a newbie with Python scripts )

    If you have the CODESYS Test Manager for Automation Platform then you can use the command "ExecuteCommand" from CoDeSys.Base for executing the command "Run Static Analysis". To add the messages to the test report you use the test command "FindMessage" from TestManager.System.

    Or you can use the following example as base for your own python script and execute it by adding the necessary parameters to your command line:

    system.commands["staticanalysis", "run"].execute()
    msgs = system.get_message_objects("{97F48D64-A2A3-4856-B640-75C046E37EA9}")
    for msg in msgs:
    Β  Β if msg.prefix == "SA":
    Β  Β Β  Β print("%s%s: %s" % (msg.prefix, msg.number or "", msg.text)
    

    BR
    Martin

     
    • k4zz - 2024-03-15

      Hallo Martin,

      Thank you so much for the Code example. It works really fine for .porject Types. However, I encountered a challenge when attempting to apply it to .library Types.

      I also tried the option to "Perform static analysis automatically after compilation"

      # get Project values
      myProject = projects.primary
      
      # Creates an active application
      app = myProject.active_application
      
      # build Application and run static code analysis 
      app.generate_code()
      

      Could you please offer any insights into why this might be occurring?

       
    • k4zz - 2024-03-15
       

      Last edit: k4zz 2024-03-15
    • k4zz - 2024-03-15
       

      Last edit: k4zz 2024-03-15
    • k4zz - 2024-03-15
       

      Last edit: k4zz 2024-03-15
    • k4zz - 2024-03-15
       

      Last edit: k4zz 2024-03-15
  • jking22 - 2016-01-14

    All,

    This is really good information... We had tried to incorporate Static analysis into reporting some time ago without success. (I don't think it was possible then).

    1) Regarding the object ID (97F48D64-A2A3-4856-B640-75C046E37EA9) Is this valid for all users or is it license/computer/customer specific?

    2) I've heard you (3S/Codesys) use Jenkins internally for CI. I think it might be good for other forum members to be aware of this when implementing version control. We started out using Cruise Control.NET and still use it for unit testing 2.3 projects, but we currently use Jenkins for 3.x. For those unfamiliar... Jenkins is free. It's easy to use and has over a thousand plugins and it's language agnostic, so check it out if you're evaluating CI solutions.

    We're in pretty good shape now, but it would be really cool to see:
    a. Some sort of Codesys/Jenkins "How To" Document or Webinar.
    b. A Jenkins Plugin to make CI even easier.
    - Version Control
    - Roll Version
    - Static Analysis
    - Unit Test
    - Packaging
    - Deployment
    - Documentation/Reporting
    - etc...

    Regards,

    John.

     
  • Anonymous - 2016-01-14

    Originally created by: M.Schaber

    Hi, John,

    jking22 hat geschrieben:
    This is really good information... We had tried to incorporate Static analysis into reporting some time ago without success. (I don't think it was possible then).
    1) Regarding the object ID (97F48D64-A2A3-4856-B640-75C046E37EA9) Is this valid for all users or is it license/computer/customer specific?

    This GUID / UUID is not an Object ID, but it identifies the message category of the compiler messages. You can use the following three methods of "system" to dump info about existing message catebories, or find the Guid to an interesting category:

        /// <summary>
        /// Gets all message categories.
        /// </summary>
        /// <param name="bActive">If set to <c>true</c> (the default), only the active ones (those
        /// which had at least one message since the current codesys instance was started) are
        /// returned. If set to false, all categories existing in the current installation are
        /// returned.</param>
        /// <returns>A list of guids.</returns>
        IList<Guid> get_message_categories(bool bActive = true);
    
        /// <summary>
        /// Gets a description for the secified message category.
        /// </summary>
        /// <param name="category">The category.</param>
        /// <returns>The description of that message category.</returns>
        string get_message_category_description(Guid category);
    

    Note that the description string is localized, and thus will vary between installations (and might change in newer versions), but the GUID is expected to remain constant.

    jking22 hat geschrieben:
    2) I've heard you (3S/Codesys) use Jenkins internally for CI. I think it might be good for other forum members to be aware of this when implementing version control. We started out using Cruise Control.NET and still use it for unit testing 2.3 projects, but we currently use Jenkins for 3.x. For those unfamiliar... Jenkins is free. It's easy to use and has over a thousand plugins and it's language agnostic, so check it out if you're evaluating CI solutions.
    We're in pretty good shape now, but it would be really cool to see:
    a. Some sort of Codesys/Jenkins "How To" Document or Webinar.
    b. A Jenkins Plugin to make CI even easier.
    - Version Control
    - Roll Version
    - Static Analysis
    - Unit Test
    - Packaging
    - Deployment
    - Documentation/Reporting
    - etc...

    I'll forward that info to our webinar guys and trainers.

     
  • Bakkertje - 2016-01-18

    Hi Martin,

    Thanks this works fine. I run this from the Test manager now and collect the result in a global variable "sSAinfo". Because the "print()" is not visible in the test report.

    system.commands["staticanalysis", "run"].execute()
    sSAinfo = "Messages: "
    msgs = system.get_message_objects("{97F48D64-A2A3-4856-B640-75C046E37EA9}")
    for msg in msgs:
    Β  if msg.prefix == "SA":
    Β  Β  sSAinfo = sSAinfo + msg.prefix + str(msg.number) + ": "Β  + msg.text + ".<br/>Β  "
    sSAresult = msg
    

    Where can I find which column names are available? I cannot found a explanation in the help. Now I see the: msg.prefix, msg.number and msg.text.
    But I want to sort and show also the first column with the "type": Error, Warning or Information. What is the name of this column?

    Regards, Bakkertje

     
  • mkeller - 2016-01-18

    Hi Bakkertje.

    Bakkertje hat geschrieben:
    Where can I find which column names are available? I cannot found a explanation in the help. Now I see the: msg.prefix, msg.number and msg.text.
    But I want to sort and show also the first column with the "type": Error, Warning or Information. What is the name of this column?

    Well, the first column in the message view is "Description" but the content is put together from the following properties: severity, prefix, number, text

    BR
    Martin

     

Log in to post a comment.