forked from adam/discord-bot-shtik
Compare commits
No commits in common. "fc73df1d634db0ab37f6b9ca38a30debed031eaf" and "401a3ecbc8f827d75cdfd0c48df841904babd7a6" have entirely different histories.
fc73df1d63
...
401a3ecbc8
@ -42,7 +42,7 @@ namespace vassago
|
|||||||
ProtocolInterfaces.ProtocolList.twitchs.Add(t);
|
ProtocolInterfaces.ProtocolList.twitchs.Add(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
Task.WaitAll(initTasks.ToArray(), cancellationToken);
|
Task.WaitAll(initTasks, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task StopAsync(CancellationToken cancellationToken)
|
public Task StopAsync(CancellationToken cancellationToken)
|
||||||
|
118
Jenkinsfile
vendored
118
Jenkinsfile
vendored
@ -1,41 +1,7 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
environment {
|
|
||||||
linuxServiceAccount=credentials("a83b97d0-dbc6-42d9-96c9-f07a7f2dfab5")
|
|
||||||
linuxServiceAccountID="3ca1be00-3d9f-42a1-bab2-48a4d7b99fb0"
|
|
||||||
database_connectionString=credentials("7ab58922-c647-42e5-ae15-84faa0c1ee7d")
|
|
||||||
targetHost="alloces.lan"
|
|
||||||
}
|
|
||||||
stages {
|
stages {
|
||||||
|
|
||||||
stage("environment setup") { //my environment, here on the jenkins agent
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
|
|
||||||
sh """#!/bin/bash
|
|
||||||
function testcmd(){
|
|
||||||
if ! command -v \$1 2>&1 >/dev/null
|
|
||||||
then
|
|
||||||
echo "this agent doesn't have \$1"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
testcmd mktemp
|
|
||||||
testcmd curl
|
|
||||||
testcmd git
|
|
||||||
testcmd sed
|
|
||||||
testcmd ssh
|
|
||||||
testcmd ssh-keyscan
|
|
||||||
testcmd ssh-keygen
|
|
||||||
testcmd scp
|
|
||||||
testcmd dotnet
|
|
||||||
|
|
||||||
dotnet tool install dotnet-ef
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('clean old'){
|
stage('clean old'){
|
||||||
steps{
|
steps{
|
||||||
sh 'rm -rf bin obj'
|
sh 'rm -rf bin obj'
|
||||||
@ -43,89 +9,17 @@ pipeline {
|
|||||||
}
|
}
|
||||||
stage('Build') {
|
stage('Build') {
|
||||||
steps {
|
steps {
|
||||||
dotnetBuild(outputDirectory: "./dist", project: "vassago.csproj")
|
sh 'dotnet publish vassago.csproj --configuration Release --os linux'
|
||||||
archiveArtifacts artifacts: 'dist/*'
|
archiveArtifacts artifacts: 'bin/Release/net7.0/linux-x64/publish/*'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage ('upload') {
|
stage('Deploy'){
|
||||||
when {
|
|
||||||
//now my CI/CD is no longer continuous, it's just... automatic.
|
|
||||||
//(which is what I actually want tbh)
|
|
||||||
//but that does mean I have to put this condition in every single branch
|
|
||||||
branch "release"
|
|
||||||
}
|
|
||||||
steps{
|
|
||||||
withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccountID, keyFileVariable: 'PK')])
|
|
||||||
{
|
|
||||||
sh """#!/bin/bash
|
|
||||||
ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'rm -rf temp_deploy & mkdir -p temp_deploy'
|
|
||||||
scp -i \"${PK}\" -r dist ${linuxServiceAccount_USR}@${env.targetHost}:temp_deploy
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage ('stop')
|
|
||||||
{
|
|
||||||
when{
|
when{
|
||||||
branch "release"
|
branch "release"
|
||||||
}
|
}
|
||||||
steps{
|
steps{
|
||||||
withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccountID, keyFileVariable: 'PK')])
|
|
||||||
{
|
|
||||||
sh """#!/bin/bash
|
|
||||||
ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'systemctl --user stop vassago'
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage ('update db')
|
|
||||||
{
|
|
||||||
when {
|
|
||||||
branch "release"
|
|
||||||
}
|
|
||||||
steps{
|
|
||||||
//TODO: backup database
|
|
||||||
sh """#!/bin/bash
|
|
||||||
"""
|
|
||||||
|
|
||||||
sh """#!/bin/bash
|
|
||||||
dotnet ef database update --connection "${env.database_connectionString}"
|
|
||||||
"""
|
|
||||||
//TODO: if updating the db fails, restore the old one
|
|
||||||
sh """#!/bin/bash
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage ('replace')
|
|
||||||
{
|
|
||||||
when {
|
|
||||||
branch "release"
|
|
||||||
}
|
|
||||||
steps{
|
|
||||||
withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccountID, keyFileVariable: 'PK')])
|
|
||||||
{
|
|
||||||
sh """#!/bin/bash
|
|
||||||
ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'mv dist/appsettings.json appsettings.json'
|
|
||||||
ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'rm -rf dist/ && shopt -s dotglob & mv temp_deploy/* dist/'
|
|
||||||
ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'mv appsettings.json dist/appsettings.json'
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage ('spin up')
|
|
||||||
{
|
|
||||||
when {
|
|
||||||
branch "release"
|
|
||||||
}
|
|
||||||
steps{
|
|
||||||
withCredentials([sshUserPrivateKey(credentialsId: env.linuxServiceAccountID, keyFileVariable: 'PK')])
|
|
||||||
{
|
|
||||||
sh """#!/bin/bash
|
|
||||||
ssh -i \"${PK}\" -tt ${linuxServiceAccount_USR}@${targetHost} 'systemctl --user start vassago'
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<NoWarn>$(NoWarn);CA2254</NoWarn>
|
<NoWarn>$(NoWarn);CA2254</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user