【问题标题】:Send build artifacts over SSH - could not create directory通过 SSH 发送构建工件 - 无法创建目录
【发布时间】:2016-11-27 10:14:24
【问题描述】:

我正在尝试将更改从 jenkins 推送到 aws 的自动化过程。问题似乎是在 GIT 存储库中,我有 2 个文件夹,一个是 docroot,另一个是 database。我需要 docroot 进入 /var/www/html 并且数据库现在应该被忽略。

作为试运行,我正在尝试以下设置:

设置 1:

构建后操作

转移集下

Source files: **/*
Remove prefix: empty
Remote directory: empty
Exec command: pwd

结果: 错误:发布时出现异常,异常消息 [无法创建或更改目录。目录[数据库]] 构建步骤“通过 SSH 发送构建工件”将构建结果更改为不稳定 完成:不稳定

设置 2

构建后操作

转移集下

Source files: **/*
Remove prefix: empty
Remote directory: /var/www/html
Exec command: pwd

结果: 错误:发布时出现异常,异常消息 [无法创建或更改目录。目录 [var]] 构建步骤“通过 SSH 发送构建工件”将构建结果更改为不稳定 完成:不稳定

所有的错误似乎都围绕着创建一个目录——但我不需要创建一个......

【问题讨论】:

    标签: git jenkins ssh


    【解决方案1】:

    如果您用于此步骤的插件是Publish Over SSH Plugin,那么第一个调用点似乎就是在控制台中启用详细输出。要显示此选项,您必须单击带有服务器名称的下拉列表下的 Advanced... 按钮,您应该会看到如下内容:

    一旦你这样做了,而不是仅仅:

    ERROR: Exception when publishing, exception message [Could not create or change to directory. Directory [var]]
    Build step 'Send files or execute commands over SSH' changed build result to UNSTABLE
    

    你可能会看到这样的东西:

    SSH: Connecting from host [some.host]
    SSH: Connecting with configuration [Some Configuration] ...
    SSH: Creating session: username [user], hostname [x.x.x.x], port [22]
    SSH: Connecting session ...
    ...
    SSH: cd [/var/lib/module/]
    SSH: OK
    SSH: mkdir [var]
    SSH: FAILED: Message [Permission denied]
    

    这应该会给你一个可能是错误的线索。

    在您的情况下,您没有明确创建任何目录,但如果您切换 Remote directory 字段的帮助提示,您将看到:

    Optional destination folder.
    
    This folder will be below the one in the global configuration, if present.
    The folder will be created if does not exist.
    

    这表明您尝试pwd 的位置不存在,并且该插件正在帮助您尝试为您创建它,但您的用户没有这样做的权限。

    虽然用户权限可能是个问题,但如果您确定目录存在且不应该创建目录,请检查以下全局设置:

    Manage Jenkins -> Configure System -> Publish over SSH
    

    看看Remote Directory字段:

    假设那里指定了/home/sophie,那么插件将尝试将您的文件发送到/home/sophie/var/www/html,这不是您想要的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-24
      • 1970-01-01
      相关资源
      最近更新 更多