Add Jenkins job configs (build, test, deploy)

This commit is contained in:
Joungmin
2026-02-19 21:08:22 +09:00
parent 43aa70be81
commit 30eefd58e4
3 changed files with 128 additions and 0 deletions

43
jenkins_build.xml Normal file
View File

@@ -0,0 +1,43 @@
<?xml version='1.0' encoding='UTF-8'?>
<project>
<description>Build job - compiles and packages the application</description>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.plugins.git.GitSCM">
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<url>https://gittea.cloud-handson.com/joungmin/openclaw-workspace.git</url>
<credentialsId>gitea-credentials</credentialsId>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>*/main</name>
</hudson.plugins.git.BranchSpec>
</branches>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<submoduleCfg class="list"/>
<extensions/>
</scm>
<assignedNode>built-in</assignedNode>
<builders>
<hudson.tasks.Shell>
<command>python3 -m venv venv
. venv/bin/activate
pip install --upgrade pip
pip install pylint flake8 black isort oracledb pytest pytest-cov</command>
</hudson.tasks.Shell>
<hudson.tasks.Shell>
<command>. venv/bin/activate
pip freeze > requirements.locked.txt</command>
</hudson.tasks.Shell>
</builders>
<publishers>
<hudson.tasks.ArtifactArchiver>
<artifacts>*.py,requirements*.txt</artifacts>
<allowEmptyArchive>true</allowEmptyArchive>
<caseSensitive>true</caseSensitive>
</hudson.tasks.ArtifactArchiver>
</publishers>
<buildWrappers/>
</project>

44
jenkins_deploy.xml Normal file
View File

@@ -0,0 +1,44 @@
<?xml version='1.0' encoding='UTF-8'?>
<project>
<description>Deploy job - deploys Habit Bot to Ubuntu server</description>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.plugins.git.GitSCM">
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<url>https://gittea.cloud-handson.com/joungmin/openclaw-workspace.git</url>
<credentialsId>gitea-credentials</credentialsId>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>*/main</name>
</hudson.plugins.git.BranchSpec>
</branches>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<submoduleCfg class="list"/>
<extensions/>
</scm>
<assignedNode>built-in</assignedNode>
<builders>
<hudson.tasks.Shell>
<command># Stop existing bot
ssh joungmin@192.168.0.147 "pkill -f habit_bot.py || true"
# Copy files
scp habit_bot.py requirements.txt joungmin@192.168.0.147:/home/joungmin/habit_bot/
# Install dependencies
ssh joungmin@192.168.0.147 "cd /home/joungmin/habit_bot && source venv/bin/activate && pip install -q -r requirements.txt"
# Restart bot
ssh joungmin@192.168.0.147 "cd /home/joungmin/habit_bot && source venv/bin/activate && TELEGRAM_BOT_TOKEN=8325588419:AAGghb0nosWG8g6QtYeghqUs0RHug06uG74 nohup python habit_bot.py > bot.log 2>&1 &"
# Verify
sleep 3
ssh joungmin@192.168.0.147 "ps aux | grep habit_bot | grep -v grep"</command>
</hudson.tasks.Shell>
</builders>
<publishers/>
<buildWrappers/>
</project>

41
jenkins_test.xml Normal file
View File

@@ -0,0 +1,41 @@
<?xml version='1.0' encoding='UTF-8'?>
<project>
<description>Test job - runs all unit tests</description>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.plugins.git.GitSCM">
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<url>https://gittea.cloud-handson.com/joungmin/openclaw-workspace.git</url>
<credentialsId>gitea-credentials</credentialsId>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>*/main</name>
</hudson.plugins.git.BranchSpec>
</branches>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<submoduleCfg class="list"/>
<extensions/>
</scm>
<assignedNode>built-in</assignedNode>
<builders>
<hudson.tasks.Shell>
<command>python3 -m venv venv
. venv/bin/activate
pip install -r test_requirements.txt</command>
</hudson.tasks.Shell>
</builders>
<publishers>
<hudson.tasks.JUnitResultArchiver>
<testResults>test-results.xml</testResults>
<allowEmptyResults>true</allowEmptyResults>
</hudson.tasks.JUnitResultArchiver>
<hudson.tasks.Shell>
<command>. venv/bin/activate
pytest tests/ -v --junitxml=test-results.xml --cov=. --cov-report=html</command>
</hudson.tasks.Shell>
</publishers>
<buildWrappers/>
</project>