#!/usr/bin/env groovy
@Library('github.com/stakater/fabric8-pipeline-library@master')
def localItestPattern = ""
try {
localItestPattern = ITEST_PATTERN
} catch (Throwable e) {
localItestPattern = "*KT"
}
def localFailIfNoTests = ""
try {
localFailIfNoTests = ITEST_FAIL_IF_NO_TEST
} catch (Throwable e) {
localFailIfNoTests = "false"
}
def versionPrefix = ""
try {
versionPrefix = VERSION_PREFIX
} catch (Throwable e) {
versionPrefix = "1.0"
}
def canaryVersion = "${versionPrefix}.${env.BUILD_NUMBER}"
def fabric8Console = "${env.FABRIC8_CONSOLE ?: ''}"
def utils = new io.fabric8.Utils()
def label = "buildpod.${env.JOB_NAME}.${env.BUILD_NUMBER}".replace('-', '_').replace('/', '_')
def envStage = utils.environmentNamespace('stage')
def envProd = utils.environmentNamespace('run')
def stashName = ""
def deploy = false
// TODO # 1 : use different profile dev or prod
// TODO # 2 : use config maps
// TODO # 3 : the code is being checked out multiple times; that should be fixed! must be checked out only once
// TODO # 4 : run performance tests ( gatling ) and save stats
// TODO # 5 : the artifacts should be archived & should be browse'able from Jenkins!
mavenNode(mavenImage: 'stakater/chrome') {
container(name: 'maven') {
stage("checkout") {
checkout scm
}
stage("clean") {
sh 'chmod +x mvnw'
sh './mvnw clean'
}
stage('install tools') {
sh './mvnw com.github.eirslett:frontend-maven-plugin:install-node-and-yarn -DnodeVersion=v6.11.1 -DyarnVersion=v0.27.5'
}
stage('yarn install') {
sh './mvnw com.github.eirslett:frontend-maven-plugin:yarn'
}
stage('Canary Release'){
mavenCanaryRelease {
version = canaryVersion
}
}
stage('Integration Testing') {
mavenIntegrationTest {
environment = 'Test'
failIfNoTests = localFailIfNoTests
itestPattern = localItestPattern
}
}
// timeout is in milliseconds
stage('Rollout to Stage') {
envStage = "apps"
echo "Environment name:: ${envStage}"
kubernetesApply(readinessTimeout: 180000, environment: envStage)
// TODO: figure out why to stash deployments?
// TODO: from where does the stash command comes?
//stash deployments
stashName = label
stash includes: '**/*.yml', name: stashName
}
}
}
Recording test results
[Pipeline] findFiles
[Pipeline] junit
Recording test results
[Pipeline] echo
Failed to find test results
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Rollout to Stage)
[Pipeline] echo
Environment name:: tools
[Pipeline] kubernetesApply
Found namespace apps
Found namespace default
Found namespace internal
Found namespace kube-public
Found namespace kube-system
Found namespace n
Found namespace tools
Found existing environment tools
Found BuildConfig name organizationpreference namespace ${PROJECT_NAMESPACE} from BuildConfigProjectProperty
The Run has not been enriched by the jenkins-sync plugin with the BuildCause to make it easy to detect the Build name
Found BuildConfig: organizationpreference namespace: ${PROJECT_NAMESPACE} Build: organizationpreference-18
Adapting resources to use pull images from registry: 10.32.0.179:80
About to apply resource[Service(apiVersion=v1, kind=Service, metadata=ObjectMeta(annotations={fabric8.io/ingress.annotations=kubernetes.io/ingress.class: internal-ingress
ingress.kubernetes.io/force-ssl-redirect: true, fabric8.io/git-commit=d59e7c6bfa0ea0a0013317c3a32ebdd94937dbb4, prometheus.io/port=9779, fabric8.io/scm-url=https://github.com/spring-projects/spring-boot/spring-boot-starter-parent/organization-preference, fabric8.io/iconUrl=img/icons/spring-boot.svg, fabric8.io/git-branch=OrganizationPreference-1.18, prometheus.io/scrape=true, fabric8.io/scm-tag=HEAD}, clusterName=null, creationTimestamp=null, deletionGracePeriodSeconds=null, deletionTimestamp=null, finalizers=[], generateName=null, generation=null, labels={expose=true, app=organization-preference, provider=fabric8, version=1.18, group=com.scania.digitaldealer.organizationpreference}, name=organization-preference, namespace=null, ownerReferences=[], resourceVersion=null, selfLink=null, uid=null, additionalProperties={}), spec=ServiceSpec(clusterIP=null, deprecatedPublicIPs=[], externalIPs=[], externalName=null, loadBalancerIP=null, loadBalancerSourceRanges=[], ports=[ServicePort(name=http, nodePort=null, port=8080, protocol=TCP, targetPort=IntOrString(IntVal=8080, Kind=null, StrVal=null, additionalProperties={}), additionalProperties={})], selector={app=organization-preference, provider=fabric8, group=com.scania.digitaldealer.organizationpreference}, sessionAffinity=null, type=null, additionalProperties={}), status=null, additionalProperties={}), Deployment(apiVersion=extensions/v1beta1, kind=Deployment, metadata=ObjectMeta(annotations={fabric8.io/git-commit=d59e7c6bfa0ea0a0013317c3a32ebdd94937dbb4, fabric8.io/iconUrl=img/icons/spring-boot.svg, fabric8.io/git-branch=OrganizationPreference-1.18, fabric8.io/metrics-path=dashboard/file/kubernetes-pods.json/?var-project=organization-preference&var-version=1.18, fabric8.io/scm-tag=HEAD, fabric8.io/scm-url=https://github.com/spring-projects/spring-boot/spring-boot-starter-parent/organization-preference}, clusterName=null, creationTimestamp=null, deletionGracePeriodSeconds=null, deletionTimestamp=null, finalizers=[], generateName=null, generation=null, labels={app=organization-preference, provider=fabric8, version=1.18, group=com.scania.digitaldealer.organizationpreference}, name=organization-preference, namespace=null, ownerReferences=[], resourceVersion=null, selfLink=null, uid=null, additionalProperties={}), spec=DeploymentSpec(minReadySeconds=null, paused=null, progressDeadlineSeconds=null, replicas=1, revisionHistoryLimit=2, rollbackTo=null, selector=LabelSelector(matchExpressions=[], matchLabels={app=organization-preference, provider=fabric8, group=com.scania.digitaldealer.organizationpreference}, additionalProperties={}), strategy=null, template=PodTemplateSpec(metadata=ObjectMeta(annotations={fabric8.io/git-commit=d59e7c6bfa0ea0a0013317c3a32ebdd94937dbb4, fabric8.io/metrics-path=dashboard/file/kubernetes-pods.json/?var-project=organization-preference&var-version=1.18, fabric8.io/scm-url=https://github.com/spring-projects/spring-boot/spring-boot-starter-parent/organization-preference, fabric8.io/iconUrl=img/icons/spring-boot.svg, fabric8.io/git-branch=OrganizationPreference-1.18, fabric8.io/scm-tag=HEAD}, clusterName=null, creationTimestamp=null, deletionGracePeriodSeconds=null, deletionTimestamp=null, finalizers=[], generateName=null, generation=null, labels={app=organization-preference, provider=fabric8, version=1.18, group=com.scania.digitaldealer.organizationpreference}, name=null, namespace=null, ownerReferences=[], resourceVersion=null, selfLink=null, uid=null, additionalProperties={}), spec=PodSpec(activeDeadlineSeconds=null, containers=[Container(args=[], command=[], env=[EnvVar(name=KUBERNETES_NAMESPACE, value=null, valueFrom=EnvVarSource(configMapKeyRef=null, fieldRef=ObjectFieldSelector(apiVersion=null, fieldPath=metadata.namespace, additionalProperties={}), resourceFieldRef=null, secretKeyRef=null, additionalProperties={}), additionalProperties={}), EnvVar(name=JAVA_APP_JAR, value=organization-preference-1.18.war, valueFrom=null, additionalProperties={})], image=10.32.0.179:80/organizationpreference/organization-preference:1.18, imagePullPolicy=IfNotPresent, lifecycle=null, livenessProbe=Probe(exec=null, failureThreshold=null, httpGet=HTTPGetAction(host=null, httpHeaders=[], path=/health, port=IntOrString(IntVal=8080, Kind=null, StrVal=null, additionalProperties={}), scheme=HTTP, additionalProperties={}), initialDelaySeconds=180, periodSeconds=null, successThreshold=null, tcpSocket=null, timeoutSeconds=null, additionalProperties={}), name=spring-boot, ports=[ContainerPort(containerPort=8080, hostIP=null, hostPort=null, name=http, protocol=TCP, additionalProperties={}), ContainerPort(containerPort=9779, hostIP=null, hostPort=null, name=prometheus, protocol=TCP, additionalProperties={}), ContainerPort(containerPort=8778, hostIP=null, hostPort=null, name=jolokia, protocol=TCP, additionalProperties={})], readinessProbe=Probe(exec=null, failureThreshold=null, httpGet=HTTPGetAction(host=null, httpHeaders=[], path=/health, port=IntOrString(IntVal=8080, Kind=null, StrVal=null, additionalProperties={}), scheme=HTTP, additionalProperties={}), initialDelaySeconds=10, periodSeconds=null, successThreshold=null, tcpSocket=null, timeoutSeconds=null, additionalProperties={}), resources=null, securityContext=SecurityContext(capabilities=null, privileged=false, readOnlyRootFilesystem=null, runAsNonRoot=null, runAsUser=null, seLinuxOptions=null, additionalProperties={}), stdin=null, stdinOnce=null, terminationMessagePath=null, tty=null, volumeMounts=[], workingDir=null, additionalProperties={})], dnsPolicy=null, hostIPC=null, hostNetwork=null, hostPID=null, hostname=null, imagePullSecrets=[], nodeName=null, nodeSelector=null, restartPolicy=null, securityContext=null, serviceAccount=null, serviceAccountName=null, subdomain=null, terminationGracePeriodSeconds=null, volumes=[], additionalProperties={}), additionalProperties={}), additionalProperties={}), status=null, additionalProperties={})]
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // container
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // podTemplate
[Pipeline] End of Pipeline
ERROR: Error during kubernetes apply: io.fabric8.kubernetes.client.KubernetesClientTimeoutException: Timed out waiting for [180000] milliseconds for multiple resources. Resources that are not ready: [Kind:Deployment Name:organization-preference Namespace:tools]
at io.fabric8.kubernetes.client.dsl.internal.NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl.waitUntilReady(NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl.java:121)
at io.fabric8.kubernetes.client.dsl.internal.NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl.waitUntilReady(NamespaceVisitFromServerGetWatchDeleteRecreateWaitApplicableListImpl.java:66)
at io.fabric8.kubernetes.pipeline.devops.ApplyStepExecution.run(ApplyStepExecution.java:244)
at io.fabric8.kubernetes.pipeline.devops.ApplyStepExecution.run(ApplyStepExecution.java:92)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousStepExecution.start(AbstractSynchronousStepExecution.java:42)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:224)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:150)
at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108)
at sun.reflect.GeneratedMethodAccessor284.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:155)
at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:123)
at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:153)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:157)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:127)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:127)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:127)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
at sun.reflect.GeneratedMethodAccessor265.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.dispatch(CollectionLiteralBlock.java:55)
at com.cloudbees.groovy.cps.impl.CollectionLiteralBlock$ContinuationImpl.item(CollectionLiteralBlock.java:45)
at sun.reflect.GeneratedMethodAccessor270.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
at com.cloudbees.groovy.cps.impl.LocalVariableBlock$LocalVariable.get(LocalVariableBlock.java:39)
at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
at com.cloudbees.groovy.cps.impl.LocalVariableBlock.evalLValue(LocalVariableBlock.java:28)
at com.cloudbees.groovy.cps.LValueBlock$BlockImpl.eval(LValueBlock.java:55)
at com.cloudbees.groovy.cps.LValueBlock.eval(LValueBlock.java:16)
at com.cloudbees.groovy.cps.Next.step(Next.java:83)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:173)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:162)
at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:122)
at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:261)
at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:162)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:19)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:35)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:32)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:32)
at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:330)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:82)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:242)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:230)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE