我正试图在Openshift Online上运行一个简单的Pipeline。这是我的步骤:
oc new-project ess
bc.yaml
的内容:
kind: "BuildConfig"
apiVersion: "v1"
metadata:
name: "yngwuoso-pipeline"
spec:
source:
git:
uri: "https://github.com/yngwuoso/spring-boot-rest-example.git"
strategy:
type: JenkinsPipeline
oc create -f bc.yaml
结果是:
Error from server (Forbidden): error when creating "bc.yaml": buildconfigs.build.openshift.io "yngwuoso-pipeline" is forbidden: unrecognized build strategy: build.BuildStrategy{DockerStrategy:(*build.DockerBuildStrategy)(nil), SourceStrategy:(*build.SourceBuildStrategy)(nil), CustomStrategy:(*build.CustomBuildStrategy)(nil), JenkinsPipelineStrategy:(*build.JenkinsPipelineBuildStrategy)(nil)}
谁能告诉我缺少什么?
如果你想基于pipeline
源代码运行git
build,首先为git repo创建buildConfig
source
的Strategy
,然后创建buildConfig
的pipeline
来控制所有build
进程。
例如,它是您理解的示例指南,它可能不适用于您的环境,但您可以为您的环境自定义以下配置。
buildConfig
的源策略(github
)如下,
apiVersion: v1
kind: BuildConfig
metadata:
labels:
app: yngwuoso-pipeline
name: yngwuoso-git-build
spec:
failedBuildsHistoryLimit: 5
output:
to:
kind: ImageStreamTag
name: yngwuoso-pipeline-image:latest
runPolicy: Serial
source:
git:
uri: https://github.com/yngwuoso/spring-boot-rest-example.git
type: Git
strategy:
sourceStrategy:
from:
kind: ImageStreamTag
name: redhat-openjdk18-openshift:1.3
namespace: openshift
type: Source
triggers:
- type: ConfigChange
- type: ImageChange
buildConfig
的pipeline
基于git repo触发buildConfig
以上。
apiVersion: v1
kind: BuildConfig
metadata:
labels:
name: yngwuoso-pipeline
name: yngwuoso-pipeline
spec:
runPolicy: Serial
strategy:
jenkinsPipelineStrategy:
jenkinsfile: |-
node(''){
stage 'Build by S2I'
openshiftBuild(namespace: 'PROJECT NAME', bldCfg: 'yngwuoso-git-build', showBuildLogs: 'true')
}
type: JenkinsPipeline
triggers:
- github:
secret: gitsecret
type: GitHub
- generic:
secret: genericsecret
type: Generic
您应该在GitHub Webhook
secret
中使用身份验证pipeline
配置buildConfg
,有关详细信息,请参阅GitHub Webhooks
。