I'm working on a project involving Apple Script and I can not manage to set it up correctly in the GitLab runner. No matter what I do it seems the gitlab-runner does not see any running applications, see following execution (Terminal is also running, I see it open in by screen sharing):
$ ps -axj | grep applee # To check System Events is running
_appleevents 349 1 349 0 1 S ?? 0:05.01 /usr/sbin/distnoted agent
main 71925 71816 71810 0 1 S ?? 0:00.00 grep applee
_appleevents 77279 1 77279 0 0 Ss ?? 0:00.56 /System/Library/CoreServices/appleeventsd --server
$ osascript -e 'tell application "Terminal" to do script "echo hello"' || true
31:53: execution error: Terminal got an error: Application isn’t running. (-600)
$ osascript -e 'tell application "System Events" to get every process' || true
40:53: execution error: System Events got an error: Application isn’t running. (-600)
same thing happens if I try to access by application id as suggested here
$ ps -axj | grep applee # To check System Events is running
_appleevents 349 1 349 0 1 S ?? 0:05.03 /usr/sbin/distnoted agent
main 76150 76026 76020 0 1 S ?? 0:00.00 grep applee
_appleevents 77279 1 77279 0 0 Ss ?? 0:00.60 /System/Library/CoreServices/appleeventsd --server
$ osascript -e 'tell application id "com.apple.terminal" to do script "echo hello"' || true
44:66: execution error: Terminal got an error: Application isn’t running. (-600)
$ osascript -e 'tell application id "com.apple.systemevents" to get every process' || true
52:65: execution error: System Events got an error: Application isn’t running. (-600)
If I access the runner via ssh or Screen Sharing and I launch any of these commands in the ssh/Terminal, they work perfectly in both methodologies shown above.
I've also tried to kill the System Events process so it would be respawned and nothing changed. Tried also to run osascript with sudo
in front, nothing changed either.
Moreover, it's not a matter of settings:
gitlab-runner, AEServer and Terminal have all Accessibility permissions enabled.
gitlab-runner and Terminal have Automation permissions enabled for the 'System Events' application.
I do not know what else to try or how to configure the gitlab-runner so osascript can see the running applications. Any help or idea would be appreciated.