OpenShift Build Configuration Definition: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(45 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]]


=servlet-example Build Configuration=
=Source Strategy Example=


<syntaxhighlight lang='yaml'>
apiVersion: v1
apiVersion: v1
kind: BuildConfig
kind: BuildConfig
metadata:
metadata:
  labels:
  labels:
    app: eap70-basic-s2i
    app: eap70-basic-s2i
    application: session-servlet
    application: session-servlet
    template: eap70-basic-s2i
    template: eap70-basic-s2i
    xpaas: 1.4.0
    xpaas: 1.4.0
  name: session-servlet
  name: session-servlet
spec:
'''[[OpenShift_REST_Resource_Definition_Schema#spec|spec]]''':
  failedBuildsHistoryLimit: 5
  nodeSelector: null
  '''strategy''':
  output:
    to:
    '''type''': '''Source'''
      kind: ImageStreamTag
      name: session-servlet:latest
    '''[[OpenShift_Build_Configuration_Definition#sourceStrategy|sourceStrategy]]''':
  postCommit: {}
  resources: {}
      '''[[OpenShift_Build_Configuration_Definition#env|env]]''':
  runPolicy: Serial
          - name: MAVEN_MIRROR_URL
   source:
            value: "..."
    contextDir: /
          - name: ARTIFACT_DIR
    git:
            value: "..."
      ref: master
      uri: https://github.com/NovaOrdis/novaordis-session-servlet.git
      from:
    type: Git
  strategy:
          kind: ImageStreamTag
    sourceStrategy:
          name: jboss-eap70-openshift:1.5
      env:
          namespace: openshift
      - name: MAVEN_MIRROR_URL
      - name: ARTIFACT_DIR
      '''[[#scripts|scripts]]''': <font color=SandyBrown>"http&#58;//novaordis.io/openshift/scripts_directory"</font>
      forcePull: true
      from:
      forcePull: true
        kind: ImageStreamTag
    
        name: jboss-eap70-openshift:1.5
  '''source''':
        namespace: openshift
    contextDir: /
    type: Source
    git:
  successfulBuildsHistoryLimit: 5
      ref: master
  triggers:
      uri: https&#58;//github.com/NovaOrdis/novaordis-session-servlet.git
  - github:
    type: Git
      secret: v2h6dtKw7Gw3
    type: GitHub
  <span id='output'></span>'''output''':
  - generic:
    to:
      secret: Euf3bjjw
      kind: ImageStreamTag
    type: Generic
      name: session-servlet:latest
  - imageChange:
    type: ImageChange
  failedBuildsHistoryLimit: 5
  - type: ConfigChange
status:
  nodeSelector: null
</syntaxhighlight>
  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