Skip to content

Instantly share code, notes, and snippets.

@ismail0352
Last active February 14, 2023 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save ismail0352/11720b4e37d39341f531451d4648db80 to your computer and use it in GitHub Desktop.
Save ismail0352/11720b4e37d39341f531451d4648db80 to your computer and use it in GitHub Desktop.
Jenkinsfile for Dotnet application
pipeline {
agent { label "build && windows" }
stages {
stage('Clean Workspace'){
steps {
cleanWs()
}
}
stage('Checkout'){
steps {
checkout([$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
userRemoteConfigs: [[url: 'https://github.com/ismail0352/Packer-Terraform-Jenkins.git']]])
}
}
stage('Nuget Restore') {
steps {
bat label: 'Nuget Restore',
script: '''
nuget restore "PrimeDotnet\\prime-dotnet.sln"
echo "Nuget Done Starting Msbuild *************"
'''
}
}
stage('Build') {
steps {
script {
//def msbuild = tool name: 'msbuild_2017', type: 'hudson.plugins.msbuild.MsBuildInstallation'
tool name: 'msbuild_2017', type: 'msbuild'
bat "\"${tool 'msbuild_2017'}\"\\msbuild.exe PrimeDotnet\\prime-dotnet.sln /P:DeployOnBuild=True /p:AllowUntrustedCertificate=True /p:MSDeployServiceUrl=<IP or Hostname of IIS server> /P:DeployIISAppPath=\"Default Web Site/PrimeDotnet\""
}
}
}
stage('UnitTest') {
steps {
script {
bat label: 'Unit Test using Dotnet CLI',
script: '''
dotnet.exe test .\\PrimeDotnet\\
'''
}
}
}
stage('Deploy') {
steps {
bat label: 'MsDeploy',
script: '''
// For Localhost
"C:\\Program Files (x86)\\IIS\\Microsoft Web Deploy V3\\msdeploy.exe" -verb:sync -source:package="PrimeDotnet\\bin\\Debug\\Package\\PrimeDotnet.zip" -dest:auto,computerName=localhost
// For Remote Server
"C:\\Program Files (x86)\\IIS\\Microsoft Web Deploy V3\\msdeploy.exe" -verb:sync -source:package="PrimeDotnet\\obj\\Debug\\Package\\PrimeDotnet.zip" -dest:auto,computerName="<IP or Hostname>",userName=administrator,password="supersecret",authType=NTLM -allowUntrusted=true
'''
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment