jenkins中使用mkdir和rmdir拒绝访问 [英] access denied using mkdir and rmdir in jenkins

查看:324
本文介绍了jenkins中使用mkdir和rmdir拒绝访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Jenkins正在生成Visual Studio中制作的C ++项目的构建.

Jenkins is generating a build of a C++ project made in Visual Studio.

在此过程中,调用了某些.bat,其中之一具有这样的结构:

During the process, some .bats are called and in one of them, there is a structure like this:

SET TEMPDIR=Temp
rmdir %TEMPDIR% /S /Q
echo Don't continue if there was an error above (except the not found error which is ok) and go hand delete the dir!
:pause
mkdir %TEMPDIR%

我对批处理脚本不是很熟悉,但是当同时调用rmdirmkdir时,詹金斯给了我access denied.

I'm not very familiar to batch scripting, but when both rmdir and mkdir are called, Jenkins gives me access denied.

我查看了构建配置以搜索任何类型的读/写权限,但似乎没有任何权限.

I looked in the build configurations to search for any type of read/write permissions but it seems there isn't any.

我该如何解决?后来其他脚本尝试访问Temp,但是它们失败了,这破坏了我的构建.

How can I fix this? Later the other scripts try to access Temp but they fail and it breaks my build.

推荐答案

rmdir可能失败的某些原因:

Some of the reasons rmdir can fail:

  • 没有权限
  • 该目录包含文件.
  • 这是一个或多个进程的当前工作目录.
  • 进程已锁定.

mkdir可能失败的某些原因:

Some the reasons mkdir can fail:

  • 没有权限
  • 该目录已存在.

OP的脚本正在尝试在运行该脚本的进程的%CD%中创建一个名为"Temp"的目录.如果还有其他进程也在运行该脚本,或者由于某种原因而使用同一%CD%\Temp路径的任何进程,则创建或删除该路径都可能会失败.

The OP's script is attempting to create a directory named "Temp" in whatever the %CD% is for the process running that script. If there are other processes that also run that script, or any that avail themselves of the same %CD%\Temp path for any reason, then there can be failures for both creating or deleting that path.

在构建系统中很常见,因为有多个并行进程和线程在各种工作目录中运行各种程序/脚本.从cmd文件的任何实例的角度来看,与%CD%相关的任何路径实际上都是随机的.所有下降的CI构建系统都提供了环境变量,此类程序/脚本可使用这些环境变量来相对于某种形式的已知构建根(通常称为BuildRoot之类)正确定向自身.

It is common in build systems, for there to be multiple parallel processes and threads running a variety of programs/scripts in a variety of working directories. From the perspective of any instance of a cmd file, any path that is %CD% relative, is effectively random. All descent CI build systems provide environment variables that such programs/scripts can use to orient themselves correctly, relative to a known build root of some form, often called something like BuildRoot.

但是这里真正的问题是OP的脚本如何处理临时目录管理.它们根本不够强大,无法共享一个公共的临时目录.

But the real issue here is how the OP's scripts are handling temp directory management. They simply aren't robust enough to be sharing a common temp directory.

我要补充一点,一个好的CI构建系统,提供某种形式的每进程/线程临时目录,程序/脚本可以使用它们而无需进行任何目录管理.

I would add that a good CI build system, provides some form of per-process/thread temp directory, that programs/scripts can use without having to do any directory management.

这篇关于jenkins中使用mkdir和rmdir拒绝访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