Skip to content

Instantly share code, notes, and snippets.

@ahmetkucukoglu
Last active April 27, 2024 15:47
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmetkucukoglu/d7dc7283ddb79677386b1e4cef904e8c to your computer and use it in GitHub Desktop.
Save ahmetkucukoglu/d7dc7283ddb79677386b1e4cef904e8c to your computer and use it in GitHub Desktop.
Jenkinsfile - Github to IIS Deployment
//Kaynak kodun adresi
String githubUrl = "https://github.com/ahmetkucukoglu/aspnetcore-ci-sample"
//Kaynak kodun içerisindeki projenin ismi
String projectName = "CISample/CISample.App"
//Kaynak kodun publish edileceği dizin
String publishedPath = "CISample\\CISample.App\\bin\\Release\\netcoreapp2.2\\publish"
//Hedef makinesindeki IIS'de tanımlı olan sitenizin ismi
String iisApplicationName = "cisample"
//Hedef makinesindeki IIS'de tanımlı olan sitenizin dizini
String iisApplicationPath = "D:\\WebSites\\cisample"
//Hedef makinesinin IP'si
String targetServerIP = "0.0.0.0"
node () {
stage('Checkout') {
checkout([
$class: 'GitSCM',
branches: [[name: 'master']],
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
userRemoteConfigs: [[url: """ "${githubUrl}" """]]])
}
stage('Build') {
bat """
cd ${projectName}
dotnet build -c Release /p:Version=${BUILD_NUMBER}
dotnet publish -c Release --no-build
"""
}
stage('Deploy'){
withCredentials([usernamePassword(credentialsId: 'iis-credential', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { bat """ "C:\\Program Files (x86)\\IIS\\Microsoft Web Deploy V3\\msdeploy.exe" -verb:sync -source:iisApp="${WORKSPACE}\\${publishedPath}" -enableRule:AppOffline -dest:iisApp="${iisApplicationName}",ComputerName="https://${targetServerIP}:8172/msdeploy.axd",UserName="$USERNAME",Password="$PASSWORD",AuthType="Basic" -allowUntrusted"""}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment