Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding filemanager with dragdrop - changes #144

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
40a9909
Dev (#47)
sanchitmehta Jun 4, 2019
1bb7575
Merged the dev into master
sanchitmehta Aug 19, 2019
f2d8346
Merge branch 'dev'
sanchitmehta Aug 19, 2019
0a5e658
Merge Dev into Master (#116)
sanchitmehta Apr 20, 2020
21d6f7f
Parse external deployment ID from zip push headers
jjk2673 May 29, 2020
791121c
Merge branch 'master' into feature/deployment-status-api
jjk2673 May 29, 2020
4fc0e31
Merge branch 'feature/deployment-status-api' into developer/jokleinf/…
jjk2673 May 29, 2020
33072a1
Persist new ID through changeset so it carries over to later deployme…
jjk2673 May 29, 2020
2a15325
Make usage consistent across all push deploy types
jjk2673 Jun 2, 2020
99f6367
fixed TryGetValues to TryGetValue and changed result data type
purva-vasudeo Aug 14, 2020
7a0fafb
Merge pull request #131 from purva-vasudeo/puvasude/api-bug-fix
jjk2673 Aug 14, 2020
77e127f
Kudu to FE call to update deployment status
purva-vasudeo Aug 17, 2020
6a21f68
Merge pull request #132 from purva-vasudeo/puvasude/deploy-api-final
purva-vasudeo Aug 31, 2020
de47f09
OneDeploy API - /publish and /api/publish (#134)
shrishrirang Sep 11, 2020
7e75ea6
Merge branch 'dev' into feature/deployment-status-api
jjk2673 Sep 28, 2020
7feeec4
Add external ID support for OneDeploy
jjk2673 Sep 28, 2020
47ff01b
Remove merge conflict artifact
jjk2673 Sep 28, 2020
4cb6cc5
Merge pull request #120 from Azure-App-Service/developer/jokleinf/add…
jjk2673 Sep 29, 2020
3978128
Clean up formatting and avoid posting deployment status if not using …
jjk2673 Sep 29, 2020
e777a5a
Refactor helper function for retrieving ID from request
jjk2673 Oct 3, 2020
acd0ceb
Refactor to commit deployment ID to NullRepository and use strings fo…
jjk2673 Oct 6, 2020
5f2be3c
Fix whitespace changes
jjk2673 Oct 6, 2020
7708143
Revert "Fix whitespace changes"
jjk2673 Oct 6, 2020
0c300fa
Revert changes to IRepo and HgRepo
jjk2673 Oct 6, 2020
2a209a0
Add back IRepo and HgRepo with correct line endings
jjk2673 Oct 6, 2020
42322b1
Added retry logic to retry 3 times with 5sec intervals (#137)
purva-vasudeo Oct 8, 2020
c433a90
PR feedback
jjk2673 Oct 9, 2020
98b330a
Add home page for Linux Consumption app (#138)
Hazhzeng Oct 10, 2020
9d75f3c
Update DeploymentId to ExternalDeploymentId
jjk2673 Oct 14, 2020
a195f47
Fix typo in pushdeploymentcontroller
jjk2673 Oct 14, 2020
13d45fb
Merge pull request #135 from Azure-App-Service/feature/deployment-sta…
jjk2673 Oct 19, 2020
624c1c3
adding filemanager with dragdrop
anandanthony Oct 21, 2020
f5dcacf
changes for dragdrop pr 139
anandanthony Oct 23, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public static class Constants
public const string WebRoot = "wwwroot";
public const string MappedSite = "/_app";
public const string RepositoryPath = "repository";
public const string ZipTempPath = "zipdeploy";
public const string ZipExtractPath = "extracted";
public const string ZipTempDirectoryName = "zipdeploy";
public const string ArtifactStagingDirectoryName = "extracted";

public const string LockPath = "locks";
public const string DeploymentLockFile = "deployments.lock";
Expand Down Expand Up @@ -100,6 +100,15 @@ public static TimeSpan MaxAllowedExecutionTime
public const string LogicAppUrlKey = "LOGICAPP_URL";

public const string RestartApiPath = "/api/app/restart";
public const string UpdateDeployStatusPath = "/api/app/updatedeploystatus";

// Deployment status API constants
public const string BuildRequestReceived = "BuildRequestReceived";
public const string BuildPending = "BuildPending";
public const string BuildInProgress = "BuildInProgress";
public const string BuildSuccessful = "BuildSuccessful";
public const string PostBuildRestartRequired = "PostBuildRestartRequired";
public const string BuildFailed = "BuildFailed";

public const string SiteExtensionProvisioningStateCreated = "Created";
public const string SiteExtensionProvisioningStateAccepted = "Accepted";
Expand All @@ -115,7 +124,7 @@ public static TimeSpan MaxAllowedExecutionTime
public const string FreeSKU = "Free";
public const string BasicSKU = "Basic";

//Setting for VC++ for node builds
// Setting for VC++ for node builds
public const string VCVersion = "2015";

public const string WebsiteSiteName = "WEBSITE_SITE_NAME";
Expand Down Expand Up @@ -165,5 +174,9 @@ public static TimeSpan MaxAllowedExecutionTime
public const string KuduFileShareMountPath = "/kudu-mnt";
public const string KuduFileSharePrefix = "kudu-mnt";
public const string EnablePersistentStorage = "ENABLE_KUDU_PERSISTENT_STORAGE";

public const string OneDeploy = "OneDeploy";

public const string ScmDeploymentIdHeader = "SCM-DEPLOYMENT-ID";
}
}
21 changes: 21 additions & 0 deletions Kudu.Contracts/Deployment/ArtifactType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Kudu.Contracts.Deployment
{
public enum ArtifactType
{
Unknown,
War,
Jar,
Ear,
Lib,
Static,
Startup,
Script,
Zip,
}
}
19 changes: 19 additions & 0 deletions Kudu.Contracts/Deployment/DeployStatusApiResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Kudu.Contracts.Deployment
{
public class DeployStatusApiResult
{
public DeployStatusApiResult(string DeploymentStatus, string DeploymentId)
{
this.DeploymentStatus = DeploymentStatus;
this.DeploymentId = DeploymentId;
}

public string DeploymentStatus { get; set; }

public string DeploymentId { get; set; }
}
}
39 changes: 35 additions & 4 deletions Kudu.Contracts/Deployment/DeploymentInfoBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
using System.Threading.Tasks;
using System.Collections;
using System.Collections.Generic;

using Kudu.Contracts.Deployment;

namespace Kudu.Core.Deployment
{
public abstract class DeploymentInfoBase
Expand All @@ -16,6 +17,9 @@ protected DeploymentInfoBase()
IsReusable = true;
AllowDeferredDeployment = true;
DoFullBuildByDefault = true;
WatchedFileEnabled = true;
RestartAllowed = true;
ArtifactType = ArtifactType.Unknown;
}

public RepositoryType RepositoryType { get; set; }
Expand All @@ -26,16 +30,32 @@ protected DeploymentInfoBase()
// Allow deferred deployment via marker file mechanism.
public bool AllowDeferredDeployment { get; set; }
// indicating that this is a CI triggered by SCM provider
public bool IsContinuous { get; set; }
public bool IsContinuous { get; set; }

// NOTE: Do not access the request stream in the Fetch handler as it may have been closed during asynchronous scenarios
public FetchDelegate Fetch { get; set; }
public bool AllowDeploymentWhileScmDisabled { get; set; }

public IDictionary<string, string> repositorySymlinks { get; set; }

// Optional.
// By default, TargetSubDirectoryRelativePath specifies the directory to deploy to relative to /home/site/wwwroot.
// This property can be used to change the root from wwwroot to something else.
public string TargetRootPath { get; set; }

// Optional.
// Path of the directory to be deployed to. The path should be relative to the wwwroot directory.
// Example: "webapps/ROOT"
public string TargetPath { get; set; }
public string TargetSubDirectoryRelativePath { get; set; }

// Optional.
// Specifies the name of the deployed artifact.
// Example: When deploying startup files, OneDeploy will set this to startup.cmd (or startup.sh)
public string TargetFileName { get; set; }

// Optional.
// Type of artifact being deployed.
public ArtifactType ArtifactType { get; set; }

// Optional.
// Path of the file that is watched for changes by the web server.
Expand Down Expand Up @@ -71,11 +91,22 @@ public bool IsValid()
// This is used in Run-From-Zip deployments where the content of wwwroot
// won't update until after a process restart. Therefore, we copy the needed
// files into a separate folders and run sync triggers from there.
public string SyncFunctionsTriggersPath { get; set; } = null;
public string SyncFunctionsTriggersPath { get; set; } = null;

// Specifies whether to touch the watched file (example web.config, web.xml, etc) after the deployment
public bool WatchedFileEnabled { get; set; }

// Used to allow / disallow 'restart' on a per deployment basis, if needed.
// For example: OneDeploy allows clients to enable / disable 'restart'.
public bool RestartAllowed { get; set; }

// If DoSyncTriggers is set to true, the after Linux Consumption function app deployment,
// will initiate a POST request to http://appname.azurewebsites.net/admin/host/synctriggers
public bool DoSyncTriggers { get; set; }

// Allows the use of a caller-provided GUID for the deployment, rather than
// a commit hash or a randomly-generated identifier.
public string ExternalDeploymentId { get; set; } = null;

// This config is for Linux Consumption function app only
// Allow artifact generation even when WEBSITE_RUN_FROM_PACKAGE is set to a Url (RunFromRemoteZip)
Expand Down
2 changes: 1 addition & 1 deletion Kudu.Contracts/IEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public interface IEnvironment
string RequestId { get; } // e.g. x-arr-log-id or x-ms-request-id header value
string KuduConsoleFullPath { get; } // e.g. KuduConsole/kudu.dll
string SitePackagesPath { get; } // e.g. /data/SitePackages
bool IsOnLinuxConsumption { get; } // e.g. True on Linux Consumption. False on App Service.
bool IsOnLinuxConsumption { get; } // Check if the application is a Linux Consumption function app
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@

namespace Kudu.Core.Deployment
{
public class ZipDeploymentInfo : DeploymentInfoBase
public class ArtifactDeploymentInfo : DeploymentInfoBase
{
private readonly IEnvironment _environment;
private readonly ITraceFactory _traceFactory;

public ZipDeploymentInfo(IEnvironment environment, ITraceFactory traceFactory)
public ArtifactDeploymentInfo(IEnvironment environment, ITraceFactory traceFactory)
{
_environment = environment;
_traceFactory = traceFactory;
}

public override IRepository GetRepository()
{
// Zip "repository" does not conflict with other types, including NoRepository,
// Artifact "repository" does not conflict with other types, including NoRepository,
// so there's no call to EnsureRepository
var path = Path.Combine(_environment.ZipTempPath, Constants.ZipExtractPath);
return new NullRepository(path, _traceFactory);
var path = Path.Combine(_environment.ZipTempPath, Constants.ArtifactStagingDirectoryName);
return new NullRepository(path, _traceFactory, ExternalDeploymentId);
}

public string Author { get; set; }

public string AuthorEmail { get; set; }

public string Message { get; set; }
// This is used if the deployment is Run-From-Zip
public string ZipName { get; set; }
public string Message { get; set; }
// Optional file name. Used by certain features like run-from-zip.
public string ArtifactFileName { get; set; }

// This is used when getting the zipfile from the zipURL
public string ZipURL { get; set; }
// This is used when getting the artifact file from the remote URL
public string RemoteURL { get; set; }
}
}
71 changes: 49 additions & 22 deletions Kudu.Core/Deployment/DeploymentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Kudu.Contracts.Deployment;
using Kudu.Contracts.Infrastructure;
using Kudu.Contracts.Settings;
using Kudu.Contracts.Tracing;
Expand Down Expand Up @@ -195,8 +196,8 @@ public async Task DeployAsync(
"The current deployment branch is '{0}', but nothing has been pushed to it",
targetBranch));
}
}

}
string id = changeSet.Id;
IDeploymentStatusFile statusFile = null;
try
Expand Down Expand Up @@ -293,12 +294,24 @@ public async Task DeployAsync(
}
}

