简体   繁体   English

VSTS持续集成-更改SDK路径

[英]VSTS Continuous Integration - Change SDK path

I'm looking for a solution for a problem. 我正在寻找问题的解决方案。 That is arise during Continuous Integration. 这是在持续集成过程中出现的。 To run the build command on my agent I have to give the path of the sdk of my server where build is going to be run. 在我的代理运行构建命令我必须给我的服务器在哪里建立将要运行SDK的路径。 Normally the local.properties files are not part of git change list. 通常, local.properties文件不属于git change列表。 I have come to know that there are git hooks for running custom scripts but after reading more, it seems like they are made for some other purpose. 我知道有运行自定义脚本的git钩子,但在阅读了更多内容后,似乎它们是出于其他目的而制作的。

What I want is that after I push the code the sdk directory path in local.properties gets changed to reflect the sdk path of my server and whenever i pull the code from the remote repository, the path automatically changes back to my local sdk path. 我想的是,我以后推代码local.properties SDK目录路径被改变,以反映我的服务器的SDK路径,每当我从远程仓库拉码,路径会自动变回我的本地SDK路径。

Please suggest, should i use the git hooks for this purpose or is there any better solution you guys follow or know. 请建议,我应该使用git的钩用于此目的或者是有没有更好的解决办法,你们跟随或不知道。

Regards 问候

Okay, so i changed my approach. 好的,所以我改变了方法。 I used a powershell script as part of my build. 我将Powershell脚本用作构建的一部分。 So in the build pipeline before gradle build i added the powershell script task. 因此,在gradle构建之前的构建管道中,我添加了powershell脚本任务。 After the agent copies the source code to the server the script runs and add a local.properties file with the path of the android sdk (server's). 代理将源代码复制到服务器后,脚本将运行并添加带有android sdk(服务器)路径的local.properties文件。 This was a more easier approach i believe. 我认为这是一种更简单的方法。

Any one looking for solution. 任何寻求解决方案的人。 All you have to do is to create a new file with .ps1 extension at the root of your project. 您要做的就是在项目的根目录下创建一个扩展名为.ps1的新文件。 Here is the code 这是代码

param([string] $fileName)
$sdkDir = "sdk.dir=C\:\\Users\\xyz\\AppData\\Local\\Android\\android-sdk" (path to your build server sdk)

Set-Content $fileName $sdkDir

the param will come from the argument section of the PowerShell Script task in build. 该参数将来自构建中PowerShell脚本任务的参数部分。 You simply have to pass local.properties. 您只需要传递local.properties。

This way the local.properties file won't be part of git change list. 这样,local.properties文件就不会成为git change list的一部分。 Hope this helps someone. 希望这对某人有帮助。 If you have any more questions regarding this feel free to ask. 如果您对此还有其他疑问,请随时提出。

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

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