Skip to content

Commit

Permalink
updated solutions for ocp 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
siamaksade committed Mar 2, 2018
1 parent 8239a8b commit a9c9f8e
Show file tree
Hide file tree
Showing 10 changed files with 242 additions and 974 deletions.
2 changes: 1 addition & 1 deletion openshift/coolstore-build-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ parameters:
- displayName: Git branch/tag reference
name: GIT_REF
required: true
value: master
value: ocp-3.7
- description: Maven mirror url. If nexus is deployed locally, use nexus url (e.g. http://nexus.ci:8081/content/groups/public/)
displayName: Maven mirror url
name: MAVEN_MIRROR_URL
Expand Down
2 changes: 1 addition & 1 deletion openshift/coolstore-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ parameters:
- displayName: Git branch/tag reference
name: GIT_REF
required: true
value: master
value: ocp-3.7
- description: Maven mirror url. If nexus is deployed locally, use nexus url (e.g. http://nexus.ci:8081/content/groups/public/)
displayName: Maven mirror url
name: MAVEN_MIRROR_URL
Expand Down
2 changes: 1 addition & 1 deletion solutions/lab-10/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM registry.access.redhat.com/openshift3/jenkins-slave-maven-rhel7

MAINTAINER Siamak Sadeghianfar <[email protected]>

ENV GRADLE_VERSION=3.4.1
ENV GRADLE_VERSION=3.6

USER root

Expand Down
2 changes: 1 addition & 1 deletion solutions/lab-3/cart-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ objects:
value: ${MAVEN_MIRROR_URL}
from:
kind: ImageStreamTag
name: redhat-openjdk18-openshift:1.0
name: redhat-openjdk18-openshift:1.1
namespace: openshift
type: Source
triggers:
Expand Down
50 changes: 36 additions & 14 deletions solutions/lab-4/cart-pipeline.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,46 @@
apiVersion: v1
kind: BuildConfig
metadata:
annotations:
pipeline.alpha.openshift.io/uses: '[{"name": "cart", "namespace": "", "kind": "DeploymentConfig"}]'
name: cart-pipeline
spec:
strategy:
jenkinsPipelineStrategy:
jenkinsfile: |-
node('maven') {
stage('Build') {
openshiftBuild(buildConfig: 'cart', showBuildLogs: 'true')
pipeline {
agent any
stages {
stage('Build') {
steps {
script {
openshift.withCluster() {
openshift.withProject() {
openshift.startBuild("cart", "--follow")
}
}
}
}
}
stage('Deploy') {
steps {
script {
openshift.withCluster() {
openshift.withProject() {
dc = openshift.selector("dc", "cart")
dc.rollout().latest()
timeout(10) {
dc.rollout().status("-w")
}
}
}
}
}
}
stage('Test') {
steps {
sh "curl -s -X POST http://cart:8080/api/cart/dummy/666/1"
sh "curl -s http://cart:8080/api/cart/dummy | grep 'Dummy Product'"
}
}
}
stage('Deploy') {
openshiftDeploy(deploymentConfig: 'cart')
openshiftVerifyDeployment(deploymentConfig: "cart", replicaCount: 1, verifyReplicaCount: true)
}
stage('Test') {
sh "curl -s -X POST http://cart.dev.svc.cluster.local:8080/api/cart/dummy/666/1"
sh "curl -s http://cart.dev.svc.cluster.local:8080/api/cart/dummy | grep 'Dummy Product'"
}
}
}
type: JenkinsPipeline
67 changes: 49 additions & 18 deletions solutions/lab-5/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,51 @@
node('maven') {
stage('Build App') {
git url: "http://gogs.lab-infra.svc.cluster.local:3000/developer/cart-service.git"
sh "mvn clean package -s src/main/config/settings.xml"
pipeline {
agent {
label 'maven'
}
stage('Integration Test') {
sh "mvn verify -s src/main/config/settings.xml"
stages {
stage('Build App') {
steps {
sh "mvn clean package -s src/main/config/settings.xml"
}
}
stage('Integration Test') {
steps {
sh "mvn verify -s src/main/config/settings.xml"
}
}
stage('Build Image') {
steps {
script {
openshift.withCluster() {
openshift.withProject() {
openshift.startBuild("cart", "--from-file=target/cart.jar", "--follow")
}
}
}
}
}
stage('Deploy') {
steps {
script {
openshift.withCluster() {
openshift.withProject() {
dc = openshift.selector("dc", "cart")
dc.rollout().latest()
timeout(10) {
dc.rollout().status("-w")
}
}
}
}
}
}
stage('Component Test') {
steps {
script {
sh "curl -s -X POST http://cart:8080/api/cart/dummy/666/1"
sh "curl -s http://cart:8080/api/cart/dummy | grep 'Dummy Product'"
}
}
}
}
stage('Build Image') {
sh "oc start-build cart --from-file=target/cart.jar --follow"
}
stage('Deploy') {
openshiftDeploy deploymentConfig: 'cart'
openshiftVerifyDeployment deploymentConfig: "cart", replicaCount: 1, verifyReplicaCount: true
}
stage('Component Test') {
sh "curl -s -X POST http://cart.dev.svc.cluster.local:8080/api/cart/dummy/666/1"
sh "curl -s http://cart.dev.svc.cluster.local:8080/api/cart/dummy | grep 'Dummy Product'"
}
}
}
94 changes: 61 additions & 33 deletions solutions/lab-6/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,63 @@
node('maven') {
stage('Build App') {
git url: "http://gogs.lab-infra.svc.cluster.local:3000/developer/cart-service.git"
sh "mvn clean package -s src/main/config/settings.xml"
}
stage('Integration Test') {
sh "mvn verify -s src/main/config/settings.xml"
}
stage('Build Image') {
sh "oc start-build cart --from-file=target/cart.jar --follow"
}
stage('Deploy') {
openshiftDeploy depCfg: 'cart'
openshiftVerifyDeployment depCfg: 'cart', replicaCount: 1, verifyReplicaCount: true
}
stage('Component Test') {
sh "curl -s -X POST http://cart.dev.svc.cluster.local:8080/api/cart/dummy/666/1"
sh "curl -s http://cart.dev.svc.cluster.local:8080/api/cart/dummy | grep 'Dummy Product'"
}
stage('Approve') {
timeout(time:15, unit:'MINUTES') {
input message:'Approve Deploy to Prod?'
pipeline {
agent {
label 'maven'
}
stages {
stage('Build App') {
steps {
sh "mvn clean package -s src/main/config/settings.xml"
}
}
stage('Integration Test') {
steps {
sh "mvn verify -s src/main/config/settings.xml"
}
}
stage('Build Image') {
steps {
script {
openshift.withCluster() {
openshift.withProject() {
openshift.startBuild("cart", "--from-file=target/cart.jar", "--follow")
}
}
}
}
}
stage('Deploy') {
steps {
script {
openshift.withCluster() {
openshift.withProject() {
dc = openshift.selector("dc", "cart")
dc.rollout().latest()
timeout(10) {
dc.rollout().status("-w")
}
}
}
}
}
}
stage('Component Test') {
steps {
script {
sh "curl -s -X POST http://cart:8080/api/cart/dummy/666/1"
sh "curl -s http://cart:8080/api/cart/dummy | grep 'Dummy Product'"
}
}
}
stage('Promote to Prod') {
steps {
timeout(time:15, unit:'MINUTES') {
input message: "Approve Promotion to Prod?", ok: "Promote"
}
script {
openshift.withCluster() {
openshift.tag("dev-XX/cart:latest", "prod-XX/cart:prod")
}
}
}
}
}
stage('Promote') {
openshiftTag srcStream: 'cart', srcTag: 'latest', namespace: 'dev', destStream: 'cart', destTag: 'prod', destinationNamespace: 'prod'
sleep 10
openshiftVerifyDeployment depCfg: 'cart', replicaCount: 1, verifyReplicaCount: true, namespace: 'prod'
}

stage('End-To-End Test') {
sh "curl -s -X POST http://cart.prod.svc.cluster.local:8080/api/cart/dummy/444434/1"
sh "curl -s http://cart.prod.svc.cluster.local:8080/api/cart/dummy | grep 'Pebble Smart Watch'"
}
}
}
Loading

0 comments on commit a9c9f8e

Please sign in to comment.