Skip to content

Instantly share code, notes, and snippets.

@ahmetkucukoglu
Last active April 27, 2024 15:47

Revisions

  1. ahmetkucukoglu revised this gist Sep 5, 2019. 1 changed file with 0 additions and 10 deletions.
    10 changes: 0 additions & 10 deletions github_to_iis_deployment
    Original file line number Diff line number Diff line change
    @@ -7,9 +7,6 @@ String projectName = "CISample/CISample.App"
    //Kaynak kodun publish edileceği dizin
    String publishedPath = "CISample\\CISample.App\\bin\\Release\\netcoreapp2.2\\publish"

    //Hedef makinesinde yedeklemenin yapılacağı dizin
    String backupPath = "D:\\Backups\\cisample"

    //Hedef makinesindeki IIS'de tanımlı olan sitenizin ismi
    String iisApplicationName = "cisample"

    @@ -36,13 +33,6 @@ node () {
    dotnet publish -c Release --no-build
    """
    }
    stage ('Backup') {
    winRMClient credentialsId: 'iis-credential', hostName: """ "${targetServerIP}" """, winRMOperations: [invokeCommand(""" Remove-Item "${backupPath}" -recurse""")]
    winRMClient credentialsId: 'iis-credential', hostName: """ "${targetServerIP}" """, winRMOperations: [invokeCommand(""" rm "${backupPath}.zip" """)]
    winRMClient credentialsId: 'iis-credential', hostName: """ "${targetServerIP}" """, winRMOperations: [invokeCommand(""" mkdir "${backupPath}" """)]
    winRMClient credentialsId: 'iis-credential', hostName: """ "${targetServerIP}" """, winRMOperations: [invokeCommand(""" xcopy /i /s /Y "${iisApplicationPath}" "${backupPath}" """)]
    winRMClient credentialsId: 'iis-credential', hostName: """ "${targetServerIP}" """, winRMOperations: [invokeCommand(""" Compress-Archive -Path "${backupPath}" -DestinationPath "${backupPath}.zip" """)]
    }
    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"""}
    }
  2. ahmetkucukoglu revised this gist Jul 27, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions github_to_iis_deployment
    Original file line number Diff line number Diff line change
    @@ -41,6 +41,7 @@ node () {
    winRMClient credentialsId: 'iis-credential', hostName: """ "${targetServerIP}" """, winRMOperations: [invokeCommand(""" rm "${backupPath}.zip" """)]
    winRMClient credentialsId: 'iis-credential', hostName: """ "${targetServerIP}" """, winRMOperations: [invokeCommand(""" mkdir "${backupPath}" """)]
    winRMClient credentialsId: 'iis-credential', hostName: """ "${targetServerIP}" """, winRMOperations: [invokeCommand(""" xcopy /i /s /Y "${iisApplicationPath}" "${backupPath}" """)]
    winRMClient credentialsId: 'iis-credential', hostName: """ "${targetServerIP}" """, winRMOperations: [invokeCommand(""" Compress-Archive -Path "${backupPath}" -DestinationPath "${backupPath}.zip" """)]
    }
    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"""}
  3. ahmetkucukoglu revised this gist Jul 27, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion github_to_iis_deployment
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ String githubUrl = "https://github.com/ahmetkucukoglu/aspnetcore-ci-sample"
    String projectName = "CISample/CISample.App"

    //Kaynak kodun publish edileceği dizin
    String publishedPath = "CISample/CISample.App\\bin\\Release\\netcoreapp2.2\\publish"
    String publishedPath = "CISample\\CISample.App\\bin\\Release\\netcoreapp2.2\\publish"

    //Hedef makinesinde yedeklemenin yapılacağı dizin
    String backupPath = "D:\\Backups\\cisample"
  4. ahmetkucukoglu renamed this gist Jul 27, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. ahmetkucukoglu revised this gist Jul 26, 2019. 1 changed file with 9 additions and 8 deletions.
    17 changes: 9 additions & 8 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,20 @@
    //Kaynak kodun adresi
    String githubUrl = "https://github.com/xxx/xxx"
    String githubUrl = "https://github.com/ahmetkucukoglu/aspnetcore-ci-sample"

    //Kaynak kodun içerisindeki projenin ismi
    String projectName = "xxx"
    String projectName = "CISample/CISample.App"

    //Kaynak kodun publish edileceği dizin
    String publishedPath = "xxx\\bin\\Release\\netcoreapp2.2\\publish"
    String publishedPath = "CISample/CISample.App\\bin\\Release\\netcoreapp2.2\\publish"

    //Hedef makinesinde yedeklemenin yapılacağı dizin
    String backupPath = "D:\\Backups\\xxx"
    String backupPath = "D:\\Backups\\cisample"

    //Hedef makinesindeki IIS'de tanımlı olan sitenizin ismi
    String iisApplicationName = "xxx"
    String iisApplicationName = "cisample"

    //Hedef makinesindeki IIS'de tanımlı olan sitenizin dizini
    String iisApplicationPath = "D:\\Sites\\xxx"
    String iisApplicationPath = "D:\\WebSites\\cisample"

    //Hedef makinesinin IP'si
    String targetServerIP = "0.0.0.0"
    @@ -27,12 +27,13 @@ node () {
    doGenerateSubmoduleConfigurations: false,
    extensions: [],
    submoduleCfg: [],
    userRemoteConfigs: [[credentialsId: 'github-credential', url: """ "${githubUrl}" """]]])
    userRemoteConfigs: [[url: """ "${githubUrl}" """]]])
    }
    stage('Build') {
    bat """
    cd ${projectName}
    dotnet publish -c Release
    dotnet build -c Release /p:Version=${BUILD_NUMBER}
    dotnet publish -c Release --no-build
    """
    }
    stage ('Backup') {
  6. ahmetkucukoglu created this gist Jul 26, 2019.
    47 changes: 47 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    //Kaynak kodun adresi
    String githubUrl = "https://github.com/xxx/xxx"

    //Kaynak kodun içerisindeki projenin ismi
    String projectName = "xxx"

    //Kaynak kodun publish edileceği dizin
    String publishedPath = "xxx\\bin\\Release\\netcoreapp2.2\\publish"

    //Hedef makinesinde yedeklemenin yapılacağı dizin
    String backupPath = "D:\\Backups\\xxx"

    //Hedef makinesindeki IIS'de tanımlı olan sitenizin ismi
    String iisApplicationName = "xxx"

    //Hedef makinesindeki IIS'de tanımlı olan sitenizin dizini
    String iisApplicationPath = "D:\\Sites\\xxx"

    //Hedef makinesinin IP'si
    String targetServerIP = "0.0.0.0"

    node () {
    stage('Checkout') {
    checkout([
    $class: 'GitSCM',
    branches: [[name: 'master']],
    doGenerateSubmoduleConfigurations: false,
    extensions: [],
    submoduleCfg: [],
    userRemoteConfigs: [[credentialsId: 'github-credential', url: """ "${githubUrl}" """]]])
    }
    stage('Build') {
    bat """
    cd ${projectName}
    dotnet publish -c Release
    """
    }
    stage ('Backup') {
    winRMClient credentialsId: 'iis-credential', hostName: """ "${targetServerIP}" """, winRMOperations: [invokeCommand(""" Remove-Item "${backupPath}" -recurse""")]
    winRMClient credentialsId: 'iis-credential', hostName: """ "${targetServerIP}" """, winRMOperations: [invokeCommand(""" rm "${backupPath}.zip" """)]
    winRMClient credentialsId: 'iis-credential', hostName: """ "${targetServerIP}" """, winRMOperations: [invokeCommand(""" mkdir "${backupPath}" """)]
    winRMClient credentialsId: 'iis-credential', hostName: """ "${targetServerIP}" """, winRMOperations: [invokeCommand(""" xcopy /i /s /Y "${iisApplicationPath}" "${backupPath}" """)]
    }
    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"""}
    }
    }