Giter Club home page Giter Club logo

cake.buildsystems.module's Introduction

Cake.BuildSystems.Module

A simple Cake module to enhance running from a hosted CI environment

This module will introduce a number of features for running in hosted CI build environments to tightly integrate with the host environment/tools. These modules require no changes to build scripts and instead rely on your Cake script's standard aliases and lifecycle events to integrate your script into the environment.

Build Systems

Currently this module supports:

Azure Pipelines

This applies to TFS, Azure Pipelines, and Azure DevOps Server

  • Individual timeline records for each task
  • Percentage reporting on build progress
  • Integrates Warning and Error logging aliases with the Build Issues summary
  • Includes a Cake Build Summary widget on the build summary page

TeamCity

Tested with TeamCity 10

  • Build Logs are separated (and nested) for each executed task
  • Current/ongoing build status is updated to currently running task
  • Error logging aliases are highlighted in build log output

MyGet

Supports the MyGet Build Service

  • Task records are added to build logs
  • Includes a task summary in the build log
  • Integrates Warning, Error and Fatal logging aliases with the build log and report

Travis CI

This module is affected by a bug in Travis CI's Linux image (see travis-ci/travis-ci#7262)

  • Log folding for the Cake build and for individual tasks

GitLab CI

  • Add colored output for Cake log messages in the GitLab pipeline output window

Usage

Each build system's functionality resides in its own module, with Cake.Module.Shared used for shared types. Each module will conditionally register itself, meaning they will only be loaded in their respective CI environments. This means all modules can be deployed with a single codebase without interference.

Installation

Using the pre-processor directives

Add the next following line to your Cake script:

#module nuget:?package=Cake.BuildSystems.Module&version=##see below for note on versioning##

Note: The current version can always be taken from nuget.org).

Currently modules require "bootstrapping", so the first step before running the build is to call dotnet cake --bootstrap (or .\build.ps1 --bootstrap)

Other methods

You can also integrate this module into your own build process, even with a customized build.ps1/build.sh. As long as the Cake.BuildSystems.Module NuGet package is installed into your modules directory (by default ./tools/Modules), cake.exe should pick them up when it runs. Note that you can also change your modules directory using the cake.config file or passing arguments to cake.exe as outlined in the documentation).

Cake.Frosting

While Cake script will load all modules automatically that are present in the modules directory, the same is not the case when using Cake.Frosting.

Before using Cake.Buildsystems.Module you have to reference the NuGet package either by adding <PackageReference Include="Cake.BuildSystems.Module" Version="##see below for note on versioning##" /> to the csproj file of the build project, or by running dotnet add package cake.buildsystems.module in the folder of the build project.

To actually make use of the different modules included in Cake.Buildsystems.Module they need to be registered to the CakeHost. This can be done by using ICakeHost.UseModule<TModule>(). Typically the CakeHost is set up in the Main method of the build project. All modules included in Cake.Buildsystems.Module can be registered, regardless of the underlying build system, as each modules will only be triggered for the intended build system.

An example that registers all currently existing modules from Cake.Buildsystems.Module:

public static int Main(string[] args)
{
    return new CakeHost()
        // Register all modules from Cake.Buildsystems.Module
        .UseModule<AzurePipelinesModule>()
        .UseModule<MyGetModule>()
        .UseModule<TravisCIModule>()
        .UseModule<TeamCityModule>()
        .UseModule<GitLabCIModule>()
        // continue with the "normal" setup of the CakeHost
        .UseContext<BuildContext>()
        .Run(args);
}

Versioning

Note that since modules interact with the internals of Cake, they are tied to a specific version of Cake. The version of Cake supported by the particular module version will always be in the Release Notes of the NuGet package (and therefore also on nuget.org). Make sure to match this version number to the Cake version you're using.

Building

Running build.ps1 with the default target will build all system modules into BuildArtifacts/temp/_PublishedLibraries. Copy this to tools/Modules (you may need to disable the MD5 check if using the bootstrapper) and run your script.

cake.buildsystems.module's People

Contributors

agc93 avatar ap0llo avatar augustoproiete avatar bdukes avatar blythmeister avatar dependabot[bot] avatar flcdrg avatar gep13 avatar github-actions[bot] avatar juergenrb avatar kcamp avatar micsco avatar nils-a avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cake.buildsystems.module's Issues

