forked from openshift-labs/devops-labs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc61391
commit 8239a8b
Showing
14 changed files
with
2,553 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM registry.access.redhat.com/openshift3/jenkins-slave-maven-rhel7 | ||
|
||
MAINTAINER Siamak Sadeghianfar <[email protected]> | ||
|
||
ENV GRADLE_VERSION=3.4.1 | ||
|
||
USER root | ||
|
||
RUN curl -skL -o /tmp/gradle-bin.zip https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip && \ | ||
mkdir -p /opt/gradle && \ | ||
unzip -q /tmp/gradle-bin.zip -d /opt/gradle && \ | ||
ln -sf /opt/gradle/gradle-$GRADLE_VERSION/bin/gradle /usr/local/bin/gradle | ||
|
||
RUN chown -R 1001:0 /opt/gradle && \ | ||
chmod -R g+rw /opt/gradle | ||
|
||
USER 1001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
apiVersion: v1 | ||
kind: Template | ||
metadata: | ||
annotations: | ||
iconClass: icon-java | ||
tags: microservice,jboss | ||
name: cart | ||
objects: | ||
- apiVersion: v1 | ||
kind: ImageStream | ||
metadata: | ||
name: cart | ||
labels: | ||
application: cart | ||
spec: | ||
tags: | ||
- name: latest | ||
- apiVersion: v1 | ||
kind: BuildConfig | ||
metadata: | ||
name: cart | ||
labels: | ||
application: cart | ||
spec: | ||
output: | ||
to: | ||
kind: ImageStreamTag | ||
name: cart:latest | ||
source: | ||
git: | ||
ref: ${GIT_REF} | ||
uri: ${GIT_URI} | ||
type: Git | ||
strategy: | ||
sourceStrategy: | ||
env: | ||
- name: MAVEN_MIRROR_URL | ||
value: ${MAVEN_MIRROR_URL} | ||
from: | ||
kind: ImageStreamTag | ||
name: redhat-openjdk18-openshift:1.0 | ||
namespace: openshift | ||
type: Source | ||
triggers: | ||
- type: ConfigChange | ||
- imageChange: {} | ||
type: ImageChange | ||
- apiVersion: v1 | ||
kind: DeploymentConfig | ||
metadata: | ||
name: cart | ||
labels: | ||
application: cart | ||
spec: | ||
replicas: 1 | ||
selector: | ||
deploymentconfig: cart | ||
strategy: | ||
resources: {} | ||
type: Recreate | ||
template: | ||
metadata: | ||
labels: | ||
application: cart | ||
deploymentconfig: cart | ||
name: cart | ||
spec: | ||
containers: | ||
- env: | ||
- name: CATALOG_ENDPOINT | ||
value: "http://catalog:8080" | ||
image: cart | ||
imagePullPolicy: Always | ||
livenessProbe: | ||
failureThreshold: 5 | ||
httpGet: | ||
path: /health | ||
port: 8080 | ||
scheme: HTTP | ||
initialDelaySeconds: 45 | ||
periodSeconds: 5 | ||
successThreshold: 1 | ||
timeoutSeconds: 1 | ||
name: cart | ||
ports: | ||
- containerPort: 8778 | ||
name: jolokia | ||
protocol: TCP | ||
- containerPort: 8080 | ||
name: http | ||
protocol: TCP | ||
- containerPort: 8443 | ||
name: https | ||
protocol: TCP | ||
readinessProbe: | ||
failureThreshold: 10 | ||
httpGet: | ||
path: /health | ||
port: 8080 | ||
scheme: HTTP | ||
initialDelaySeconds: 45 | ||
periodSeconds: 5 | ||
successThreshold: 1 | ||
timeoutSeconds: 1 | ||
resources: | ||
limits: | ||
memory: 1Gi | ||
requests: | ||
memory: 200Mi | ||
terminationMessagePath: /dev/termination-log | ||
dnsPolicy: ClusterFirst | ||
restartPolicy: Always | ||
securityContext: {} | ||
terminationGracePeriodSeconds: 75 | ||
triggers: | ||
- imageChangeParams: | ||
automatic: true | ||
containerNames: | ||
- cart | ||
from: | ||
kind: ImageStreamTag | ||
name: cart:latest | ||
type: ImageChange | ||
- type: ConfigChange | ||
- apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app: cart | ||
application: cart | ||
name: cart | ||
spec: | ||
ports: | ||
- port: 8080 | ||
protocol: TCP | ||
targetPort: 8080 | ||
selector: | ||
deploymentconfig: cart | ||
- apiVersion: v1 | ||
kind: Route | ||
metadata: | ||
labels: | ||
app: cart | ||
application: cart | ||
name: cart | ||
spec: | ||
to: | ||
kind: Service | ||
name: cart | ||
weight: 100 | ||
wildcardPolicy: None | ||
parameters: | ||
- displayName: Application name | ||
name: APPLICATION_NAME | ||
required: true | ||
value: cart | ||
- description: Git source URI for application | ||
displayName: Git source repository | ||
name: GIT_URI | ||
required: true | ||
- description: Git branch/tag reference | ||
displayName: Git branch/tag reference | ||
name: GIT_REF | ||
- description: Sub-directory in the Git repo for cart service | ||
displayName: Git context dir | ||
name: GIT_CONTEXT_DIR | ||
- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
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') | ||
} | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
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 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'" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: v1 | ||
kind: BuildConfig | ||
metadata: | ||
annotations: | ||
pipeline.alpha.openshift.io/uses: '[{"name": "cart", "namespace": "", "kind": "DeploymentConfig"}]' | ||
name: cart-pipeline-git | ||
spec: | ||
source: | ||
git: | ||
uri: http://gogs.lab-infra.svc.cluster.local:3000/developer/pipelines.git | ||
type: Git | ||
strategy: | ||
type: JenkinsPipeline | ||
jenkinsPipelineStrategy: {} | ||
triggers: | ||
- generic: | ||
secret: FiArdDBH | ||
type: Generic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
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?' | ||
} | ||
} | ||
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'" | ||
} | ||
} |
Oops, something went wrong.