项目作者: Photon-CI

项目描述 :
An open-source .NET task platform designed for pipeline-as-code automation.
高级语言: C#
项目地址: git://github.com/Photon-CI/Photon.git
创建时间: 2018-03-23T22:50:15Z
项目社区:https://github.com/Photon-CI/Photon

开源协议:GNU General Public License v3.0

下载


Photon

A platform for packaging and deploying .NET-based automation scripts to provide a complete pipeline-as-code solution for building, testing, and deploying projects.

Photon packages your custom .NET library with your applications, allowing users to build, test, and deploy their applications with the full power of .NET! By managing your custom libraries alongside your projects, you can gain full support for branch versioning of your automated tasks. This allows users to make structural project changes that alter their pipelines, without affecting other branches of code!

Since standard .NET libraries are used, you can leverage the full user experience of Visual Studio when editing your pipelines. By decorating your scripts and tasks with test attributes, you can even make your tasks directly runnable and debuggable using your favorite testing platform.

Visit the Official Website to download releases and view the documentation.

Usage example

Scripts : IScript

Scripts are run on the Server, and are primarily used to delegate work to agents. In the below script, we register all agents matching the roles Configuration.Roles.Deploy.Web and Configuration.Roles.Deploy.Service, which are pre-defined string constants.

  1. public class DeployScript : IScript
  2. {
  3. public async Task<ScriptResult> RunAsync(ScriptContext context)
  4. {
  5. var agents = context.RegisterAgents(
  6. "role.deploy.web",
  7. "role.deploy.Service");
  8. try {
  9. await agents.InitializeAsync();
  10. // Unpack Applications
  11. await agents.RunTasksAsync(
  12. nameof(UnpackPhotonSampleWeb),
  13. nameof(UnpackPhotonSampleService));
  14. // Update Applications
  15. await agents.RunTasksAsync(
  16. nameof(UpdatePhotonSampleWeb),
  17. nameof(UpdatePhotonSampleService));
  18. }
  19. finally {
  20. await agents.ReleaseAllAsync();
  21. }
  22. }
  23. }

Tasks are run on Agents. By specifying the [Roles] attribute, tasks can be limited to Agents matching those roles. This allows multiple tasks to be executed simultaneously while only executing on agents matching their role.

  1. [Roles(Configuration.Roles.Deploy.Web)]
  2. internal class UnpackPhotonSampleWeb : IDeployTask
  3. {
  4. public IAgentDeployContext Context {get; set;}
  5. public async Task<TaskResult> RunAsync()
  6. {
  7. // Get the versioned application path
  8. var applicationPath = Context.GetApplicationDirectory(Configuration.Apps.Web.AppName, Context.ProjectPackageVersion);
  9. // Download Package to temp file
  10. var packageFilename = await Context.PullApplicationPackageAsync(Configuration.Apps.Web.PackageId, Context.ProjectPackageVersion);
  11. // Unpackage contents to application path
  12. await ApplicationPackageTools.UnpackAsync(packageFilename, applicationPath);
  13. }
  14. }
  1. [Roles(Configuration.Roles.Deploy.Web)]
  2. internal class UpdatePhotonSampleWeb : IDeployTask
  3. {
  4. public IAgentDeployContext Context {get; set;}
  5. public async Task RunAsync()
  6. {
  7. // Get the versioned application path
  8. var applicationPath = Context.GetApplicationDirectory(Configuration.Apps.Web.AppName, Context.ProjectPackageVersion);
  9. using (var iis = new IISTools(Context)) {
  10. // Configure and start AppPool
  11. iis.ApplicationPool.Configure(Configuration.AppPoolName, pool => {
  12. pool.AutoStart = true;
  13. pool.ManagedPipelineMode = ManagedPipelineMode.Integrated;
  14. pool.ManagedRuntimeVersion = "v4.0";
  15. if (pool.State == ObjectState.Stopped)
  16. pool.Start();
  17. });
  18. // Configure and start Website
  19. iis.WebSite.Configure("Photon Web", 8086, site => {
  20. site.ApplicationDefaults.ApplicationPoolName = Configuration.AppPoolName;
  21. site.ServerAutoStart = true;
  22. // Set Bindings
  23. site.Bindings.Clear();
  24. site.Bindings.Add("*:8086:localhost", "http");
  25. // Update Virtual Path
  26. site.Applications[0]
  27. .VirtualDirectories["/"]
  28. .PhysicalPath = applicationPath;
  29. if (site.State == ObjectState.Stopped)
  30. site.Start();
  31. });
  32. }
  33. }
  34. }

Release History

  • 0.0.1
    • Initial Release; Work in progress.

Meta

Joshua Miller - null511@GitHubnull511@outlook.com

Distributed under the MIT license. See LICENSE for more information.

Contributing

  1. Fork it (https://github.com/Photon-CI/Photon/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request