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

Conditional executiom stages #138

Open
wants to merge 20 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
30 changes: 30 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
pipeline {
agent any

stages{
stage("one"){
steps{
echo 'step 1'
sleep 3
}
}
stage("two"){
steps{
echo 'step 2'
sleep 9
}
}
stage("three"){
steps{
echo 'step 3'
sleep 5
}
}
}

post{
always{
echo 'This pipeline is completed.'
}
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Example Voting App
=========
==========

Getting started
---------------
Expand Down
13 changes: 13 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
services:
vote:
image: zkube/vote:latest
ports:
- 5000:80

result:
image: zkube/result:latest
ports:
- 5001:4000

worker:
image: zkube/worker:latest
6 changes: 6 additions & 0 deletions worker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
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
89 changes: 89 additions & 0 deletions worker/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
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 worker 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 Tets 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 worker 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("zkube/worker:v${env.BUILD_ID}", "./worker")
workerImage.push()
workerImage.push("${env.BRANCH_NAME}")
workerImage.push("latest")
}
}
}
}
}

post{
always{
echo 'Building multibranch pipeline for worker is completed..'
}
}
}