Suport Azure DevOps Server & cake 0.38

Could you please clarify, is it support Azure DevOps Server & cake 0.38?
I installed Cake.BuildSystems.Module 0.3.2 version, but any changes on the build definition result

Recommended changes resulting from automated audit

We performed an automated audit of your Cake addin and found that it does not follow all the best practices.

We encourage you to make the following modifications:

  • You are currently referencing Cake.Core 0.24.0. Please upgrade to 0.28.0
  • You are currently referencing Cake.Common 0.24.0. Please upgrade to 0.28.0
  • The Cake.Core reference should be private. Specifically, your addin's .csproj should have a line similar to this: <PackageReference Include="Cake.Core" Version="0.28.0" PrivateAssets="All" />
  • The Cake.Common reference should be private. Specifically, your addin's .csproj should have a line similar to this: <PackageReference Include="Cake.Common" Version="0.28.0" PrivateAssets="All" />
  • Your addin should target netstandard2.0. Please note that there is no need to multi-target, netstandard2.0 is sufficient.
  • The nuget package for your addin should use the cake-contrib icon. Specifically, your addin's .csproj should have a line like this: <PackageIconUrl>https://cdn.rawgit.com/cake-contrib/graphics/a5cf0f881c390650144b2243ae551d5b9f836196/png/cake-contrib-medium.png</PackageIconUrl>.
  • There should be a YAML file describing your addin on the cake web site. Specifically, you should add a .yml file in this repo

Apologies if this is already being worked on, or if there are existing open issues, this issue was created based on what is currently published for this package on NuGet.org and in the project on github.

CakeModules should be public classes

MyGetModule, TeamCityModule and TravisCIModule are all declared private class.
While this works when using Cake.exe and Cake.Tool, it does not work when using Cake.Frosting.

Remove net461 target, leaving only netstandard2.0

To be aligned with new guidance/best practices on developing Modules for Cake:

ยง2.6 Avoid targeting additional frameworks such as net461 or net5.0.

Why? Due to current limitations on how modules are loaded, Cake attempts to load all assemblies included in the NuGet package of the module (of all targets) which causes warnings to be displayed and the impression that the module was not loaded and/or is not working.
Once those limitations are fixed, we'll update this recommendation to align with the recommendations for Cake Addins.

Would it be possible to use the Cake Contrib Icon for your NuGet Package?

Thanks again for creating this Cake Addin, we really appreciate the effort that you have put in to creating it.

We, the Cake Team, recently announced a new Cake Contrib Icon, details of which can be found here:

http://cakebuild.net/blog/2017/06/new-cake-contrib-icon

Would you consider changing the nuspec file for your NuGet Package to use this new Cake Contrib Icon? If so, the recommended URL to use is:

https://cdn.rawgit.com/cake-contrib/graphics/a5cf0f881c390650144b2243ae551d5b9f836196/png/cake-contrib-medium.png

Details of the above URL can be found in the repository here:

https://github.com/cake-contrib/graphics

Please let me know if you have any questions.

Error: Method 'RunTargetAsync' does not have an implementation.

On Cake 0.23, and Cake.BuildSystems.Module 0.1.5, I am now getting this output:

Error: Method 'RunTargetAsync' in type 'Cake.TravisCI.Module.TravisCIEngine' from assembly 'Cake.TravisCI.Module, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.

I have no issues with this on TFS, only when running via command line on my dev machine where Travis is not in the picture.

TeamCityLog is not escaping text correctly

Service messages need to have particular characters escaped, otherwise they can be misinterpreted by TeamCity. See https://confluence.jetbrains.com/display/TCD10/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-Escapedvalues for details.

Here's an example of this not being done:

##teamcity[buildProblem description='An error occurred when executing task 'Compile'.']
[03:14:55]
Property value not found
Valid property list format is (name( )*=( )*'escaped_value'( )*)* where escape symbol is "|"

Start supporting Cake v2.0.0-rc0001

Cake v2.0.0-rc0001 has been released and the current version of Cake.BuildSystems.Module is incompatible with it.

The error raised is:

The assembly 'Cake.AzurePipelines.Module, Version=3.0.3.0, Culture=neutral, PublicKeyToken=null'
is referencing an older version of Cake.Core (1.0.0).
For best compatibility it should target Cake.Core version 2.0.0.
The assembly 'Cake.MyGet.Module, Version=3.0.3.0, Culture=neutral, PublicKeyToken=null'
is referencing an older version of Cake.Core (1.0.0).
For best compatibility it should target Cake.Core version 2.0.0.
The assembly 'Cake.TeamCity.Module, Version=3.0.3.0, Culture=neutral, PublicKeyToken=null'
is referencing an older version of Cake.Core (1.0.0).
For best compatibility it should target Cake.Core version 2.0.0.
The assembly 'Cake.TravisCI.Module, Version=3.0.3.0, Culture=neutral, PublicKeyToken=null'
is referencing an older version of Cake.Core (1.0.0).
For best compatibility it should target Cake.Core version 2.0.0.
Error: Method 'add_BeforeSetup' in type 'Cake.AzurePipelines.Module.AzurePipelinesEngine' from assembly 'Cake.AzurePipelines.Module, Version=3.0.3.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.

The problem here is that Cake.BuildSystems.Module provides its own implementation of ICakeEngine, which had a breaking change in cake-build/cake#3152.

CodeQL show a warning on every run

1 issue was detected with this workflow: git checkout HEAD^2 is no longer necessary. Please remove this step as Code Scanning recommends analyzing the merge commit for best results.

Teamcity build failure after upgrading from 3.0.3 to 4.1.0

We updated our cake build script to use 4.1.0 instead of 3.0.3 and now our build is bombing out with an error but it's only happening when the teamcity agent kicks of the build. Connecting to the same machine and running the same commandline as the teamcity agent causes the build to work perfectly fine. We tried restarting the teamcity build agent along with doing a git clean -dfx and we have had no luck. We could use some help on this. Below is the error we see from our teamcity agent logs for the failed build

TeamCity Agent Build Logs
image

Cake Build Script

I have only pasted the module pragma.

// modules
#module nuget:?package=Cake.BuildSystems.Module&version=4.1.0

Error trying to load module with #module directive

Getting this error when loading the loading using a #module directive instead of using packages.config

Error: Method 'get_Tasks' in type 'Cake.MyGet.Module.MyGetEngine' from assembly 'Cake.MyGet.Module, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.

Please update for compatibility with Cake 0.22.x

Error: The assembly 'Cake.MyGet.Module, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
is referencing an older version of Cake.Core (0.19.4).
This assembly need to reference at least Cake.Core version 0.22.0.
Another option is to downgrade Cake to an earlier version.
It's not recommended, but you can explicitly opt-out of assembly verification
by configuring the Skip Verification setting to true
(i.e. command line parameter "--settings_skipverification=true",
envrionment variable "CAKE_SETTINGS_SKIPVERIFICATION=true",
read more about configuration at https://cakebuild.net/docs/fundamentals/configuration)

Cake.Frosting usage

Hi, can you please update your readme how to use this module with Cake.Frosting?
I tried it multiple times differently and I couldn't find out how to make this module working.
Until I found .UseModule extension on CakeHost so this works:

            return new CakeHost()
                .InstallTool(new Uri("nuget:?package=xunit.runner.console&version=2.4.1"))
                .UseModule<TeamCityModule>()
                .UseContext<BuildContext>()
                .Run(args);

Module cannot be initialized

Hey,

I've found an issue where after addition of packages.config with just Cake.BuildSystems.Module to ./tools/Modules is breaking the Cake build process.

packages.config

<?xml version="1.0" encoding="utf-8"?>
<packages>
    <package id="Cake.BuildSystems.Module" version="0.3.0" />
</packages>

Error with Diagnostic output:

Preparing to run build script...
Running build script...
Verifying assembly 'Cake.MyGet.Module, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Verifying assembly 'Cake.TeamCity.Module, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Verifying assembly 'Cake.TFBuild.Module, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Verifying assembly 'Cake.TravisCI.Module, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Verifying assembly 'Cake.MyGet.Module, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Verifying assembly 'Cake.TeamCity.Module, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Verifying assembly 'Cake.TFBuild.Module, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Verifying assembly 'Cake.TravisCI.Module, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Registering module Cake.MyGet.Module.MyGetModule...
Registering module Cake.TeamCity.Module.TeamCityModule...
Registering module Cake.TFBuild.Module.TFBuildModule...
Registering module Cake.TravisCI.Module.TravisCIModule...
Registering module Cake.MyGet.Module.MyGetModule...
Registering module Cake.TeamCity.Module.TeamCityModule...
Registering module Cake.TFBuild.Module.TFBuildModule...
Registering module Cake.TravisCI.Module.TravisCIModule...
Error: System.TypeLoadException: Method 'RunTargetAsync' in type 'Cake.MyGet.Module.MyGetEngine' from assembly 'Cake.MyGet.Module, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
   at Cake.MyGet.Module.MyGetModule.Register(ICakeContainerRegistrar registrar)
   at Cake.Composition.ModuleLoader.LoadModules(IContainer container, CakeOptions options)
   at Cake.Program.Main()

The problem with module exists in Cake 0.29.0 only. The module is working fine with Cake 0.28.1 or older.

TeamCity module not working on the first run

Hey,

I added Cake.BuildSystems.Module to tools/Modules/packages.config as described.
The first run on TeamCity the module is not working. If I run it the second time it is.
So whenever a new Branch "runs" on the TeamCity server the module is not working since you "run" the branch a second time. The Cake.BuildSystems.Module folder and its content itself I did not check into source control. What am I doing wrong?

Add cake-module tag to Cake.BuildSystems.Module NuGet package

The NuGet Gallery will soon include a "Cake" tab with instructions on how to use NuGet packages in Cake build scripts. I'd like to suggest that you include the tag cake-module in the NuGet package of this module, so that the NuGet Gallery can display the correct instructions to install this module.

The UI will look similar to this:

image

Documentation on best practices on tags for Cake modules: https://cakebuild.net/docs/extending/modules/best-practices#tags

Start supporting Cake 3.0.0

We upgraded Cake.BuildSystems.Module to 4.2.0, Cake.Frosting to 3.0.0 and Cake.Issues to 2.0.0, and are now getting a build error:

Unhandled exception. System.TypeLoadException: Method 'WriteLifeCycleStep' in type 'Cake.AzurePipelines.Module.AzurePipelinesReportPrinter' from assembly 'Cake.AzurePipelines.Module, Version=4.2.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
at Cake.AzurePipelines.Module.AzurePipelinesModule.Register(ICakeContainerRegistrar registrar)
at Cake.Frosting.ServiceCollectionExtensions.UseModule[TModule](IServiceCollection services)
at Cake.Frosting.CakeHostExtensions.<>c__8`1.<UseModule>b__8_0(IServiceCollection services)
at Cake.Frosting.CakeHost.ConfigureServices(Action`1 services)
at Cake.Frosting.CakeHostExtensions.UseModule[TModule](CakeHost host)
at DotNetNuke.Build.Program.Main(String[] args) in D:\a\1\s\build\Program.cs:line 26

No particular rush on the upgrade, just wanted to make sure you were aware and/or we didn't miss anything we needed to do with the upgrade. Thanks!

Agent.WorkingDirectory appears not to be writable when run from inside a container

Not exactly sure why, but when I run Cake from within a Linux Container (Ubuntu / .NET Core) as part of an Azure Pipelines build, the directory pointed at by Agent.WorkFolder (aka TFBuild.Environment.Agent.WorkingDirectory ) is not writable, such that Cake.TFBuild.Module.TFBuildReportPrinter.WriteToMarkdown is failing to create the tasksummary.md file.

This results in the following error:

========================================
Default
========================================
##[debug]Processed: ##vso[task.logdetail finishtime=02/25/2019 05:00:15;progress=100;result=Succeeded;id=3f293bfc-27b1-42cf-af56-139f503340c8;]update
##[debug]Processed: ##vso[task.logdetail finishtime=02/25/2019 05:00:15;progress=100;state=Completed;result=Succeeded;id=0ffa0556-53ab-4a01-8f8a-c7dd226e3a15;]update
Error: One or more errors occurred. (Access to the path "/__w/tasksummary.md" is denied.)
	Access to the path "/__w/tasksummary.md" is denied.
##[debug]Exit code 1 received from tool '/bin/bash'

(I wasn't having this problem when I was building in a non-container Ubuntu hosted agent)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.