I am trying to setup an OpenShift Jenkins pipeline to:
Dockerfile
I have created a BuildConfig
with Docker
strategy which actually works without the pipeline. The problem is I don't know how to run tests
If I try to kick off the build from the Pipeline it does not trigger the build.
Am I on the right path? What be the best approach for the projects like this? Should I keep relying on OpenShift specific tools? Or move to plain Kubernetes?
I am using a https://github.com/openshift/jenkins-client-plugin for the pipeline.
Here is my BuildConfig:
kind: "BuildConfig"
apiVersion: "v1"
metadata:
name: "front-end-build"
spec:
runPolicy: "Serial"
nodeSelector:
hostname: "vhkdld518"
source:
git:
uri: "https://kraporta@bitbucket/scm/~kraporta/test-kube.git"
strategy:
dockerStrategy:
from:
kind: "ImageStreamTag"
name: "nginx:alpine"
dockerfilePath: Dockerfile
output:
to:
kind: "ImageStreamTag"
name: "front-end:latest"
Here is the pipeline:
node {
stage('build') {
openshift.withCluster() {
openshift.withProject() {
echo "Using project: ${openshift.project()}"
def builds = openshift.selector("bc", "front-end-build").related('builds')
builds.describe()
timeout(5) {
builds.untilEach(1) {
it.describe()
echo "Inside loop: ${it}"
return (it.object().status.phase == "Complete")
}
}
}
}
}
}
Thanks a lot!
I know it's an old question but i'd to keep it as reference.
the issue: there's missing step, you haven't start the build process so there's no builds!
the solution: we need to start the build process before fetching the builds, here:
def builds = openshift.selector("bc", "front-end-build").related('builds')
to be (there's many way to be done):
def buildConfig = openshift.selector("bc", "front-end-build")
openshift.startBuild("front-end-build") # we started the build process
def builds = buildConfig.related('builds')
check: https://github.com/openshift/jenkins-client-plugin#watching-and-waiting-of-course
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.