openshift pipeline

用oc命令创建pipeline 模板如下:

{
    "apiVersion": "v1",
    "kind": "BuildConfig",
    "metadata": {
        "creationTimestamp": "2017-11-23T07:05:54Z",
        "labels": {
            "name": "peony-pipeline",
            "run": "cs-cd"
        },
        "name": "peony-pipeline",
        "namespace": "ecloudcaas-dev",
        "resourceVersion": "41403844",
        "selfLink": "/oapi/v1/namespaces/ecloudcaas-dev/buildconfigs/pipeline-config",
        "uid": "bf172406-d01c-11e7-b8ec-0050568cc9dc"
    },
    "spec": {
        "nodeSelector": null,
        "output": {},
        "postCommit": {},
        "resources": {},
        "runPolicy": "Serial",
        "source": {
            "git": {
                "ref": "www.github.com",
                "uri": "master"
            },
            "type": "Git"
        },
        "strategy": {
            "jenkinsPipelineStrategy": {
                "jenkinsfile": "node() {\nstage '--build-cs-images--'\nopenshiftBuild(namespace: '${NAMESPACE}', buildConfig: 'cs-bc', showBuildLogs: 'true', waitTime: '7200000')\nstage '--redeploy-mysql-master--'\nsh \"oc scale dc/mysql-master --replicas=0 -n ${NAMESPACE}\"\nsleep(10)\nsh \"oc delete pvc  mysql-master-storage -n ${NAMESPACE}\"\nsleep(5)\nopenshiftCreateResource jsonyaml: '''{\n  \"apiVersion\": \"v1\",\n  \"kind\": \"PersistentVolumeClaim\",\n  \"metadata\": {\n    \"name\": \"mysql-master-storage\",\n    \"labels\": {\n      \"run\": \"cs-cd\"\n    },\n    \"annotations\": {\n      \"volume.beta.kubernetes.io/storage-class\": \"${STORAGECLASS_NAME}\"\n    }\n  },\n  \"spec\": {\n    \"accessModes\": [\n      \"ReadWriteOnce\"\n    ],\n    \"resources\": {\n      \"requests\": {\n        \"storage\": \"${MYSQL_STORAGE_SIZE}\"\n      }\n    }\n  }\n}''', namespace: '${NAMESPACE}', verbose: 'false'\nsleep(5)\nsh \"oc scale dc/mysql-master --replicas=1 -n ${NAMESPACE}\"\nsleep(10)\nstage '--redeploy-mysql-slave--'\nsh \"oc scale dc/mysql-slave --replicas=0 -n ${NAMESPACE}\"\nsleep(10)\nsh \"oc delete pvc  mysql-slave-storage -n ${NAMESPACE}\"\nsleep(5)\nopenshiftCreateResource jsonyaml: '''{\n  \"apiVersion\": \"v1\",\n  \"kind\": \"PersistentVolumeClaim\",\n  \"metadata\": {\n    \"name\": \"mysql-slave-storage\",\n    \"labels\": {\n      \"run\": \"cs-cd\"\n    },\n    \"annotations\": {\n      \"volume.beta.kubernetes.io/storage-class\": \"${STORAGECLASS_NAME}\"\n    }\n  },\n  \"spec\": {\n    \"accessModes\": [\n      \"ReadWriteOnce\"\n    ],\n    \"resources\": {\n      \"requests\": {\n        \"storage\": \"${MYSQL_STORAGE_SIZE}\"\n      }\n    }\n  }\n}''', namespace: '${NAMESPACE}', verbose: 'false'\nsleep(5)\nsh \"oc scale dc/mysql-slave --replicas=1 -n ${NAMESPACE}\"\nsleep(10)\nstage '--deploy-cs-master--'\nopenshiftDeploy(namespace: '${NAMESPACE}', deploymentConfig: 'cscd-master', waitTime: '7200000')\nsleep(120)\nstage '--deploy-cs-slave--'\nopenshiftDeploy(namespace: '${NAMESPACE}', deploymentConfig: 'cscd-slave', waitTime: '7200000')\n}"
            },
            "type": "JenkinsPipeline"
        },
        "triggers": [
            {
                "github": {
                    "secret": "secret101"
                },
                "type": "GitHub"
            },
            {
                "generic": {
                    "secret": "secret101"
                },
                "type": "Generic"
            }
        ]
    },
    "status": {
        "lastVersion": 0

创建完成后,oc命令查询即可看到刚创建的bc,如下:

vito@caas:~/docker$ oc get bc
NAME              TYPE              FROM                 LATEST
iris              Source            Git@master           3
iris-pipeline     JenkinsPipeline   Git@www.github.com   1

此时,打开openshift—–builds——pipelines,即可看到刚才创建的pipeline,如下图:
这里写图片描述

点击pipeline名字iris-pipeline,进入配置界面,删掉模板中的步骤信息,配置自己的pipeline步骤,如下:openshift pipeline_第1张图片

编辑完成后,点击start pipeline 开始运行pipeline,运行结束后如下图:
openshift pipeline_第2张图片

oc tag ecloudcaas-dev/pontus:latest ecloudcaas-sit/pontus:latest
oc tag ecloudcaas-dev/peony:latest ecloudcaas-sit/peony:latest

你可能感兴趣的:(openshift)