View Categories

ADO

8 min read

Dotnet Sample Pipeline

Dotnet Application

trigger:
- main

pool:
  vmImage: 'windows-latest'

variables:
  buildConfiguration: 'Release'

steps:
- task: DotNetCoreCLI@2
  inputs:
    command: 'restore'
    feedsToUse: 'select'
    vstsFeed: 'my-vsts-feed' # A series of numbers and letters

- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    arguments: '--configuration $(buildConfiguration)'
  displayName: 'dotnet build $(buildConfiguration)'

Porject1 – Hello World Python Web based application


Source Code : https://github.com/oggistechsoft/Hello-Python.git

  1. Testing Application on Linux machine
    a. clone the clone
    git clone https://github.com/oggistechsoft/Hello-Python.git
    b. pip install ./requiremets.txt

c. ./main.py

  1. Testing as container

a. clone it on docker machine
git clone clone https://github.com/oggistechsoft/Hello-Python.git

b. write Dockerfile
FROM
WORKDIR /web
COPY . .
RUN requirement.txt

EXPOSE
CMD (main.py)

c. run docker file
docker build -t hellopython .
docker run –name hello-python -d p 3000:3000 hellopython
docker contianer list # to verify running container

d. Test application on browser
https://publicip:3000

  1. push your docker image to azure container registry
  2. Testing on azure container instance

Automation

Developer

source – source code
Target – Azure container instance

End user Browser – url

Agent.BuildDirectory: /home/vsts/work/1
  1. Build variables:
    • $(Build.ArtifactStagingDirectory):  c:\agent_work\1\a
    • The local path on the agent where artifacts are copied to before being pushed to their destination.
    • $(Build.BuildId): The unique identifier for the build.
    • $(Build.DefinitionName): The name of the build definition.
    • $(Build.Repository.Name): The name of the repository.
    • $(Build.SourceBranch): The branch being built.
    • $(Build.SourceVersion): The commit ID of the triggering commit.
    • $(Build.RequestedFor): The user who requested the build.
    • $(Build.SourceTfvcShelveset): The name of the shelveset that is built.
  1. Release variables:
    • $(Release.Artifacts.{Alias}.BuildId): The ID of the triggering build for the artifact with the specified alias.
    • $(Release.Artifacts.{Alias}.DefinitionName): The name of the build definition for the artifact with the specified alias.
    • $(Release.Deployment.Id): The ID of the deployment.
    • $(Release.DefinitionName): The name of the release definition.
    • $(Release.ReleaseId): The unique identifier of the release.
    • $(Release.RequestedFor): The user who requested the release.
    • $(Release.TriggeringArtifact.Alias): The alias of the artifact that triggered the release.
  2. Agent variables:
    • $(Agent.Name): The name of the agent.
    • $(Agent.Id): The ID of the agent.
    • $(Agent.Version): The version of the agent.
    • $(Agent.OS): The operating system of the agent.
    • $(Agent.HomeDirectory): The path to the home directory of the agent.
  3. Environment variables:
    • $(System.TeamFoundationCollectionUri): The URI of the Azure DevOps server or the Team Foundation Server.
    • $(System.TeamProject): The name of the team project.
    • $(System.TeamFoundationServer): The URL of the Azure DevOps or Team Foundation Server.
    • $(System.DefaultWorkingDirectory): The default working directory on the agent.
  4. Build and release specific variables:
    • $(Build.SourceBranchName): The name of the branch without the ‘refs/heads/’ prefix.
    • $(Build.ArtifactName): The name of the artifact.
    • $(Release.ReleaseName): The name of the release.
    • $(Release.EnvironmentName): The name of the environment in the release.

Azure Devops Labs   

  1. ArmTemplate Deployment with AzureDevops
  2. Java Application deploy on Azure WebApp

Azure side

Webapp : webappjava

Runtime stack                   :   Java 8

Java Web Server Stack    :   Tomcat 9.0

Operating system             :   Windows

Continues Deployment   :   Disable

Database                 : mysql

Server                      : single server

Type                        : basic server

Username              : srinivas               india

Password               : India!@143     d50P*D1%#uxj

Networking Firewall rules : allow all (0.0.0.0   to 255.255.255.255)

               Connection String Configuration on Application server

               Name : MyShuttleDB     

Connection string :

Server=”java-db.mysql.database.azure.com”;UserID = “srinivas”;Password=”{your_password}”;Database=”{your_database}”;SslMode=Required;SslCa=”{path_to_CA_cert}”;

