fabric8io / osio-pipeline

DSL and utility functions in groovy for running Jenkins OSIO Pipeline
13 stars 17 forks source link

oc new-app integration #108

Closed chmouel closed 5 years ago

chmouel commented 5 years ago

a poc that try to leverage oc new-app feature supported on osio-pipeline :

  1. Take an exisiting repo without .openshiftio/application.yaml
  2. Run :
mkdir -p .openshiftio/
oc new-app . -o yaml --strategy=source > .openshiftio/application.yaml
  1. Run OSIO-Pipeline and see if it builds and deploy correctly on OSO/OSD

  2. Identify what things are missing, there is arguments to play with on oc new-app to get the template exactly the way we want,

piyush-garg commented 5 years ago

I tried this

I used command oc new-app . -o yaml --strategy=source --dry-run=true > .openshiftio/application.yaml which basically generated the list of all objects.

Then I used the loadResources API, and tried to build

Build Config generated is

apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
  annotations:
    openshift.io/generated-by: OpenShiftNewApp
  creationTimestamp: null
  labels:
    app: test-app-new-app
  name: test-app-new-app
spec:
  nodeSelector: null
  output:
    to:
      kind: ImageStreamTag
      name: test-app-new-app:latest
  postCommit: {}
  resources: {}
  source:
    git:
      uri: https://github.com/piyush-garg/test-app-new-app.git
    type: Git
  strategy:
    sourceStrategy:
      from:
        kind: ImageStreamTag
        name: nodejs:10
        namespace: openshift
    type: Source
  triggers:
  - github:
      secret: gDsCob43m2sIpeSYQvGZ
    type: GitHub
  - generic:
      secret: n4s1FZJefo85PxHeWeTY
    type: Generic
  - type: ConfigChange
  - imageChange: {}
    type: ImageChange
status:
  lastVersion: 0

After applying, its throwing error like this

oc apply -f .openshiftio/.tmp-pgarg-preview-22-buildconfig.yaml -n pgarg-preview
Warning: oc apply should be used on resource created by either oc create --save-config or oc apply
The BuildConfig "test-app-new-app" is invalid: spec.strategy: Invalid value: build.BuildStrategy{DockerStrategy:(*build.DockerBuildStrategy)(nil), SourceStrategy:(*build.SourceBuildStrategy)(0xc5a54c13f0), CustomStrategy:(*build.CustomBuildStrategy)(nil), JenkinsPipelineStrategy:(*build.JenkinsPipelineBuildStrategy)(0xc770a63b40)}: must provide a value for exactly one of sourceStrategy, customStrategy, dockerStrategy, or jenkinsPipelineStrategy

I tried upgrading the OC binary to v3.11 also, still does not work. But locally its working fine.

chmouel commented 5 years ago

When you say locally, you mean on a minishfit?

chmouel commented 5 years ago

Your repo seems to okay to me on OSO account :

image

osio-pipeline parsing need to be fixed to handle this properly,

piyush-garg commented 5 years ago

Sorry for the confusion, I mean the same, OSO account but without Jenkins, directly oc create from the command line.

piyush-garg commented 5 years ago

Even I tried to cat after parsing, the file looks good to me, but still not able to apply from our library

chmouel commented 5 years ago

Can you cat the output generated in this issue?

piyush-garg commented 5 years ago
[workspace] Running shell script
+ cat .openshiftio/.tmp-pgarg-preview-22-buildconfig.yaml
apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
  annotations:
    openshift.io/generated-by: OpenShiftNewApp
  creationTimestamp: null
  labels:
    app: test-app-new-app
  name: test-app-new-app
spec:
  nodeSelector: null
  output:
    to:
      kind: ImageStreamTag
      name: test-app-new-app:latest
  postCommit: {}
  resources: {}
  source:
    git:
      uri: https://github.com/piyush-garg/test-app-new-app.git
    type: Git
  strategy:
    sourceStrategy:
      from:
        kind: ImageStreamTag
        name: nodejs:10
        namespace: openshift
    type: Source
  triggers:
  - github:
      secret: gDsCob43m2sIpeSYQvGZ
    type: GitHub
  - generic:
      secret: n4s1FZJefo85PxHeWeTY
    type: Generic
  - type: ConfigChange
  - imageChange: {}
    type: ImageChange
status:
  lastVersion: 0
+ oc apply -f .openshiftio/.tmp-pgarg-preview-22-buildconfig.yaml -n pgarg-preview
Warning: oc apply should be used on resource created by either oc create --save-config or oc apply
The BuildConfig "test-app-new-app" is invalid: spec.strategy: Invalid value: build.BuildStrategy{DockerStrategy:(*build.DockerBuildStrategy)(nil), SourceStrategy:(*build.SourceBuildStrategy)(0xc5a54c13f0), CustomStrategy:(*build.CustomBuildStrategy)(nil), JenkinsPipelineStrategy:(*build.JenkinsPipelineBuildStrategy)(0xc770a63b40)}: must provide a value for exactly one of sourceStrategy, customStrategy, dockerStrategy, or jenkinsPipelineStrategy
[Pipeline] error
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline