Skip to content
This repository has been archived by the owner on Apr 6, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/0.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed Oct 17, 2019
2 parents ca5b727 + a0d1fbd commit 9344844
Show file tree
Hide file tree
Showing 52 changed files with 879 additions and 498 deletions.
4 changes: 2 additions & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#---------------------------------#
# Build Image #
#---------------------------------#
image: Visual Studio 2017
image: Visual Studio 2019

#---------------------------------#
# Build Script #
Expand All @@ -27,4 +27,4 @@ branches:
# Build Cache #
#---------------------------------#
cache:
- tools -> setup.cake
- tools -> recipe.cake
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These owners will be the default owners for everything in the repo and
# will be requested for review when someone opens a pull request.
* @pascalberger @christianbumann @x-jokay @silanosa @georgesgoetz
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,6 @@ __pycache__/
# Cake - Uncomment if you are using it
tools/**
!tools/packages.config
BuildArtifacts/
BuildArtifacts/

.dotnet
10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
# TFS / Azure DevOps support for Cake Issues Addin
# Azure DevOps support for Cake Issues Addin

This addin for the Cake Build Automation System allows you to write issues found using any code
analyzer or linter to Team Foundation Server or Azure DevOps pull requests using
the [Cake Issues addin](https://github.com/cake-contrib/Cake.Issues).
analyzer or linter to Azure DevOps pull requests using the [Cake Issues addin](https://github.com/cake-contrib/Cake.Issues).

For more information about this add-in see the [Cake.Issues website](https://cakeissues.net)
and for general information about the Cake build automation system see the [Cake website](http://cakebuild.net)
and for general information about the Cake build automation system see the [Cake website](http://cakebuild.net).

[![License](http://img.shields.io/:license-mit-blue.svg)](https://github.com/cake-contrib/Cake.Issues.PullRequests.Tfs/blob/feature/build/LICENSE)
[![License](http://img.shields.io/:license-mit-blue.svg)](https://github.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/blob/feature/build/LICENSE)

## Information

| | Stable | Pre-release |
|:--:|:--:|:--:|
|GitHub Release|-|[![GitHub release](https://img.shields.io/github/release/cake-contrib/Cake.Issues.PullRequests.Tfs.svg)](https://github.com/cake-contrib/Cake.Issues.PullRequests.Tfs/releases/latest)|
|NuGet|[![NuGet](https://img.shields.io/nuget/v/Cake.Issues.PullRequests.Tfs.svg)](https://www.nuget.org/packages/Cake.Issues.PullRequests.Tfs)|[![NuGet](https://img.shields.io/nuget/vpre/Cake.Issues.PullRequests.Tfs.svg)](https://www.nuget.org/packages/Cake.Issues.PullRequests.Tfs)|
|GitHub Release|-|[![GitHub release](https://img.shields.io/github/release/cake-contrib/Cake.Issues.PullRequests.AzureDevOps.svg)](https://github.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/releases/latest)|
|NuGet|[![NuGet](https://img.shields.io/nuget/v/Cake.Issues.PullRequests.AzureDevOps.svg)](https://www.nuget.org/packages/Cake.Issues.PullRequests.AzureDevOps)|[![NuGet](https://img.shields.io/nuget/vpre/Cake.Issues.PullRequests.AzureDevOps.svg)](https://www.nuget.org/packages/Cake.Issues.PullRequests.AzureDevOps)|

## Build Status

| | Develop | Master |
|:--:|:--:|:--:|
|AppVeyor Windows|[![Build status](https://ci.appveyor.com/api/projects/status/s8t8j2gh6icynkod/branch/develop?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-issues-pullrequests-tfs/branch/develop)|[![Build status](https://ci.appveyor.com/api/projects/status/s8t8j2gh6icynkod/branch/master?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-issues-pullrequests-tfs/branch/master)|
|Azure DevOps Windows|[![Build Status](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.Tfs/_apis/build/status/cake-contrib.Cake.Issues.PullRequests.Tfs?branchName=develop&jobName=Windows)](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.Tfs/_build/latest?definitionId=8?branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.Tfs/_apis/build/status/cake-contrib.Cake.Issues.PullRequests.Tfs?branchName=master&jobName=Windows)](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.Tfs/_build/latest?definitionId=8?branchName=master)|
|AppVeyor Windows|[![Build status](https://ci.appveyor.com/api/projects/status/6t6m39enwkvkhk80/branch/develop?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-issues-pullrequests-azuredevops/branch/develop)|[![Build status](https://ci.appveyor.com/api/projects/status/6t6m39enwkvkhk80/branch/master?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-issues-pullrequests-azuredevops/branch/master)|
|Azure DevOps Windows|[![Build Status](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_apis/build/status/cake-contrib.Cake.Issues.PullRequests.AzureDevOps?branchName=develop&jobName=Windows)](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_build/latest?definitionId=8&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_apis/build/status/cake-contrib.Cake.Issues.PullRequests.AzureDevOps?branchName=master&jobName=Windows)](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_build/latest?definitionId=8&branchName=master)|
|Azure DevOps macOS|[![Build Status](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_apis/build/status/cake-contrib.Cake.Issues.PullRequests.AzureDevOps?branchName=develop&jobName=macOS)](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_build/latest?definitionId=8&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_apis/build/status/cake-contrib.Cake.Issues.PullRequests.AzureDevOps?branchName=master&jobName=macOS)](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_build/latest?definitionId=8&branchName=master)|
|Azure DevOps Ubuntu|[![Build Status](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_apis/build/status/cake-contrib.Cake.Issues.PullRequests.AzureDevOps?branchName=develop&jobName=Ubuntu)](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_build/latest?definitionId=8&branchName=develop)|[![Build Status](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_apis/build/status/cake-contrib.Cake.Issues.PullRequests.AzureDevOps?branchName=master&jobName=Ubuntu)](https://dev.azure.com/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/_build/latest?definitionId=8&branchName=master)|

## Code Coverage

[![Coverage Status](https://coveralls.io/repos/github/cake-contrib/Cake.Issues.PullRequests.Tfs/badge.svg?branch=develop)](https://coveralls.io/github/cake-contrib/Cake.Issues.PullRequests.Tfs?branch=develop)
[![Coverage Status](https://coveralls.io/repos/github/cake-contrib/Cake.Issues.PullRequests.AzureDevOps/badge.svg?branch=develop)](https://coveralls.io/github/cake-contrib/Cake.Issues.PullRequests.AzureDevOps?branch=develop)

## Quick Links

- [Documentation](https://cakeissues.net)

## Chat Room

Come join in the conversation about this addin in our Gitter Chat Room
Come join in the conversation about this addin in our Gitter Chat Room.

[![Join the chat at https://gitter.im/cake-contrib/Lobby](https://badges.gitter.im/cake-contrib/Lobby.svg)](https://gitter.im/cake-contrib/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Expand Down
26 changes: 25 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,35 @@ trigger:

pr:
- develop
- release/*
- hotfix/*

jobs:
- job: Windows
pool:
vmImage: 'vs2017-win2016'
steps:
- powershell: ./build.ps1
- powershell: |
$ENV:CAKE_SKIP_GITVERSION=([string]::IsNullOrEmpty($ENV:SYSTEM_PULLREQUEST_PULLREQUESTID) -eq $False).ToString()
.\build.ps1
exit $LASTEXITCODE
displayName: 'Cake Build'
- job: macOS
pool:
vmImage: 'macOS-10.14'
steps:
# To manually select a Xamarin SDK version on the Hosted macOS agent, enable this script with the SDK version you want to target
# https://go.microsoft.com/fwlink/?linkid=871629
- bash: |
sudo $AGENT_HOMEDIRECTORY/scripts/select-xamarin-sdk.sh 5_18_1
displayName: 'Select Mono 5.18.1'
- bash: |
./build.sh
displayName: 'Cake Build'
- job: Ubuntu
pool:
vmImage: 'ubuntu-16.04'
steps:
- bash: |
./build.sh
displayName: 'Cake Build'
4 changes: 2 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ http://cakebuild.net

[CmdletBinding()]
Param(
[string]$Script = "setup.cake",
[string]$Script = "recipe.cake",
[string]$Target = "Default",
[ValidateSet("Release", "Debug")]
[string]$Configuration = "Release",
Expand Down Expand Up @@ -181,4 +181,4 @@ if (!(Test-Path $CAKE_EXE)) {
# Start Cake
Write-Host "Running build script..."
Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs"
exit $LASTEXITCODE
exit $LASTEXITCODE
90 changes: 55 additions & 35 deletions build.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,82 +1,102 @@
#!/usr/bin/env bash
###############################################################
# This is the Cake bootstrapper script that is responsible for
# downloading Cake and all specified tools from NuGet.
###############################################################
##########################################################################
# This is the Cake bootstrapper script for Linux and OS X.
# This file was downloaded from https://github.com/cake-build/resources
# Feel free to change this file to fit your needs.
##########################################################################

# Define directories.
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
TOOLS_DIR=$SCRIPT_DIR/tools
NUGET_EXE=$TOOLS_DIR/nuget.exe
CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe
NUGET_URL=https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
CAKE_VERSION=0.32.1
CAKE_EXE=$TOOLS_DIR/Cake.$CAKE_VERSION/Cake.exe

# Temporarily skip verification of addins.
export CAKE_SETTINGS_SKIPVERIFICATION='true'

# Define default arguments.
SCRIPT="setup.cake"
TARGET="Default"
CONFIGURATION="Release"
VERBOSITY="verbose"
DRYRUN=
SHOW_VERSION=false
SCRIPT_ARGUMENTS=()

# Parse arguments.
for i in "$@"; do
case $1 in
-s|--script) SCRIPT="$2"; shift ;;
-t|--target) TARGET="$2"; shift ;;
-c|--configuration) CONFIGURATION="$2"; shift ;;
-v|--verbosity) VERBOSITY="$2"; shift ;;
-d|--dryrun) DRYRUN="-dryrun" ;;
--version) SHOW_VERSION=true ;;
--) shift; SCRIPT_ARGUMENTS+=("$@"); break ;;
*) SCRIPT_ARGUMENTS+=("$1") ;;
esac
shift
done

# Make sure the tools folder exist.
if [ ! -d $TOOLS_DIR ]; then
mkdir $TOOLS_DIR
if [ ! -d "$TOOLS_DIR" ]; then
mkdir "$TOOLS_DIR"
fi

# Make sure that packages.config exist.
if [ ! -f $TOOLS_DIR/packages.config ]; then
echo "Downloading packages.config..."
curl -Lsfo $TOOLS_DIR/packages.config http://cakebuild.net/bootstrapper/packages
if [ $? -ne 0 ]; then
echo "An error occured while downloading packages.config."
exit 1
fi
# Print Mono version.
echo "Mono version:"
mono --version
echo ""

###########################################################################
# INSTALL .NET CORE CLI
###########################################################################

echo "Installing .NET CLI..."
if [ ! -d "$SCRIPT_DIR/.dotnet" ]; then
mkdir "$SCRIPT_DIR/.dotnet"
fi
curl -Lsfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" https://dot.net/v1/dotnet-install.sh
sudo bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version 2.1.400 --install-dir .dotnet --no-path
export PATH="$SCRIPT_DIR/.dotnet":$PATH
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0
"$SCRIPT_DIR/.dotnet/dotnet" --info

###########################################################################
# INSTALL NUGET
###########################################################################

# Download NuGet if it does not exist.
if [ ! -f $NUGET_EXE ]; then
if [ ! -f "$NUGET_EXE" ]; then
echo "Downloading NuGet..."
curl -Lsfo $NUGET_EXE https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
curl -Lsfo "$NUGET_EXE" $NUGET_URL
if [ $? -ne 0 ]; then
echo "An error occured while downloading nuget.exe."
echo "An error occurred while downloading nuget.exe."
exit 1
fi
fi

# Restore tools from NuGet.
pushd $TOOLS_DIR >/dev/null
mono $NUGET_EXE install -ExcludeVersion -PreRelease -Source https://www.myget.org/F/cake/api/v3/index.json
if [ $? -ne 0 ]; then
echo "Could not restore NuGet packages."
exit 1
###########################################################################
# INSTALL CAKE
###########################################################################

if [ ! -f "$CAKE_EXE" ]; then
mono "$NUGET_EXE" install Cake -Version $CAKE_VERSION -OutputDirectory "$TOOLS_DIR"
if [ $? -ne 0 ]; then
echo "An error occurred while installing Cake."
exit 1
fi
fi
popd >/dev/null

# Make sure that Cake has been installed.
if [ ! -f $CAKE_EXE ]; then
if [ ! -f "$CAKE_EXE" ]; then
echo "Could not find Cake.exe at '$CAKE_EXE'."
exit 1
fi

###########################################################################
# RUN BUILD SCRIPT
###########################################################################

# Start Cake
if $SHOW_VERSION; then
exec mono $CAKE_EXE -version
else
exec mono $CAKE_EXE $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}"
fi
exec mono "$CAKE_EXE" recipe.cake --verbosity=$VERBOSITY --configuration=$CONFIGURATION --target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}"
Binary file added docs/cake.issues.pullrequests.azuredevops.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 83 additions & 0 deletions docs/examples/azure-pipelines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
Order: 30
Title: Using with Azure Pipelines
Description: Example how to use the Cake.Issues.PullRequests.AzureDevOps addin from an Azure Pipelines build.
---
This example shows how to write issues as comments to an Azure DevOps pull request from an Azure Pipelines build.

To write issues as comments to Azure DevOps pull requests you need to import the core addin,
the core pull request addin, the Azure DevOps support including the Cake.AzureDevOps addin, and one or more issue providers,
in this example for JetBrains InspectCode:

```csharp
#addin "Cake.Issues"
#addin "Cake.Issues.InspectCode"
#addin "Cake.Issues.PullRequests"
#addin "Cake.Issues.PullRequests.AzureDevOps"
#addin "Cake.AzureDevOps"
```

:::{.alert .alert-warning}
Please note that you always should pin addins to a specific version to make sure your builds are deterministic and
won't break due to updates to one of the addins.

See [pinning addin versions](https://cakebuild.net/docs/tutorials/pinning-cake-version#pinning-addin-version) for details.
:::

In the following task we'll first determine if the build is running on Azure DevOps and for a pull request,
then read the remote repository URL and pull request id from environment variables set by the Azure Pipelines build
and finally call the [AzureDevOpsPullRequests] alias using the OAuth token provided by the Azure Pipeline build.

:::{.alert .alert-info}
Please note that you'll need to setup your Azure Pipelines build to allow scripts to
access the OAuth token and need to setup proper permissions.

See [OAuth authentication from Azure Pipelines] for details.
:::

```csharp
Task("ReportIssuesToPullRequest").Does(() =>
{
var isRunningOnAzureDevOps =
!string.IsNullOrWhiteSpace(context.EnvironmentVariable("TF_BUILD")) &&
!string.IsNullOrWhiteSpace(context.EnvironmentVariable("SYSTEM_COLLECTIONURI")) &&
(
new Uri(context.EnvironmentVariable("SYSTEM_COLLECTIONURI")).Host == "dev.azure.com" ||
new Uri(context.EnvironmentVariable("SYSTEM_COLLECTIONURI")).Host.EndsWith("visualstudio.com")
);

var isPullRequestBuild =
!string.IsNullOrWhiteSpace(context.EnvironmentVariable("SYSTEM_PULLREQUEST_PULLREQUESTID"));

if (isRunningOnAzureDevOps)
{
var repositoryUrl = new Uri(context.EnvironmentVariable("BUILD_REPOSITORY_URI"));

if (isPullRequestBuild)
{
var pullRequestIdVariable = context.EnvironmentVariable("SYSTEM_PULLREQUEST_PULLREQUESTID");
if (!Int32.TryParse(pullRequestIdVariable, out var pullRequestId))
{
throw new Exception($"Invalid pull request ID: {pullRequestIdVariable}");
}
else
{
var repoRootFolder = MakeAbsolute(Directory("./"));

ReportIssuesToPullRequest(
InspectCodeIssuesFromFilePath(
@"C:\build\inspectcode.log"),
AzureDevOpsPullRequests(
repositoryUrl,
pullRequestId,
AzureDevOpsAuthenticationOAuth(EnvironmentVariable("SYSTEM_ACCESSTOKEN"))),
repoRootFolder);
}
}
}
});
```

[AzureDevOpsPullRequests]: ../../../../api/Cake.Issues.PullRequests.AzureDevOps/AzureDevOpsPullRequestSystemAliases/64912B0A
[Allow scripts to access the OAuth token]: https://docs.microsoft.com/en-us/azure/devops/pipelines/build/options#allow-scripts-to-access-the-oauth-token
[OAuth authentication from Azure Pipelines]: ../setup#oauth-authentication-from-azure-pipelines
12 changes: 12 additions & 0 deletions docs/examples/index.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
Title: Examples
Description: Examples for using the Cake.Issues.PullRequests.AzureDevOps addin.
---
<p>@Html.Raw(Model.String(DocsKeys.Description))</p>

<div class="alert alert-info">
There's a <a href="https://dev.azure.com/pberger/Cake.Issues-Demo" target="_blank">demo repository</a>
available which you can fork and to which you can create pull requests to test the integration functionality.
</div>

@Html.Partial("_ChildPages")
Loading

0 comments on commit 9344844

Please sign in to comment.