diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..c986de24 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,31 @@ +pipeline { + agent any + + stages { + stage('one') { + steps { + echo 'step 1' + } + } + stage('two') { + steps { + echo 'step 2' + } + } + stage('three') { + when { + branch 'master' + changeset "**/worker/**" + } + steps { + echo 'step 3' + sleep(time: 5, unit: 'SECONDS') + } + } + } + post { + always{ + echo 'This pipeline is completed.' + } + } +} diff --git a/README.md b/README.md index a8ee7312..0f6bad46 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Example Voting App ========= -Getting started +Getting started modified --------------- Download [Docker](https://www.docker.com/products/overview). If you are on Mac or Windows, [Docker Compose](https://docs.docker.com/compose) will be automatically installed. On Linux, make sure you have the latest version of [Compose](https://docs.docker.com/compose/install/). If you're using [Docker for Windows](https://docs.docker.com/docker-for-windows/) on Windows 10 pro or later, you must also [switch to Linux containers](https://docs.docker.com/docker-for-windows/#switch-between-windows-and-linux-containers). diff --git a/result/Jenkinsfile b/result/Jenkinsfile new file mode 100644 index 00000000..d3b5e3fa --- /dev/null +++ b/result/Jenkinsfile @@ -0,0 +1,32 @@ +pipeline { + agent any + + tools { + nodejs "NodeJS 22.4.0" + } + stages { + stage("Build") { + when { + changeset "**/result/**" + } + steps { + echo "Compiling result app" + dir("result") { + sh 'npm install' + } + } + } + + stage("Test") { + when { + changeset "**/result/**" + } + steps { + echo "Testing result app" + dir("result") { + sh 'npm install && npm test' + } + } + } + } +} \ No newline at end of file diff --git a/result/test/mock.test.js b/result/test/mock.test.js index aac87156..c33a7c04 100644 --- a/result/test/mock.test.js +++ b/result/test/mock.test.js @@ -4,7 +4,7 @@ describe('mock test 1', () => { it('unit test 1', () => { expect(true).to.be.true; }); -}); +}); describe('mock test 2', () => { @@ -36,5 +36,11 @@ describe('mock test 6', () => { it('unit test 6', () => { expect(true).to.be.true; }); -}); + describe('mock test 7', () => { + it('unit test 7', () => { + expect(true).to.be.true; + }); + }); + +}); diff --git a/worker/Jenkinsfile b/worker/Jenkinsfile new file mode 100644 index 00000000..8162c0c8 --- /dev/null +++ b/worker/Jenkinsfile @@ -0,0 +1,50 @@ +pipeline { + agent any + + tools { + maven 'maven 3.9.8' + } + + stages { + stage('build') { + when{ + changeset "**/worker/**" + } + steps { + echo 'compiling worker app' + dir('worker') { + sh 'mvn compile' + } + } + } + stage('test') { + when{ + changeset "**/worker/**" + } + steps { + echo 'Running Unit Tests on worker app' + dir('worker') { + sh 'mvn clean test' + } + } + } + stage('package') { + when{ + branch 'master' + changeset "**/worker/**" + } + steps { + echo 'Packaging worker app' + dir('worker') { + sh 'mvn clean package -DskipTests' + archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true + } + } + } + } + post { + always{ + echo 'Building multibranch pipeline for worker app is completed.' + } + } +}