【问题标题】:Remove remote branch from a Jenkins job从 Jenkins 作业中删除远程分支
【发布时间】:2018-03-06 17:54:00
【问题描述】:

我在 Jenkins 中为我的 Git 存储库(Git on TFS online)进行了维护工作,以删除与特定不匹配的分支条件或陈旧的分支。运行作业时会这样说:

Going to remove branch development/Batch_R7
fatal: InvalidOperationException encountered.
   Showing a modal dialog box or form when the application is not running in 
UserInteractive mode is not a valid operation. Specify the ServiceNotification 
or DefaultDesktopOnly style to display a notification from a service 
application.
bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://everisidbtfs.visualstudio.com': No 
error

我从 Powershell 脚本运行此命令。

其他 Git 命令在该 Powershell 脚本中运行良好,例如获取分支列表。

如果我从 Jenkins 服务器(或任何其他机器)中的 Powershell 命令行运行 PowerShell 脚本,它可以正常工作。

TFS 用户有权删除遥控器,并向 Jenkins 作业提供凭据。

这是我用来删除分支的 Git 命令:

git push --porcelain --progress --recurse-submodules=check origin :refs/heads/<branch_name>

有什么解决方法吗?我做错了什么?

我想到,由于 git 命令是“写入”操作(推送),可能 Jenkins 中存在一些安全限制...我在自动化脚本中使用的其余 git 命令是“只读”。

【问题讨论】:

    标签: git powershell jenkins tfs


    【解决方案1】:

    我想到的是,由于 git 命令是一个“写入”操作(推送),所以 Jenkins 可能存在一些安全限制......

    完全正确:所有其他操作都在 repo 本地,除了需要身份验证的推送操作。您需要确保在 Jenkins 中执行脚本的帐户具有正确的凭据。如果使用的 https URL 中没有身份验证信息,则意味着它应该依赖于

    【讨论】:

    • 嗯...我已经安装了 Windows Credential Store 和 Credential Plugin,但是由于 Jenkins 使用 SYSTEM 帐户运行(因为它默认作为 Windows 服务运行)我认为问题是与此相关...凭据是为我的 Windows 管理员用户存储的。我会看看它,让你知道!如果可能的话,我想避免与 SYSTEM 用户混淆 :) 非常感谢!!!
    • 使用我存储的凭据以普通用户身份启动 Jenkins 服务工作正常。
    猜你喜欢
    • 1970-01-01
    • 2023-01-12
    • 2016-07-08
    • 1970-01-01
    • 2013-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-28
    相关资源
    最近更新 更多