OpenShift Build Configuration Definition: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=External= * https://docs.openshift.com/container-platform/latest/rest_api/openshift_v1.html#v1-buildconfig =Internal= * OpenShift_Concepts#Build_Configuration|OpenShift...")
 
 
(51 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
=External=


* https://docs.openshift.com/container-platform/latest/rest_api/openshift_v1.html#v1-buildconfig
* https://docs.openshift.com/container-platform/latest/rest_api/apis-build.openshift.io/v1.BuildConfig.html


=Internal=
=Internal=
Line 7: Line 7:
* [[OpenShift_Concepts#Build_Configuration|OpenShift Concepts]]
* [[OpenShift_Concepts#Build_Configuration|OpenShift Concepts]]
* [[OpenShift_Configuration#Definitions|OpenShift Definitions]]
* [[OpenShift_Configuration#Definitions|OpenShift Definitions]]
* [[OpenShift_Build_Operations#Create_a_Build_Configuration|Create a Build Configuration]]
=Source Strategy Example=
apiVersion: v1
kind: BuildConfig
metadata:
  labels:
    app: eap70-basic-s2i
    application: session-servlet
    template: eap70-basic-s2i
    xpaas: 1.4.0
  name: session-servlet
'''[[OpenShift_REST_Resource_Definition_Schema#spec|spec]]''':
  '''strategy''':
    '''type''': '''Source'''
    '''[[OpenShift_Build_Configuration_Definition#sourceStrategy|sourceStrategy]]''':
      '''[[OpenShift_Build_Configuration_Definition#env|env]]''':
          - name: MAVEN_MIRROR_URL
            value: "..."
          - name: ARTIFACT_DIR
            value: "..."
      from:
          kind: ImageStreamTag
          name: jboss-eap70-openshift:1.5
          namespace: openshift
      '''[[#scripts|scripts]]''': <font color=SandyBrown>"http&#58;//novaordis.io/openshift/scripts_directory"</font>
      forcePull: true
 
  '''source''':
    contextDir: /
    git:
      ref: master
      uri: https&#58;//github.com/NovaOrdis/novaordis-session-servlet.git
    type: Git
  <span id='output'></span>'''output''':
    to:
      kind: ImageStreamTag
      name: session-servlet:latest
  failedBuildsHistoryLimit: 5
  nodeSelector: null
  postCommit: {}
  resources: {}
  runPolicy: Serial
  successfulBuildsHistoryLimit: 5
  triggers:
  - github:
      secret: v2h6dtKw7Gw3
    type: GitHub
  - generic:
      secret: Euf3bjjw
    type: Generic
  - imageChange:
    type: ImageChange
  - type: ConfigChange
status:
=Elements=
==spec==
===strategy===
====sourceStrategy====
=====env=====
Represents the environment that will be injected into the build container.
=====scripts=====
Represents the location to download the [[OpenShift_Concepts#S2I_Scripts|S2I scripts]] from. If specified in the build configuration, the scripts downloaded from that location take precedence over those embedded with the source code and those bundled with the [[OpenShift_Concepts#Builder_Image|builder image]]. This path will have "run", "assemble", and "save-artifacts" appended to it. If any or all scripts are found they will be used in place of the same named script(s) provided in the image or in the source code. The value is optional, in which case the scripts must exist in one of the previously mentioned location.
The location can be expressed in one of the following formats:
* image:///<''path-to-script-directory''> - the absolute path inside the image.
* file:///<''path-to-script-directory''> - relative or absolute path to a directory on the host where the scripts are located.
* http(s)://<''path-to-script-directory''> - URL to a directory where the scripts are located.
=Configuration=
==Turn Off SSL Certificate Verification for Git==
Add [[Git_Environment_Variables#GIT_SSL_NO_VERIFY|GIT_SSL_NO_VERIFY=true]] to the environment that will be injected into the build pod. This is valid for both source builds and pipeline builds:
apiVersion: v1
kind: BuildConfig
spec:
  ...
  strategy:
      sourceStrategy:
        env:
          - name: '''GIT_SSL_NO_VERIFY'''
            value: '''"true"'''
apiVersion: v1
kind: BuildConfig
spec:
  ...
  strategy:
      jenkinsPipelineStrategy:
        env:
          - name: '''GIT_SSL_NO_VERIFY'''
            value: '''"true"'''
==Enable a Generic Webhook Trigger==
A default build configuration already has a webhook trigger enabled, it is enabled by default when the configuration is created:
apiVersion: v1
kind: BuildConfig
spec:
  '''triggers''':
  - '''type''': '''Generic'''
    '''generic''':
      '''secret: <font color=brown>Euf3bjjw</font>
OpenShift will listen for invocations at the following URL: https&#58;//openshift.default.svc.cluster.local/oapi/v1/namespaces/<''project-name''>/buildconfigs/<''build-configuration-name''>/webhooks/<''generic-secret-value''>/generic

Latest revision as of 22:57, 8 December 2017

External

Internal

Source Strategy Example

apiVersion: v1
kind: BuildConfig
metadata:
  labels:
    app: eap70-basic-s2i
    application: session-servlet
    template: eap70-basic-s2i
    xpaas: 1.4.0
  name: session-servlet

spec: 

  strategy:

    type: Source

    sourceStrategy:

      env:
          - name: MAVEN_MIRROR_URL
            value: "..."
          - name: ARTIFACT_DIR
            value: "..."

      from:

          kind: ImageStreamTag
          name: jboss-eap70-openshift:1.5
          namespace: openshift

      scripts: "http://novaordis.io/openshift/scripts_directory"

      forcePull: true
 
  source:
    contextDir: /
    git:
      ref: master
      uri: https://github.com/NovaOrdis/novaordis-session-servlet.git
    type: Git

  output:
    to:
      kind: ImageStreamTag
      name: session-servlet:latest

  failedBuildsHistoryLimit: 5

  nodeSelector: null

  postCommit: {}

  resources: {}

  runPolicy: Serial

  successfulBuildsHistoryLimit: 5
  triggers:
  - github:
      secret: v2h6dtKw7Gw3
    type: GitHub
  - generic:
      secret: Euf3bjjw
    type: Generic
  - imageChange:
    type: ImageChange
  - type: ConfigChange
status:

Elements

spec

strategy

sourceStrategy

env

Represents the environment that will be injected into the build container.

scripts

Represents the location to download the S2I scripts from. If specified in the build configuration, the scripts downloaded from that location take precedence over those embedded with the source code and those bundled with the builder image. This path will have "run", "assemble", and "save-artifacts" appended to it. If any or all scripts are found they will be used in place of the same named script(s) provided in the image or in the source code. The value is optional, in which case the scripts must exist in one of the previously mentioned location.

The location can be expressed in one of the following formats:

  • image:///<path-to-script-directory> - the absolute path inside the image.
  • file:///<path-to-script-directory> - relative or absolute path to a directory on the host where the scripts are located.
  • http(s)://<path-to-script-directory> - URL to a directory where the scripts are located.

Configuration

Turn Off SSL Certificate Verification for Git

Add GIT_SSL_NO_VERIFY=true to the environment that will be injected into the build pod. This is valid for both source builds and pipeline builds:

apiVersion: v1
kind: BuildConfig
spec: 
  ...
  strategy:
     sourceStrategy:
       env:
          - name: GIT_SSL_NO_VERIFY
            value: "true"
apiVersion: v1
kind: BuildConfig
spec: 
  ...
  strategy:
     jenkinsPipelineStrategy:
       env:
          - name: GIT_SSL_NO_VERIFY
            value: "true"

Enable a Generic Webhook Trigger

A default build configuration already has a webhook trigger enabled, it is enabled by default when the configuration is created:

apiVersion: v1
kind: BuildConfig
spec:
  triggers:
  - type: Generic
    generic:
      secret: Euf3bjjw

OpenShift will listen for invocations at the following URL: https://openshift.default.svc.cluster.local/oapi/v1/namespaces/<project-name>/buildconfigs/<build-configuration-name>/webhooks/<generic-secret-value>/generic