为什么rsync因jenkins而失败(Why rsync fails with jenkins)
当rsync与jenkins一起用作CentOS 6.4上的Execute shell Command时,它会失败:
[workspace] $ /bin/sh -xe /tmp/hudson3424899639384884888.sh + rsync -av /var/lib/jenkins/jobs/myjob/workspace/target/classes/ myuser@myserver.com:/home/myuser/test rsync: Failed to exec ssh: Permission denied (13) rsync error: error in IPC code (code 14) at pipe.c(84) [sender=3.0.6] rsync: connection unexpectedly closed (0 bytes received so far) [sender] rsync error: error in IPC code (code 14) at io.c(600) [sender=3.0.6]
但是,它可以从命令行运行:
su jenkins rsync -av /var/lib/jenkins/jobs/myjob/workspace/target/classes/ myuser@myserver.com:/home/myuser/test sending incremental file list sent 17875 bytes received 83 bytes 3990.67 bytes/sec total size is 1981027 speedup is 110.31
要使其在詹金斯中发挥作用还需要做些什么?
When rsync is used with jenkins as Execute shell Command on CentOS 6.4, it fails:
[workspace] $ /bin/sh -xe /tmp/hudson3424899639384884888.sh + rsync -av /var/lib/jenkins/jobs/myjob/workspace/target/classes/ myuser@myserver.com:/home/myuser/test rsync: Failed to exec ssh: Permission denied (13) rsync error: error in IPC code (code 14) at pipe.c(84) [sender=3.0.6] rsync: connection unexpectedly closed (0 bytes received so far) [sender] rsync error: error in IPC code (code 14) at io.c(600) [sender=3.0.6]
However, it works from the command line:
su jenkins rsync -av /var/lib/jenkins/jobs/myjob/workspace/target/classes/ myuser@myserver.com:/home/myuser/test sending incremental file list sent 17875 bytes received 83 bytes 3990.67 bytes/sec total size is 1981027 speedup is 110.31
What has to be done to make it work in jenkins as well?
原文:https://stackoverflow.com/questions/30743180
最满意答案
通常建议专注于使代码尽可能清晰和合理,而不必担心微观优化或其他因素。 在你的情况下,第一个是更好的选择,因为大多数程序员更习惯于按照这个顺序遍历一个数组。
两个版本都会得到相同的结果(因为它们已正确实施)并且具有完全相同的运行时间。
编辑:@Zane在评论中提到,前一个循环回到零速度更快。 原因是,将变量与零比较的速度更快。 鉴于那些日子电脑的速度要慢得多,这种优化被鼓励了。 那些日子确实结束了......
It's usually recommended to concentrate on making code as clear and as logical as possible, without worrying about micro-optimizations or other factors. In your case, the first one is the better choice, since most programmers are more used to traverse an array in that order.
Both versions will have the same result (given that they're implemented correctly) and will have exactly the same run time.
EDIT: @Zane mentioned in a comment that looping backwards to zero was faster some time ago. It was, the reason for it was that comparing a variable to zero was faster. Given that computers were much much slower those days, such optimizations were encouraged. Those days are indeed over...
相关问答
更多-
对于整数,前后增量之间没有差别。 如果i是一个非平凡类的对象,那么++i通常是首选,因为对象被修改然后被评估,而i++在评估之后修改,因此需要复制。 For integers, there is no difference between pre- and post-increment. If i is an object of a non-trivial class, then ++i is generally preferred, because the object is modified and t ...
-
您可以将整数值传递给v-for以呈现一系列值: new Vue({ el: '#app', data() { return { numberOfRanking: 4, } } })
这个'为'循环停止,为什么/为什么不?(Does this 'for' loop stop, and why/why not? for (var i=0; 1/i > 0; i++) { })[2023-04-17]
(我不是元内容的粉丝,但是: gotnull的和le_m的答案都是正确的和有用的,他们原来是,而且更多的是在这个社区Wiki发布后进行的编辑,这个CW的原始动机大部分是由于这些修改而导致的,但它仍然有用,所以...另外:虽然只列出了几个作者,但许多其他社区成员已经大大地帮助已经被折叠和清理的评论。不只是名义上的CW) 循环不会停止在正确实现的JavaScript引擎中。 (引擎的主机环境可能会终止它,因为它是无止境的,但另一回事。) 这就是为什么: 最初,当i为0 ,条件1/i > 0是真的,因为在Java ...一个++被称为后缀。 添加1到a,返回旧值。 ++ a被称为前缀。 添加1到a,返回新值。 C#: string[] items = {"a","b","c","d"}; int i = 0; foreach (string item in items) { Console.WriteLine(++i); } Console.WriteLine(""); i = 0; foreach (string item in items) { Console.WriteLine(i++); } 输 ...错误说: 运算符不是已知的二元运算符 原因很简单:您需要在操作员和开口花括号之间添加一个空格: i++ { ^ 如果没有,编译器会将++{作为二元运算符,以i和print("hello")作为参数 该问题不会出现在增量运算符的前缀版本中,因为i变量明确区分了++运算符和大括号(字母和数字不能用于定义运算符)。 The error says that: Operator is not a known binary operator The cause is very simple: you need ...如何在循环中回显$ i ++?(How to echo $i++ in the loop?)[2022-04-22]
您需要通过Wordpress中的set_query_var传递变量 // When calling a template with get_template_part() set_query_var('iNew', $iNew++); get_template_part( 'template-parts/content', 'art-small-new' ); 在模板中,您需要通过get_query_var提取它 $iNew = get_query_var('iNew'); You need to p ...为什么在for循环中“++ i”和“i ++”之间有什么区别?(Why is there any difference between “++i” and “i++” in a for loop?)[2023-03-16]
在一些处理器上,例如PDP-11,VAX-11和68K,有些指令的模式相当于*ptr++和*--ptr 。 根据编写代码的确切方式,编译器可能也可能不容易使用这些指令 - 因此,使用*++ptr或*ptr++的“正确”变体[这更好地取决于在循环内部的实际循环中的使用可以在这些特定情况下在性能上产生相当大的差异。 然而,对于ARM和x86(我认为,PowerPC和MIPS,因此涵盖了几乎所有现代处理器),这种类型的构造无论如何都不是指令集的一部分,而编译器现在比它们更加聪明,比如说,10年或20年前。 任何合 ...通常建议专注于使代码尽可能清晰和合理,而不必担心微观优化或其他因素。 在你的情况下,第一个是更好的选择,因为大多数程序员更习惯于按照这个顺序遍历一个数组。 两个版本都会得到相同的结果(因为它们已正确实施)并且具有完全相同的运行时间。 编辑:@Zane在评论中提到,前一个循环回到零速度更快。 原因是,将变量与零比较的速度更快。 鉴于那些日子电脑的速度要慢得多,这种优化被鼓励了。 那些日子确实结束了...... It's usually recommended to concentrate on making ...只需增加$ i而不是两次。 尝试下面的例子: $i = 1; foreach (new DirectoryIterator('img/thumbnail') as $fileInfo) { if($fileInfo->isDot()) continue; echo "相关文章
更多- rsync 文件校验及同步原理及rsync server配置
- cms基本功能已经开发完成(rsync)
- MapReduce错误任务失败处理
- ThoughtWorks持续集成平台GO开源了
- Hadoop1.0.3 Namenode启动失败
- Hadoop伪分布安装
- 教你快速搭建Hadoop集群
- 双开微信历程....最终失败....
- 崩溃了,android 创建表失败。。 大家看看吧。。。
- 实例讲解Hadoop中的map/reduce查询(Python语言实现)
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)