Incidental nice features: switching from system.util.execute to subprocess.call will include the output of the git command in the wrapper log, and switching from print to a system.util.getLogger object also adds in more hints about the source of the trigger.
INFO | jvm 1 | 2019/11/27 16:54:11 | I [c.revision_helper ] [16:54:11]: Updated ignition1:customer project-name=customer, request-origin=1.2.3.4, session-user=jbuser, session-project=customer, session-id=34947258
INFO | jvm 1 | 2019/11/27 16:54:11 | [master e78f6c9] Updated ignition1:customer
INFO | jvm 1 | 2019/11/27 16:54:11 | 4 files changed, 11 insertions(+), 8 deletions(-)
I
In case anyone lands here in the forum first, the IA team just recently put out an excellent whitepaper discussing issues and methods related to deploying Ignition on revision control like git:
Hi everyone! Future me, leaving more breadcrumbs of knowledge for others who follow…
As tempting as it may be, do NOT add resources.json or thumbnail.png to your gitignore, both will cause things to break. (tested circa Ignition 8.1.7)
Ignoring resources.json files will cause (sometimes cyclical) thrashing of the project files whenever you sync to a new checkout, but more importantly will totally break the newer method of saving named SQL queries to disk.
Ignoring thumbnail.png files would’ve been nice to avoid putting binaries in git, but the first time you update a server and gain views without those files, your log will be full of lines like this:
Error creating digest for resourceManifest=data/projects/Support/com.inductiveautomation.perspective/views/Page/Monitoring/resource.json, file=thumbnail.png
Error reading data for file thumbnail.png for resource at com.inductiveautomation.perspective/views/Page/Monitoring
###Fatal-An error occurred while reading project resources from disk. Disk-to-memory synchronization will not occur!
I hope that maybe IA can resolve the second and allow Ignition to sync up projects from disk without PNG files, but we’ve gotta leave them in for now.
A resource is comprised of everything inside the resource directory. You should ignore nothing.
We are, however, likely going to stop writing back an “externally modified” entry to the resource upon scanning it and noticing the signature is incorrect. We’ll just let it be wrong in the file and the in-memory / UI representation will still indicate there is a mismatch when necessary.
I for one love this. Our devs commit to Azure dev ops and I get the thumbnail of the view along with the code diff. Lots of time I don’t even need to open the designer to review changes. Just signoff right from the git commit.
Any news on the gateway event script? I have been looking for a script to run on gateway (ignition docker filesystem repo + git) for updating GitLab on save etc.
This is not documented in the Best Practice etc, only showing how to work with git on local PC.
You are taking your chances with system.util.execute. I don't think it waits for the process to run, so those three commands could execute out of order. Use java's ProcessBuilder to ensure things are sequential (and you can check for success).
{ Also, please format your code properly. Edit your comment, highlight the code, and click the </> button. }
time.sleep(5) is in the Best Practices from IA for using git.
Sadly I don't know how to code it on my own, abit surprised that there is no real good working example that covers what I do in the script I posted earlier.
Not better or worse. Just as evil. The problem is any kind of sleep (or infinite loop) tying up a thread. Event threads are typically part of a limited thread pool, impacting other tasks.