Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/dockerbuild #144

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Example Voting App
=========

THIS IS A SAMPLE VOTING APP.

Getting started
---------------

Expand All @@ -20,6 +22,7 @@ Once you have your swarm, in this directory run:
```
docker stack deploy --compose-file docker-stack.yml vote
```
Esto es una prueba

Run the app in Kubernetes
-------------------------
Expand Down
36 changes: 36 additions & 0 deletions result/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
pipeline {
agent any
tools {
nodejs 'NodeJS 8.9.0'
}
stages {
stage ("build") {
when {
changeset "**/result/**"
}
steps {
echo 'Compiling result app'
dir ('worker') {
sh 'npm install'
}
}
}
stage ("test") {
when {
changeset "**/result/**"
}
steps {
echo 'Running Unit Test on result app'
dir ('result') {
sh 'npm install'
sh 'npm test'
}
}
}
}
post {
always {
echo 'Building multibranch pipeline for result is completed..'
}
}
}
5 changes: 5 additions & 0 deletions result/test/mock.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ describe('mock test 4', () => {
});
});

describe('mock test 5', () => {
it('unit test 5', () => {
expect(true).to.be.true;
});
});

5 changes: 5 additions & 0 deletions worker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM maven:3.6.1-jdk-8-slim
WORKDIR /app
COPY . .
RUN mvn package && mv target/worker-jar-with-dependencies.jar /run/worker.jar && rm -rf /app/*
CMD java -jar /run/worker.jar
81 changes: 81 additions & 0 deletions worker/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
pipeline {
agent none
stages {
stage ("build") {
when {
changeset "**/worker/**"
}
agent {
docker {
image 'maven:3.6.1-jdk-8-slim'
args '-v $HOME/.m2:/root/.m2'
}
}
steps {
echo 'Compiling working app...'
dir ('worker') {
sh 'mvn compile'
}
}
}
stage ("test") {
when {
changeset "**/worker/**"
}
agent {
docker {
image 'maven:3.6.1-jdk-8-slim'
args '-v $HOME/.m2:/root/.m2'
}
}
steps {
echo 'Running Unit Test on worker app'
dir ('worker') {
sh 'mvn clean test'
}
}
}
stage ("package") {
when {
branch 'master'
changeset "**/worker/**"
}
agent {
docker {
image 'maven:3.6.1-jdk-8-slim'
args '-v $HOME/.m2:/root/.m2'
}
}
steps {
echo 'Packaging working app'
dir ('worker') {
sh 'mvn package -DskipTests'
archiveArtifacts artifacts: '**/target/*.jar',
fingerprint: true
}
}
}
stage ('docker-package') {
agent any
when {
changeset "**/worker/**"
branch 'master
}
steps {
echo 'Packaging worker app with docker'
script {
docker.withRegistry ('https://index.docker.io/v1/','dockerlogin') {
def workerImage = docker.build("aruizcanton/worker:v${env.BUILD_ID}", "./ worker")
workerImage.push()
workerImage.push("latest")
}
}
}
}
post {
always {
echo 'Building multibranch pipeline for worker is completed...'
}
}
}
}