Customizing deployment #112

Closed
wants to merge 3 commits into
from

Projects

None yet

2 participants

@davidfowl
Member

If the repository has a deploy.cmd at the root, we will call into this instead of doing our own build/deployment. When using this, the user takes over the entire process, with full control.

When the batch file is called, some settings are made available to it via env variable:

  • SOURCE has the path to the sources (which is the repo folder)
  • TARGET has the path to where the deployment needs to go (which is the wwwroot folder)
@davidebbo davidebbo commented on the diff Jun 20, 2012
Kudu.Core/Deployment/CustomBuilder.cs
+
+ private const string SourcePath = "SOURCE";
+ private const string TargetPath = "TARGET";
+ private const string DeployCmd = "deploy.cmd";
+
+ public CustomBuilder(string repositoryPath, string targetFile)
+ {
+ _repositoryPath = repositoryPath;
+ _targetFile = targetFile;
+ }
+
+ public Task Build(DeploymentContext context)
+ {
+ var tcs = new TaskCompletionSource<object>();
+
+ ILogger customLogger = context.Logger.Log("Running custom deployment..");
@davidebbo
davidebbo Jun 20, 2012 Member

Should be 1 or 3 periods. Two is weird :)

@davidebbo davidebbo commented on the diff Jun 20, 2012
Kudu.Core/Deployment/CustomBuilder.cs
+ {
+ string targetFile = Path.Combine(repositoryRoot, DeployCmd);
+ customDeploymentFile = null;
+
+ if (File.Exists(targetFile))
+ {
+ customDeploymentFile = targetFile;
+ return true;
+ }
+
+ return false;
+ }
+
+ private Executable GetExecutable()
+ {
+ // Creates an executable poiting to Deploy.cmd and the working directory being
@davidebbo
davidebbo Jun 20, 2012 Member

typo: 'pointing'

@davidebbo davidebbo commented on the diff Jun 20, 2012
Kudu.Core/Deployment/CustomBuilder.cs
+ public CustomBuilder(string repositoryPath, string targetFile)
+ {
+ _repositoryPath = repositoryPath;
+ _targetFile = targetFile;
+ }
+
+ public Task Build(DeploymentContext context)
+ {
+ var tcs = new TaskCompletionSource<object>();
+
+ ILogger customLogger = context.Logger.Log("Running custom deployment..");
+
+ Executable exe = GetExecutable();
+ exe.EnvironmentVariables[SourcePath] = _repositoryPath;
+ exe.EnvironmentVariables[TargetPath] = context.OutputPath;
+
@davidebbo
davidebbo Jun 20, 2012 Member

Should put msbuild on path, but we can add that logic in a later commit

@davidebbo davidebbo commented on the diff Jun 20, 2012
Kudu.FunctionalTests/GitRepositoryManagementTests.cs
+ string repositoryName = "WapWithCustomDeploymentScript";
+ string appName = KuduUtils.GetRandomWebsiteName("WapWithCustomDeploymentScript");
+ string cloneUrl = "https://github.com/KuduApps/CustomBuildScript.git";
+
+ using (var repo = Git.Clone(repositoryName, cloneUrl))
+ {
+ ApplicationManager.Run(appName, appManager =>
+ {
+ // Act
+ GitDeploymentResult deployResult = appManager.GitDeploy(repo.PhysicalPath);
+ var results = appManager.DeploymentManager.GetResultsAsync().Result.ToList();
+
+ // Assert
+ Assert.Equal(1, results.Count);
+ Assert.Equal(DeployStatus.Success, results[0].Status);
+ KuduAssert.VerifyUrl(appManager.SiteUrl, "DEBUG");
@davidebbo
davidebbo Jun 20, 2012 Member

Where does "DEBUG" string come from? Something returned by the root of the site when you hit it?

@davidebbo
Member

Looks good

@davidfowl davidfowl closed this Jun 20, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment