bash - 脚本在 Windows 中运行,但在 Jenkins 中失败
问题描述
我有一个 bash 脚本:
C:/Jenkins/workspace/xmlstarlet-1.6.1-win32/xmlstarlet-1.6.1/xml.exe ed -L -s "/Package/types[name='$TYPENAME']" -t elem -n members -v "$ENTITY" $SCRIPTFILE
C:/Jenkins/workspace/xmlstarlet-1.6.1-win32/xmlstarlet-1.6.1/xml.exe ed -L -s "/Package" -t elem -n types -v "" $SCRIPTFILE
它在 xml 中插入特定类型的节点,这在本地运行良好,但是当尝试通过任何脚本运行时,它会失败:
蚂蚁脚本:
<exec executable="C:\Program Files\Git\bin\bash.exe" osfamily="windows">
<arg value="generate_package.sh" />
<arg value="C:/Jenkins/workspace/TrailheadBranchDemo/final.txt" />
<arg value="package" />
<arg value="C:/Jenkins/workspace/deploy/src" />
</exec>
错误消息:无效的表达式:C:/Program Files/Git/Package
它无法选择/Package
or/Package/types[not(*)]
表达式。
解决方案
问题是:
在 Windows 上,bash 脚本的工作方式如下:
$ C:/Jenkins/workspace/xmlstarlet/xmlstarlet/xml.exe ed -L -i "Package" -t attr -n xmlns -v "http://soap.sforce.com/2006/04/metadata" C:/Jenkins/workspace/deploy/src/package.xml
而不是这个:
$ C:/Jenkins/workspace/xmlstarlet/xmlstarlet/xml.exe ed -L -i '/Package' -t attr -n xmlns -v "http://soap.sforce.com/2006/04/metadata" C:/Jenkins/workspace/deploy/src/package.xml
在/Package
Windows 中不能很好地识别。
推荐阅读
- python - 如何将图像添加到我通过 streamlit 在本地托管的 python 股票预测 Web 应用程序?
- android - 带条件触发器的 SingleLiveEvent
- android - Kotlin 按钮加载 RecyclerView 数据 - 需要按两次
- telegram - 如何使用 python-telegram-bot API 将 telegram.User 对象添加到 telegram.Chat 以构建测试
- java - 如何从 android WebView 应用程序中使用 PHP Curl?
- html - 为什么我看不到我的导航栏,一切正常
- apache - LiteSpeed(或 apache)重写以从 mirror.com 中隐藏 SUBFOLDERS domain.com 和 www.domain.com
- macos - 在 Swift 中获取有关显卡的信息
- swift - 从 TableView 标头访问 UITableViewController 委托
- c# - 无论点数如何,如何在二维网格上形成一个盒子