git Jenkins 使用通过 SSH 发布插件传输 0 个文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22158092/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 17:50:22  来源:igfitidea点击:

Jenkins transferring 0 files using publish over SSH plugin

gitsshjenkinscontinuous-integrationjenkins-plugins

提问by whitepatrick

I want to transfer files from my post build Jenkins workspace to a location on a remote server. Build goes smoothly for all steps in the job but always transfers 0 files.

我想将文件从我的后期构建 Jenkins 工作区传输到远程服务器上的某个位置。构建工作中的所有步骤都很顺利,但总是传输 0 个文件。

This is the console output:

这是控制台输出:

    Started by user Patrick
    Building in workspace /var/lib/jenkins/jobs/20eyes Build/workspace
    Fetching changes from the remote Git repository
    Fetching upstream changes from https://github.com/project/project.git
    using .gitcredentials to set credentials
    Checking out Revision a758e0f8e534271b999a2fc8696b6fd5a3d5e500 (origin/master)
    executing script:

    cd /var/www/20eyes-web
    [SSH] exit-status: 0
    SSH: Connecting from host [dev1.remotehost]
    SSH: Connecting with configuration [dev2.remotehost] ...
    SSH: Disconnecting configuration [dev2.remotehost] ...
    SSH: Transferred 0 file(s)
    Build step 'Send files or execute commands over SSH' changed build result to  SUCCESS
    Finished: SUCCESS

The job is configured to build after any commit is pushed to GitHub

作业被配置为在任何提交被推送到 GitHub 后构建

The transfer set is: Source Files:

传输集为: 源文件:

/var/lib/jenkins/jobs/20eyes Build/workspace/**/*

Remove prefix:

删除前缀:

/var/lib/jenkins/jobs/20eyes Build/workspace

回答by PhungLe

I thinks, problem at your config. We have 2 positions to configure.

我认为,您的配置有问题。我们有 2 个位置要配置。

  1. At System configuration (Global config). --> If test ok ==> Configuration to remote server is ok.
  2. At your project. We will focus about transfer set: (Source file, Remove prefix, remote directory)

    2.1 Source file : if it's blank = workspace directory. in your case i think you should input **/*
    2.2 Remove prefix : refer Herefor more info.
    2.3 Remote directory: if it's blank = directory that is configured at System configuration above.

  1. 在系统配置(全局配置)。--> 如果测试没问题 ==> 远程服务器的配置没问题。
  2. 在您的项目中。我们将关注传输集:(源文件、删除前缀、远程目录)

    2.1 源文件:如果为空=工作区目录。在您的情况下,我认为您应该输入**/*
    2.2 删除前缀:请参阅此处了解更多信息。
    2.3 远程目录:如果为空=上面系统配置中配置的目录。

Hope it help! Sorry about my English.

希望有帮助!对不起我的英语。

回答by Popa Andrei

Quick thing to try first: set the Source folder only with: **/* to see if any file is copied. If file was copied then take a look here to see how to write the correct path here

首先要快速尝试:仅使用以下命令设置源文件夹:**/* 以查看是否复制了任何文件。如果文件被复制,请查看此处以了解如何在此处写入正确的路径

回答by lu_ko

My advices:

我的建议:

  1. You should avoid using spaces in the Jenkins job name!
    • in your case: name 20eyes Buildcan produce some troubles in file/directory matching
  2. You should use relative paths and not absolute paths!
    • in your case: /var/lib/jenkins/...should be replaced by relative path from job's workspace
  3. You should NOT copy whole workspace!
    • specify only appropriate files from last build (e.g. WAR file from target directory)
  4. You should check documentation and examples of Publish Over plugins:
  1. 您应该避免在 Jenkins 作业名称中使用空格!
    • 在您的情况下:名称20eyes Build可能会在文件/目录匹配中产生一些麻烦
  2. 您应该使用相对路径而不是绝对路径!
    • 在您的情况下:/var/lib/jenkins/...应替换为作业工作区的相对路径
  3. 您不应该复制整个工作区!
    • 仅指定上次构建中的适当文件(例如,目标目录中的 WAR 文件)
  4. 您应该检查Publish Over 插件的文档和示例

回答by Shashi Ranjan

In my case I was using the absolute path(from root) in "Transfer Set Source Files:". When I changed the path relative to the workspace, It worked!

在我的情况下,我在“传输集源文件:”中使用了绝对路径(从根)。当我更改相对于工作区的路径时,它起作用了!