rkohser - 2023-12-05

Hi,

I am trying to build a CI/CD pipeline around our codesys projects.
The only entry point if the git url and branch, as we do not put our project file under source control, so we needed to find a way to git clone from the python scripting engine.
This is currently how we do this :

system.commands["Git", "Clone"].execute(
    "ProjectLocation=" + project_dir,
    "ProjectName=" + project_file_name,
    "RemoteUrl=" + project_git_remote_url,
    "GitProjectStoragePath=" + project_git_local_dir,
)
system.commands["Git", "Checkout", "Branch"].execute(
    "PrimaryProjectHandle=0", "BranchName=origin/" + project_git_branch
)

This works fine, except that, depending on the environment and the project, the "Project Environment" popup gets displayed to suggest for some updates, and waits for a user interaction, even with the "--noUI" flag injected as parameter.
I investigated the VersionUpdateFlags, but the problem is that the git clone is an atomic operation that clones and directly opens the generated project without the possibility to inject any updateFlags argument (only used in the ScripProjects.open() function.
I also tried to simulate some keyboard events acknowledge the window from script but I did not find the right location for the SendKeys statement, I think before the git clone call is too early and after is too late.
So I am wondering if there would be some other way to do that. Is there some more proper scripting api for the git add on ? Is there a global configuration of the VersionUpdateFlags that would allow the popup to be disabled outside from any project context ? Is there some way to automatically acknowledge this kind of messages in a "--noUI" mode ? What do you suggest ?

Thanks for your help,

Roland

Edit : I managed to solve my problem by following these steps in my pipeline :
- create a template of a project and opt file preconfigured not to open the popup
- open this project
- initialize an empty git repo
- add the remote, fetch and checkout the needed branch
-> no popup is displayed, hourra

Edit2 : The initial question was raised on a CODESYS V3.5 SP18 Patch 2 profile. Since CODESYS 3.5.19.30 a scripting API is available for Codesys Git that allows cloning a project with the support of VersionUpdateFlags https://content.helpme-codesys.com/en/CODESYS%20Git/_git_using_scripting.html

 

Last edit: rkohser 2024-01-19