public async Task RestartMainSiteIfNeeded(ITracer tracer, ILogger logger)
public async Task RestartMainSiteIfNeeded(ITracer tracer, ILogger logger, DeploymentInfoBase deploymentInfo)
{
// If post-deployment restart is disabled, do nothing.
if (!_settings.RestartAppOnGitDeploy())
{
return;
}

// Proceed only if 'restart' is allowed for this deployment
if (deploymentInfo != null && !deploymentInfo.RestartAllowed)
{
return;
}

if (deploymentInfo != null && deploymentInfo.Deployer == Constants.OneDeploy)
{
await PostDeploymentHelper.RestartMainSiteAsync(_environment.RequestId, new PostDeploymentTraceListener(tracer, logger));
return;
}

if (_settings.RecylePreviewEnabled())
Expand Down Expand Up @@ -632,7 +645,7 @@ private async Task Build(
{
using (tracer.Step("Determining deployment builder"))
{
builder = _builderFactory.CreateBuilder(tracer, innerLogger, perDeploymentSettings, repository);
builder = _builderFactory.CreateBuilder(tracer, innerLogger, perDeploymentSettings, repository, deploymentInfo);
deploymentAnalytics.ProjectType = builder.ProjectType;
tracer.Trace("Builder is {0}", builder.GetType().Name);
}
Expand Down Expand Up @@ -703,8 +716,7 @@ private async Task Build(
{
await builder.Build(context);
builder.PostBuild(context);

await RestartMainSiteIfNeeded(tracer, logger);
await RestartMainSiteIfNeeded(tracer, logger, deploymentInfo);

if (FunctionAppHelper.LooksLikeFunctionApp() && _environment.IsOnLinuxConsumption)
{
Expand All @@ -725,14 +737,11 @@ await PostDeploymentHelper.SyncFunctionsTriggers(
new PostDeploymentTraceListener(tracer, logger),
deploymentInfo?.SyncFunctionsTriggersPath);

if (_settings.TouchWatchedFileAfterDeployment())
{
TryTouchWatchedFile(context, deploymentInfo);
}

if (_settings.RunFromLocalZip() && deploymentInfo is ZipDeploymentInfo)
TouchWatchedFileIfNeeded(_settings, deploymentInfo, context);

if (_settings.RunFromLocalZip() && deploymentInfo is ArtifactDeploymentInfo)
{
await PostDeploymentHelper.UpdatePackageName(deploymentInfo as ZipDeploymentInfo, _environment, logger);
await PostDeploymentHelper.UpdatePackageName(deploymentInfo as ArtifactDeploymentInfo, _environment, logger);
}

FinishDeployment(id, deployStep);
Expand Down Expand Up @@ -761,6 +770,19 @@ await PostDeploymentHelper.SyncFunctionsTriggers(
}
}

private static void TouchWatchedFileIfNeeded(IDeploymentSettingsManager settings, DeploymentInfoBase deploymentInfo, DeploymentContext context)
{
if (deploymentInfo != null && !deploymentInfo.WatchedFileEnabled)
{
return;
}

if (settings.TouchWatchedFileAfterDeployment())
{
TryTouchWatchedFile(context, deploymentInfo);
}
}

private void PreDeployment(ITracer tracer)
{
if (Environment.IsAzureEnvironment()
Expand Down Expand Up @@ -813,18 +835,23 @@ private static void FailDeployment(ITracer tracer, IDisposable deployStep, Deplo

private static string GetOutputPath(DeploymentInfoBase deploymentInfo, IEnvironment environment, IDeploymentSettingsManager perDeploymentSettings)
{
string targetPath = perDeploymentSettings.GetTargetPath();
string targetSubDirectoryRelativePath = perDeploymentSettings.GetTargetPath();

if (string.IsNullOrWhiteSpace(targetPath))
if (string.IsNullOrWhiteSpace(targetSubDirectoryRelativePath))
{
targetPath = deploymentInfo?.TargetPath;
}

if (!string.IsNullOrWhiteSpace(targetPath))
targetSubDirectoryRelativePath = deploymentInfo?.TargetSubDirectoryRelativePath;
}

if (deploymentInfo?.Deployer == Constants.OneDeploy)
{
return string.IsNullOrWhiteSpace(deploymentInfo?.TargetRootPath) ? environment.WebRootPath : deploymentInfo.TargetRootPath;
}

if (!string.IsNullOrWhiteSpace(targetSubDirectoryRelativePath))
{
targetPath = targetPath.Trim('\\', '/');
return Path.GetFullPath(Path.Combine(environment.WebRootPath, targetPath));
}
targetSubDirectoryRelativePath = targetSubDirectoryRelativePath.Trim('\\', '/');
return Path.GetFullPath(Path.Combine(environment.WebRootPath, targetSubDirectoryRelativePath));
}

return environment.WebRootPath;
}
Expand Down
Loading