Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
63 changes: 24 additions & 39 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,28 @@
{
"name": "AzurePipelines",
"dockerFile": "Dockerfile",
"name": "AzurePipelines",
"image": "mcr.microsoft.com/devcontainers/dotnet:6.0",

// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vscode.azurecli",
"ms-vscode.powershell",
"hashicorp.terraform",
"esbenp.prettier-vscode",
"tfsec.tfsec"
]
}
},
"features": {
"ghcr.io/devcontainers/features/azure-cli:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/git-lfs:1": {},
"ghcr.io/devcontainers/features/powershell:1": {},
"ghcr.io/devcontainers/features/terraform:1": {}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postStartCommand' to run commands each time the container is successfully started..
"postStartCommand": "/home/vscode/azure-pipelines/start.sh",

// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
// Amend Azure Pipelines agent version and arch type with 'ARCH' and 'AGENT_VERSION'. https://github.com/microsoft/azure-pipelines-agent/releases.
"build": {
"args": {
"UPGRADE_PACKAGES": "true",
"ARCH": "x64",
"AGENT_VERSION": "2.206.1"
}
},
"features": {
"terraform": "latest",
"azure-cli": "latest",
"git-lfs": "latest",
"github-cli": "latest",
"powershell": "latest"
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.azurecli",
"ms-vscode.powershell",
"hashicorp.terraform",
"esbenp.prettier-vscode",
"tfsec.tfsec",
"ms-dotnettools.csharp"
]
}
}
},

"postStartCommand": "bash .devcontainer/start.sh",
"remoteUser": "vscode"
}
57 changes: 57 additions & 0 deletions .devcontainer/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env bash
set -euo pipefail

# ---------- Config via Codespaces Secrets ----------
# Required: set these in your repo/Org Codespaces secrets
# ADO_ORG -> org name (e.g. contoso) OR full URL (https://dev.azure.com/contoso)
# ADO_PAT -> PAT with at least "Agent Pools (Read & manage)"
: "${ADO_ORG:?Set Codespaces secret ADO_ORG to your org name or full URL}"
: "${ADO_PAT:?Set Codespaces secret ADO_PAT to your Azure DevOps PAT}"

# Optional overrides (you can also set these as secrets/envs)
: "${AZP_POOL:=Default}" # Azure DevOps agent pool
: "${AZP_AGENT_VERSION:=2.206.1}" # Agent version
: "${AZP_AGENT_NAME:=$(hostname)}" # Agent name

# ---------- Derive org URL ----------
if [[ "$ADO_ORG" =~ ^https?:// ]]; then
AZP_URL="$ADO_ORG"
else
AZP_URL="https://dev.azure.com/${ADO_ORG}"
fi

# ---------- Prepare workspace folder ----------
AGENT_ROOT="/home/vscode/azp"
mkdir -p "$AGENT_ROOT"
chown -R vscode:vscode "$AGENT_ROOT"
cd "$AGENT_ROOT"

# ---------- Download agent from GitHub releases (reliable) ----------
AGENT_TGZ="vsts-agent-linux-x64-${AZP_AGENT_VERSION}.tar.gz"
AGENT_URL="https://github.com/microsoft/azure-pipelines-agent/releases/download/v${AZP_AGENT_VERSION}/${AGENT_TGZ}"

if [[ ! -x "./bin/Agent.Listener" ]]; then
echo "Downloading Azure Pipelines agent ${AZP_AGENT_VERSION}..."
curl -fsSL -o "${AGENT_TGZ}" "${AGENT_URL}"
tar -xzf "${AGENT_TGZ}"
rm -f "${AGENT_TGZ}"
./bin/installdependencies.sh
fi

# ---------- Configure agent (ephemeral; auto-removes after job) ----------
# If reconfiguring, clean stale files to avoid conflicts
if [[ -f ".agent" ]]; then
./config.sh remove --unattended --auth pat --token "$ADO_PAT" || true
fi

./config.sh --unattended \
--url "$AZP_URL" \
--auth pat --token "$ADO_PAT" \
--pool "$AZP_POOL" \
--agent "$AZP_AGENT_NAME" \
--acceptTeeEula \
--ephemeral \
--replace

# ---------- Run a single job, then exit ----------
exec ./run.sh --once
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

[![Build Status](https://dev.azure.com/kgpraveen/Space%20Game%20-%20web%20-%20Pipeline/_apis/build/status%2Fkg-praveen.mslearn-tailspin-spacegame-web?branchName=main)](https://dev.azure.com/kgpraveen/Space%20Game%20-%20web%20-%20Pipeline/_build/latest?definitionId=2&branchName=main)
# Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a
Expand Down Expand Up @@ -63,3 +63,4 @@ Privacy information can be found at https://privacy.microsoft.com/en-us/

Microsoft and any contributors reserve all other rights, whether under their respective copyrights, patents,
or trademarks, whether by implication, estoppel or otherwise.

2 changes: 1 addition & 1 deletion Tailspin.SpaceGame.Web/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<section class="intro">
<div class="container">
<img class="title" src="/images/space-game-title.svg" alt="Space Game">
<p>An example site for learning</p>
<p>Welcome to the oficial Space Game site!</p>
</div>
</section>
<section class="download">
Expand Down
33 changes: 30 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
pool: MyAgentPool
steps:
- bash: echo hello world
# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- '*'

pool:
name: 'MyAgentPool'

variables:
buildConfiguration: 'Release'

steps:
- task: UseDotNet@2
displayName: 'Install .NET 8 SDK'
inputs:
packageType: 'sdk'
version: '8.x' # or pin e.g. 8.0.404
includePreview: false

- script: dotnet --info
displayName: 'Dotnet info (sanity check)'

- script: dotnet restore
displayName: 'dotnet restore'

- script: dotnet build --configuration Release --no-restore
displayName: 'dotnet build Release'