OpenShift Build Configuration Definition: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(35 intermediate revisions by the same user not shown)
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]]


=Example=
=Source Strategy Example=


  apiVersion: v1
  apiVersion: v1
Line 22: Line 23:
  '''[[OpenShift_REST_Resource_Definition_Schema#spec|spec]]''':  
  '''[[OpenShift_REST_Resource_Definition_Schema#spec|spec]]''':  
   
   
   failedBuildsHistoryLimit: 5
   '''strategy''':
    '''type''': '''Source'''
   
   
  nodeSelector: null
    '''[[OpenShift_Build_Configuration_Definition#sourceStrategy|sourceStrategy]]''':
   
   
  output:
      '''[[OpenShift_Build_Configuration_Definition#env|env]]''':
    to:
          - name: MAVEN_MIRROR_URL
      kind: ImageStreamTag
            value: "..."
      name: session-servlet:latest
          - name: ARTIFACT_DIR
            value: "..."
   
   
  postCommit: {}
      from:
   
   
  resources: {}
          kind: ImageStreamTag
          name: jboss-eap70-openshift:1.5
          namespace: openshift
   
   
  runPolicy: Serial
      '''[[#scripts|scripts]]''': <font color=SandyBrown>"http&#58;//novaordis.io/openshift/scripts_directory"</font>
   
   
   source:
      forcePull: true
 
   '''source''':
     contextDir: /
     contextDir: /
     git:
     git:
Line 44: Line 52:
     type: Git
     type: Git
   
   
   strategy:
   <span id='output'></span>'''output''':
    to:
      kind: ImageStreamTag
      name: session-servlet:latest
  failedBuildsHistoryLimit: 5
  nodeSelector: null
  postCommit: {}
  resources: {}
   
   
    '''[[OpenShift_Build_Configuration_Definition#sourceStrategy|sourceStrategy]]''':
  runPolicy: Serial
      env:
      - name: MAVEN_MIRROR_URL
      - name: ARTIFACT_DIR
      forcePull: true
      from:
        kind: ImageStreamTag
        name: jboss-eap70-openshift:1.5
        namespace: openshift
    type: Source
   
   
   successfulBuildsHistoryLimit: 5
   successfulBuildsHistoryLimit: 5
Line 77: Line 87:


====sourceStrategy====
====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=
=Configuration=


==Turn Off SSL Certificate Verification for Git==
==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