简体   繁体   English

如何正确设置詹金斯环境

[英]How to properly set up the jenkins environment

I have a fresh build server and need to setup jenkins there. 我有一个新的构建服务器,需要在此处设置詹金斯。 So I created a first user on the Mac mini, and used that user to install Jenkins on the machine. 因此,我在Mac mini上创建了第一个用户,并使用该用户在计算机上安装Jenkins。

Jenkins then created another user (Jenkins) on the Mac Mini. 然后,詹金斯在Mac Mini上创建了另一个用户(詹金斯)。 I thought that correct way to proceed is to login as that Jenkins user (with Admin rights) and prepare the build environment as this Jenkins user. 我认为正确的操作方法是以该Jenkins用户身份登录(具有管理员权限),并以该Jenkins用户身份准备构建环境。

But I cant install Visual Studio for MAC, cant install SourceTree... bcs even though Jenkins has Admin rights, I am getting 但是我无法安装Visual Studio for MAC,无法安装SourceTree ... bcs,即使Jenkins具有管理员权限,我却得到了

"You do not have permissions to open the application 'Install Visual Studio for Mac' contact your administrator..." message. 消息“您没有打开应用程序'为Mac安装Visual Studio'的权限,请联系管理员...”消息。

But as I said the Jenkins user is Admin user. 但是正如我所说的,詹金斯用户是管理员用户。 So am I doing it wrong? 那我做错了吗? What user should prepare all the build tools? 哪些用户应该准备所有构建工具? And if it is supposed to be the first user I created (after booting the Mac mini for the 1st time), how do I let Jenkins use the apps then? 如果应该是我创建的第一个用户(第一次启动Mac mini之后),那么我如何让Jenkins使用这些应用程序? When I tried doing this on my macbook, jenkins couldnt use some of the build tools, bcs apparently it did not have the permissions to do so. 当我尝试在Macbook上执行此操作时,jenkins无法使用某些构建工具,显然bcs没有这样做的权限。

So what is the correct way to set up a jenkins environment, so I can install whatever tools I need, and Jenkins can use these during builds/deploys? 那么,设置jenkins环境的正确方法是什么,以便我可以安装所需的任何工具,并且Jenkins可以在构建/部署期间使用这些工具?

Any help appreciated, all the guides about jenkins speak of jenkins user, but none gave me an idea what is the best way to set this all up. 任何帮助表示赞赏,所有有关jenkins的指南都提到了jenkins用户,但是没有一个让我知道什么是设置这一切的最佳方法。

My 2 cents. 我的2美分。

I have not worked with MAC. 我没有使用MAC。 So some of my assumptions may be wrong or suggestions may be not applicable to you. 因此,我的某些假设可能是错误的,或者建议可能不适用于您。

I have set up Jenkins mostly on Linux and a couple of times on Windows. 我主要在Linux上设置了Jenkins,在Windows上设置了几次。 I used to install Jenkins using the RPM package which, upon installation, will create a 'jenkins' user and group. 我曾经使用RPM软件包安装Jenkins,该软件包在安装时将创建一个'jenkins'用户和组。

  • For start/stop/restart, I always use 'sudo' since Jenkins is installed as a service. 对于启动/停止/重新启动,由于Jenkins是作为服务安装的,因此我始终使用“ sudo”。
  • Other build related tools like Java, Maven etc, I always make sure that Jenkins can access them and execute them. 其他与构建相关的工具,例如Java,Maven等,我始终确保Jenkins可以访问它们并执行它们。 ie, I give execute privilege on those tools. 即,我赋予那些工具执行特权。
  • The JENKINS_HOME directory, I used to create a symbolic link from the default home directory to a file system with enough storage. 我曾使用JENKINS_HOME目录创建从默认主目录到具有足够存储空间的文件系统的符号链接。 I will do the same for Jenkins log file. 我将对Jenkins日志文件执行相同的操作。 The benefit of having those Jenkins/tool files/directories as part of a custom defined directory structure is that I do not need to remember installation paths of each tool. 将这些Jenkins /工具文件/目录作为自定义定义的目录结构的一部分的好处是,我不需要记住每个工具的安装路径。 ie, I have my Jenkins, maven, java, sonarQube everything under a directory I know. 也就是说,我的Jenkins,maven,java,sonarQube都包含在我知道的目录下。 Even if I set up these tools in different servers, I will stick to the same directory structure. 即使我在不​​同的服务器上设置了这些工具,我也将坚持相同的目录结构。

My suggestions to you. 我对你的建议。

  1. Setup build tools which are to be used/accessed from Jenkins, set them up with your 'first user' and give execute privilege to Jenkins user/group. 设置要从Jenkins使用/访问的构建工具,并与您的“第一个用户”进行设置,并将执行特权授予Jenkins用户/组。
  2. Create a directory 'ci' and link or place all tools inside. 创建目录“ ci”,并将所有工具链接或放置在其中。 You can further have subdirectories for app - for binaries/installed files, data - for generated data like Jenkins_home, log - to keep log files of these tools. 您还可以具有app的子目录-二进制/已安装文件,数据-生成的数据(如Jenkins_home),log-保留这些工具的日志文件。

      ci/jenkins ci/sourcetree ci/apache-maven 

Suggestion 2 is initially time-consuming but it will save a lot of your time as you use the tools on a daily basis. 建议2最初很耗时,但是当您每天使用这些工具时,它将节省大量时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM