1、登录opeshift:oc login -u admin https://127.0.0.1:8443 2、创建名称为ci的项目:oc new-project ci 3、下载导入jenkins模板:oc create -f jenkins-ephemeral.yaml 4、创建jenkins
$ oc new-app --template=jenkins-ephemeral -e JENKINS_PASSWORD=welcome1 --> Deploying template "openshift/jenkins-ephemeral" to project openshift Jenkins (Ephemeral) --------- Jenkins service, without persistent storage. WARNING: Any data stored will be lost upon pod destruction. Only use this template for testing. A Jenkins service has been created in your project. Log into Jenkins with your OpenShift account. The tutorial at https://github.com/openshift/origin/blob/master/examples/jenkins/README.md contains more information about using this template. * With parameters: * Jenkins Service Name=jenkins * Jenkins JNLP Service Name=jenkins-jnlp * Enable OAuth in Jenkins=true * Jenkins JVM Architecture=i386 * Memory Limit=512Mi * Jenkins ImageStream Namespace=openshift * Jenkins ImageStreamTag=jenkins:latest --> Creating resources ... route "jenkins" created deploymentconfig "jenkins" created serviceaccount "jenkins" created rolebinding "jenkins_edit" created service "jenkins-jnlp" created service "jenkins" created --> Success Run 'oc status' to view your app. #查看结果 $ oc status In project openshift on server https://127.0.0.1:8443 https://jenkins-openshift.127.0.0.1.nip.io (redirects) (svc/jenkins) dc/jenkins deploys istag/jenkins:latest deployment #1 running for about a minute - 0/1 pods svc/jenkins-jnlp - 172.30.244.77:50000 dc/jenkins deploys istag/jenkins:latest deployment #1 running for about a minute - 0/1 pods View details with 'oc describe <resource>/<name>' or list everything with 'oc get all'. #创建成功 $ oc get pods NAME READY STATUS RESTARTS AGE jenkins-1-n97bf 1/1 Running 0 2m5、查看route oc get route
oc get route NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD jenkins jenkins-openshift.127.0.0.1.nip.io jenkins <all> edge/Redirect None6、设置hosts 127.0.0.1 jenkins-ci.127.0.0.1.nip.io 注意:上面的ip地址是部署route的主机的ip地址。
7、访问jenkins https://jenkins-ci.127.0.0.1.nip.io/
8、导出模板命令
1、首先授权jenkins到当前项目 oc policy add-role-ro-user edit system:serviceaddcount:ci:default -n mybank 2、添加构建步骤 3、测试构建 4、构建完成
开发环境–测试环境–生成环境 1、开发环境
2、测试环境
3、生成环境