I am trying to create a cicd pipeline with openshift. Initially, when creating the application using 'oc new-app' command, it automatically triggers the build. How i need to disable the initial build other than deleting or cancel the build?
Asked
Active
Viewed 1,057 times
1 Answers
1
How i need to disable the initial build other than deleting or cancel the build?
oc new-app
can not prevent the initial build.
It had discussed here: https://github.com/openshift/origin/issues/15429
Unfortunately it does not implement now.
But, you can prevent initial build as removing all triggers from buildConfig
by modifying yaml of buildConfig
manually.
- First export
oc new-app
as yaml format.
# oc new-app --name=test \
centos/ruby-25-centos7~https://github.com/sclorg/ruby-ex.git -o yaml --dry-run > test.yml
- Remove all triggers as changing the configuration to
triggers: []
.
strategy:
sourceStrategy:
from:
kind: ImageStreamTag
name: ruby-25-centos7:latest
type: Source
triggers: []
After modifying, create resources using oc create -f
.
# oc create -f test.yml
imagestream.image.openshift.io/ruby-25-centos7 created
imagestream.image.openshift.io/ruby-ex created
buildconfig.build.openshift.io/ruby-ex created
deploymentconfig.apps.openshift.io/ruby-ex created
service/ruby-ex created
The build does not run until you run oc start-build <bc name>
and oc rollout latest dc/<dc name>
.
I hope this use case is helpful for you.

Daein Park
- 4,393
- 2
- 12
- 21
-
Thank you for the solution. It is helpfull. Is there any other way to do this automatically through command other than editing the build configuration manually? – Pragathibaskar Apr 17 '19 at 06:23
-
@Pragathibaskar Unfortunately AFAIK, no, it isn't. There is no way unless modifying directly original template yaml. – Daein Park Apr 17 '19 at 06:37
-
I did like this, export COUNT=`oc get build|grep build-name|wc -l` ; oc apply -f ocp/buildconfig.yaml --wait=true; if [[ "$COUNT" != "0" ]]; then oc start-build build-name --wait=true fi – Ricky Vene Feb 28 '23 at 22:20