You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Gitlab CI Pipeline执行成功但未在PTC Windchill创建检查点

GitLab CI Pipeline执行成功但无法在PTC Windchill服务器创建检查点

问题描述

我有一个包含PowerShell脚本的GitLab CI Pipeline,执行状态显示成功,但未达到预期效果——无法在PTC Windchill服务器上创建检查点。但在同一GitLab Runner代理的Windows PowerShell中直接运行相同脚本时一切正常,且该脚本在Jenkins Pipeline里也能完美运行。脚本本身用于连接PTC Windchill服务器,直接运行时连接正常,放到GitLab Pipeline中就失效了。

.gitlab-ci.yml 配置

build-job: 
 stage: build 
 script:
    - '"C:\Program Files (x86)\Integrity\ILMClient11\bin\mksAPIViewer.exe" --iplocal --xml si checkpoint --hostname=test --port=7001 --label="TA/test" --project=test'

Pipeline 执行日志

Running with gitlab-runner 15.0.0 (febb2a09)
  on Scriptrunner-Shared-Q BcVqDFkp
Resolving secrets
00:00
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:00
Running on DEGTSECE092...
Getting source from Git repository
00:01
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in C:/DevApps/GitLabRunner/builds/BcVqDFkp/0/dvcs/defurq/sandbox/.git/
Checking out 54d3bf5a as main...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:01
$ echo "just for teting"
just for teting
$ (dir 2>&1 *`|echo CMD);&<# rem #>echo PowerShell
PowerShell
$ Start-Process "C:\Program Files (x86)\Integrity\ILMClient11\bin\mksAPIViewer.exe" -ArgumentList "--iplocal --xml si checkpoint --hostname=mks.de.miele.net --port=7001 --label=TA/test --project=/Playground/EC_Spielwiese/Furqan_project/project.pj" >C:\Users\yygte56\Desktop\test\cmdtest.txt
Cleaning up project directory and file based variables
00:00
Job succeeded

排查方向

  • 执行上下文差异:GitLab Runner的Shell executor默认可能用不同的用户权限或环境变量运行。对比直接运行PowerShell时的用户(比如是否为管理员)和GitLab Runner服务的运行用户,确保后者有足够权限访问Windchill服务器和本地的mksAPIViewer工具。
  • 修正Start-Process的异步行为:日志显示使用了Start-Process,该命令默认异步启动进程,GitLab CI可能在进程未完成时就结束任务。可以改成直接调用exe,或者添加-Wait参数强制等待进程执行完毕:
    Start-Process "C:\Program Files (x86)\Integrity\ILMClient11\bin\mksAPIViewer.exe" -ArgumentList "--iplocal --xml si checkpoint --hostname=mks.de.miele.net --port=7001 --label=TA/test --project=/Playground/EC_Spielwiese/Furqan_project/project.pj" -Wait -NoNewWindow >C:\Users\yygte56\Desktop\test\cmdtest.txt
    
  • 查看工具输出日志:当前仅把输出重定向到本地文件,建议在CI脚本中打印该文件内容,或者直接在CI中输出工具的执行日志,排查mksAPIViewer是否返回错误信息。
  • 对比环境变量:直接运行PowerShell时的环境变量可能与GitLab Runner的环境不一致,比如是否存在Windchill相关配置变量。可以在CI脚本中添加Get-ChildItem Env:命令输出所有环境变量,与直接运行时的环境做对比。

内容的提问来源于stack exchange,提问作者Khani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 08:40:48