Type : mysql

               My SQL Client (mysql workbench)

https://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-workbench-community-8.0.34-winx64.msi

               Devops Side

Create a project

Create service connection  –  Azure service connection – Azure-Service-Connection

Selfhosted agent registration

Prepare source Code 

https://github.com/nextopsvideos/MyShuttle.git

download local , delete .git folder

git init

create azure project

push to azure repos

Devops Pipeline  CI

Pipeline  -build pipeline

Name   – javaapp-ci

Agentpool : azure pipelines

Agent specification : windows-2019

Build Pipeline, Create classic pipeline 
Maven pom.xml mvn package -DskipITs –settings ./maven/settings.xmlDisplay name :  maven pom.xml Maven pomfile : pom.xml Goals      :              package Options : -DiskipITs –settings ./maven/settings.xml   Junit Test Results **/surefire-reports/TEST-*.xml
Copy To FilesDisplayname : Source Folder:    $(Build.SourcesDirectory) Content :      **/target/*.war                        *.sql   Target Folder :   $(Build.ArtifactStagingDirectory) Agent machines path : c:\agnet_work\1\a
Publish artifact  Display name Path to publish  : $(ArtifactStagingDirectory) Artifactname : drop   Verify the drop on release pipeline run
      
Release Pipeline 
Note :Before create release pipeline create build pipeline   Create new pipeline   (DEV)   
ArtifactSource type                      : Build Project                              : select the project Source (buildpipeline)    :   CI Default version               :  latest Source alias                      : _javaCI    
Stage1 : empty job  
Execute Azure My SQLHostname          :  java-db.mysql.database.azure.com Database name :  test Server Admin login : srinivas Password : India!@143 Type : MySQL Script file Mysql Script : browser sql file from drop      
Azure WebappDisplayname ; Subscription : azure-service-connection App type    : webapp on windows App name : javaapp1234 Package folder ; browser *.war Custom deploy folder
 Create pipeline https://javaapp1231.azurewebsites.net/myshuttledev  
  • .Net Application on Azure WebApp

Create a Azure Devops Project

Create Service Connection

Clone repo:  https://github.com/nextopsvideos/PartsUnlimited.git

Create Pipeline   (CI Pipeline)
Where is your code   : Use the classic editor Select source              :  Azure  Repos git Team project             :   2_.Net-Parts unlimited Repository                 :    2_.Net-Parts unlimited Default branch         :    main Select template       :    empty
PipelineName : 2_.Net-PartsUnlimitted-CI Agent pool : Azure Pipelines Agent specification : windows-2019
Git SourcesTeam project             :   2_.Net-Parts unlimited Repository                 :    2_.Net-Parts unlimited Default branch         :    main
Agent jobsDisplay name :  Agent job 1 Agent pool : <inherit from pipeline>
NuGet restore Command : restore Path to solution : partsunlimitted/partsUnlimitted.sln Or **\*.sln    (** meaning current directory) (sln file has
Build Solution    (MS Build search ) Solutions   : **\*.sln Visual studio version : visual studio 2017 MSBuild Arguments : /p:DeployOnBuild=true /p:WebPublishMetho=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfiguration=true /p:PackageLocation=”$(Build.StagingDirectory)” /p:IncludeServerNameInBuildInfo=True /p:GenerateBuildInfoConfigFile=true /p:BuildSymbolStorePath=”$(SymbolPath)” /p:ReferencePath=”C:\Program File (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extension\Microsoft\Pex” Define pipeline variable BuildPlatform : any cpu (set enable) BuildConfiguration : release / debug Platform :   $(BuildPlatform) Configuration :  $(BuildConfiguration)
Copy Files Source folder : $(Build.SourcesDirectory) Contents :    **/*.json Target Folder : $(Build.ArtifactStagingDirectory)
Publish Artifact: drop Display name Path to publish  : $(ArtifactStagingDirectory) Artifactname : drop   Verify the drop on release pipeline run
  • Selenium Automation Testing
  • Jenkins Integration with Azure DevOps
  • Keyvault Integration with azure DevOps
  • Github- Nodejs  with Azure DevOps
  • SonarCloud in Azure DevOps
  • Terraform With Azure DevOps
  • Aks, ACR, Dockercompose with Azure DevOps

Powered by BetterDocs

Leave a Reply

Your email address will not be published. Required fields are marked *