From 9afa8808db857da684a6b8acba71cbe087c779fa Mon Sep 17 00:00:00 2001 From: rorapp Date: Mon, 24 Feb 2025 14:07:22 +0100 Subject: [PATCH] add raw state of with jenkins --- .gitignore | 3 ++- Jenkinsfile | 34 +++++++++++++++++++++++++ apps/develop/jenkins/docker-compose.yml | 16 +++++++++--- apps/develop/jenkins/plugins.yml | 0 4 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 Jenkinsfile create mode 100644 apps/develop/jenkins/plugins.yml diff --git a/.gitignore b/.gitignore index 826710d..d3b94ce 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ volumes apps/proxy .DS_Store apps/administration/* -apps/tools/app/* \ No newline at end of file +apps/tools/app/* +env/secrets.env diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..7d4a474 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,34 @@ + + +pipeline { + agent any + + stages { + stage('Checkout Code & Submodules') { + steps { + git branch: 'main', url: 'git@github.com:your-org/my-main-repo.git', credentialsId: 'git-credentials' + sh 'git submodule update --init --recursive' + } + } + + stage('Run Backend Pipeline') { + steps { + build job: 'backend-pipeline', wait: true + } + } + + stage('Run Frontend Pipeline') { + steps { + build job: 'frontend-pipeline', wait: true + } + } + + stage('Deploy Infrastructure') { + steps { + sshagent(['jenkins-ssh-key']) { + sh "ssh user@server 'cd /opt/myapp && git pull origin main && docker compose up -d'" + } + } + } + } +} diff --git a/apps/develop/jenkins/docker-compose.yml b/apps/develop/jenkins/docker-compose.yml index f71dc7e..4452b95 100644 --- a/apps/develop/jenkins/docker-compose.yml +++ b/apps/develop/jenkins/docker-compose.yml @@ -1,5 +1,4 @@ -version: '3.8' - +### Jenkins (./apps/frontend/docker-compose.yml) services: jenkins: image: jenkins/jenkins:lts @@ -7,7 +6,10 @@ services: ports: - "50000:50000" # Jenkins Agent Port volumes: - - jenkins_home:/var/jenkins_home + - ../../../volumes/develop/jenkins:/var/jenkins_home + - ./plugins.yml:/usr/share/jenkins/ref/plugins.yml + depends_on: + - jenkins-plugins environment: - JAVA_OPTS=-Djenkins.install.runSetupWizard=false networks: @@ -21,6 +23,14 @@ services: - "traefik.http.services.jenkins.loadbalancer.server.port=8080" # interner Port von Jenkins - "traefik.docker.network=proxy" + jenkins-plugins: + image: jenkins/jenkins:lts-jdk17 + command: > + jenkins-plugin-cli -f /usr/share/jenkins/ref/plugins.yml --available-updates --output txt > /usr/share/jenkins/ref/plugins.yml + volumes: + - ./plugins.yml:/usr/share/jenkins/ref/plugins.yml + restart: "no" + volumes: jenkins_home: driver: local diff --git a/apps/develop/jenkins/plugins.yml b/apps/develop/jenkins/plugins.yml new file mode 100644 index 0000000..e69de29