<commit_before>import jetbrains.buildServer.configs.kotlin.v2018_2.*
import jetbrains.buildServer.configs.kotlin.v2018_2.buildSteps.dotnetBuild
import jetbrains.buildServer.configs.kotlin.v2018_2.buildSteps.dotnetPublish
import jetbrains.buildServer.configs.kotlin.v2018_2.buildSteps.powerShell
import jetbrains.buildServer.configs.kotlin.v2018_2.buildSteps.script

version = "2018.2"

project {

    buildType(Deploy)
}

object Deploy : BuildType({
    name = "Deploy"

    params {
        password("<PASSWORD>", "<PASSWORD>:<PASSWORD>")
    }

    vcs {
        root(DslContext.settingsRoot)
    }

    steps {
        script {
            name = "frontend.restore"
            scriptContent = "npm install"
        }
        script {
            name = "frontend.build"
            scriptContent = "npm run build"
        }
        dotnetBuild {
            name = "backend.build"
            param("dotNetCoverage.dotCover.home.path", "%teamcity.tool.JetBrains.dotCover.CommandLineTools.DEFAULT%")
        }
        dotnetPublish {
            name = "publish"
            configuration = "Release"
            param("dotNetCoverage.dotCover.home.path", "%teamcity.tool.JetBrains.dotCover.CommandLineTools.DEFAULT%")
        }
        powerShell {
            name = "configure"
            workingDir = "bin/release/netcoreapp2.2/publish"
            scriptMode = script {
                content = """
                        ${'$'}config = @'
                        {
                           "CtorSettings":{
                              "LogUrlPrefix": "https://codingteam.org.ru/_logs/codingteam%40conference.jabber.ru",
                              "LogTimeZoneOffset": 4
                           },
                           "Logging":{
                              "IncludeScopes": false,
                              "LogLevel":{
                                 "Default": "Debug",
                                 "System": "Information",
                                 "Microsoft": "Information"
                              }
                           }
                        }
                        '@
                        ${'$'}config | Out-File appsettings.json -Encoding utf8
                    """.trimIndent()
            }
        }
        step {
            name = "remote.stop"
            type = "ssh-exec-runner"
            param("jetbrains.buildServer.deployer.username", "cor-site")
            param("jetbrains.buildServer.sshexec.command", "sudo /bin/systemctl stop cor-site")
            param("jetbrains.buildServer.sshexec.port", "%ssh.port%")
            param("teamcitySshKey", "cor-site")
            param("jetbrains.buildServer.deployer.targetUrl", "codingteam.org.ru")
            param("jetbrains.buildServer.sshexec.authMethod", "UPLOADED_KEY")
        }
        step {
            name = "remote.upload"
            type = "ssh-deploy-runner"
            param("jetbrains.buildServer.deployer.username", "cor-site")
            param("jetbrains.buildServer.sshexec.port", "%ssh.port%")
            param("teamcitySshKey", "cor-site")
            param("jetbrains.buildServer.deployer.sourcePath", "bin/release/netcoreapp2.2/publish/*")
            param("jetbrains.buildServer.deployer.targetUrl", "codingteam.org.ru:/opt/codingteam/codingteam.org.ru")
            param("jetbrains.buildServer.sshexec.authMethod", "UPLOADED_KEY")
            param("jetbrains.buildServer.deployer.ssh.transport", "jetbrains.buildServer.deployer.ssh.transport.scp")
        }
        step {
            name = "remote.start"
            type = "ssh-exec-runner"
            param("jetbrains.buildServer.deployer.username", "cor-site")
            param("jetbrains.buildServer.sshexec.command", "sudo /bin/systemctl start cor-site")
            param("jetbrains.buildServer.sshexec.port", "%ssh.port%")
            param("teamcitySshKey", "cor-site")
            param("jetbrains.buildServer.deployer.targetUrl", "codingteam.org.ru")
            param("jetbrains.buildServer.sshexec.authMethod", "UPLOADED_KEY")
        }<commit_msg>Remove the old content after stopping the site<commit_after>import jetbrains.buildServer.configs.kotlin.v2018_2.*
import jetbrains.buildServer.configs.kotlin.v2018_2.buildSteps.dotnetBuild
import jetbrains.buildServer.configs.kotlin.v2018_2.buildSteps.dotnetPublish
import jetbrains.buildServer.configs.kotlin.v2018_2.buildSteps.powerShell
import jetbrains.buildServer.configs.kotlin.v2018_2.buildSteps.script

version = "2018.2"

project {

    buildType(Deploy)
}

object Deploy : BuildType({
    name = "Deploy"

    params {
        password("<PASSWORD>", "<PASSWORD>JSON:<PASSWORD>")
    }

    vcs {
        root(DslContext.settingsRoot)
    }

    steps {
        script {
            name = "frontend.restore"
            scriptContent = "npm install"
        }
        script {
            name = "frontend.build"
            scriptContent = "npm run build"
        }
        dotnetBuild {
            name = "backend.build"
            param("dotNetCoverage.dotCover.home.path", "%teamcity.tool.JetBrains.dotCover.CommandLineTools.DEFAULT%")
        }
        dotnetPublish {
            name = "publish"
            configuration = "Release"
            param("dotNetCoverage.dotCover.home.path", "%teamcity.tool.JetBrains.dotCover.CommandLineTools.DEFAULT%")
        }
        powerShell {
            name = "configure"
            workingDir = "bin/release/netcoreapp2.2/publish"
            scriptMode = script {
                content = """
                        ${'$'}config = @'
                        {
                           "CtorSettings":{
                              "LogUrlPrefix": "https://codingteam.org.ru/_logs/codingteam%40conference.jabber.ru",
                              "LogTimeZoneOffset": 4
                           },
                           "Logging":{
                              "IncludeScopes": false,
                              "LogLevel":{
                                 "Default": "Debug",
                                 "System": "Information",
                                 "Microsoft": "Information"
                              }
                           }
                        }
                        '@
                        ${'$'}config | Out-File appsettings.json -Encoding utf8
                    """.trimIndent()
            }
        }
        step {
            name = "remote.stop"
            type = "ssh-exec-runner"
            param("jetbrains.buildServer.deployer.username", "cor-site")
            param("jetbrains.buildServer.sshexec.command", """
                sudo /bin/systemctl stop cor-site
                rm -rf /opt/codingteam/codingteam.org.ru/*
                """.trimIndent())
            param("jetbrains.buildServer.sshexec.port", "%ssh.port%")
            param("teamcitySshKey", "cor-site")
            param("jetbrains.buildServer.deployer.targetUrl", "codingteam.org.ru")
            param("jetbrains.buildServer.sshexec.authMethod", "UPLOADED_KEY")
        }
        step {
            name = "remote.upload"
            type = "ssh-deploy-runner"
            param("jetbrains.buildServer.deployer.username", "cor-site")
            param("jetbrains.buildServer.sshexec.port", "%ssh.port%")
            param("teamcitySshKey", "cor-site")
            param("jetbrains.buildServer.deployer.sourcePath", "bin/release/netcoreapp2.2/publish/*")
            param("jetbrains.buildServer.deployer.targetUrl", "codingteam.org.ru:/opt/codingteam/codingteam.org.ru")
            param("jetbrains.buildServer.sshexec.authMethod", "UPLOADED_KEY")
            param("jetbrains.buildServer.deployer.ssh.transport", "jetbrains.buildServer.deployer.ssh.transport.scp")
        }
        step {
            name = "remote.start"
            type = "ssh-exec-runner"
            param("jetbrains.buildServer.deployer.username", "cor-site")
            param("jetbrains.buildServer.sshexec.command", "sudo /bin/systemctl start cor-site")
            param("jetbrains.buildServer.sshexec.port", "%ssh.port%")
            param("teamcitySshKey", "cor-site")
            param("jetbrains.buildServer.deployer.targetUrl", "codingteam.org.ru")
            param("jetbrains.buildServer.sshexec.authMethod", "UPLOADED_KEY")
        }
{'fraction_non_alphanumeric': 0.12155825417818925, 'fraction_numerical': 0.009137910304196225, 'mean_word_length': 1.7085639856724195, 'pattern_counts': {'":': 18, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4294848', 'n_tokens_mistral': 2478, 'n_tokens_neox': 2281, 'n_words': 289}