2017-04-05 63 views
0

我試圖處理kubernetes(openshift起源)autodeploy。下面是ci-config。gitlab自動部署到kubernetes/openshift:錯誤:不匹配「:master」

據我瞭解CI應該得到的代碼,檢查dockerfile,如果它不存在(它不是) - 建立herokuish容器並推送到kubernetes。但是,我得到一個錯誤:

$ command deploy 
Generating kubeconfig... 
Cluster "gitlab-deploy" set. 
User "gitlab-deploy" set. 
Context "gitlab-deploy" set. 
Switched to context "gitlab-deploy". 

Running on OpenShift. 
Deleting old application... 
No resources found 

Creating application... 
error: no match for ":master" 

CI:

# Explanation on the scripts: 
# https://gitlab.com/gitlab-examples/openshift-deploy/blob/master/README.md 
image: registry.gitlab.com/gitlab-examples/openshift-deploy 
services: 
    - mysql:5.7 
variables: 
    # Application deployment domain 
    KUBE_DOMAIN: kub.kub.myopenshift.com 
    MYSQL_DATABASE: database 
    MYSQL_ROOT_PASSWORD: secret 
cache: 
    key: "$CI_BUILD_REF_NAME" 
    untracked: true 
    paths: 
    - vendor/ 
    - .env 
stages: 
    #- build 
    #- test 
    - review 
    - staging 
    - production 
    - cleanup 
#build: 
# stage: build 
# script: 
# - composer install --ignore-platform-reqs 
# - cp .env.testing .env 
# only: 
# - branches 
#test: 
# stage: test 
# script: 
# - php vendor/bin/phpunit --colors 
# only: 
# - branches 
production: 
    stage: production 
    variables: 
    CI_ENVIRONMENT_URL: http://$CI_PROJECT_NAME.$KUBE_DOMAIN 
    script: 
    - command deploy 
    environment: 
    name: production 
    url: http://$CI_PROJECT_NAME.$KUBE_DOMAIN 
    when: manual 
    only: 
    - master 
staging: 
    stage: staging 
    variables: 
    CI_ENVIRONMENT_URL: http://$CI_PROJECT_NAME-staging.$KUBE_DOMAIN 
    script: 
    - command deploy 
    environment: 
    name: staging 
    url: http://$CI_PROJECT_NAME-staging.$KUBE_DOMAIN 
    only: 
    - master 
review: 
    stage: review 
    variables: 
    CI_ENVIRONMENT_URL: http://$CI_PROJECT_NAME-$CI_ENVIRONMENT_SLUG.$KUBE_DOMAIN 
    script: 
    - command deploy 
    environment: 
    name: review/$CI_COMMIT_REF_NAME 
    url: http://$CI_PROJECT_NAME-$CI_ENVIRONMENT_SLUG.$KUBE_DOMAIN 
    on_stop: stop_review 
    only: 
    - branches 
    except: 
    - master 
stop_review: 
    stage: cleanup 
    variables: 
    GIT_STRATEGY: none 
    script: 
    - command destroy 
    environment: 
    name: review/$CI_COMMIT_REF_NAME 
    action: stop 
    when: manual 
    only: 
    - branches 
    except: 
    - master 

我在做什麼錯?是否應該在openshift中額外設置一些內容?

回答

0

沒有在這裏做所有的步驟,我只是嘗試從step where命令它失敗了,你在deploy script

oc new-app "--name=${CI_ENVIRONMENT_SLUG}" "$CI_REGISTRY_IMAGE:$CI_REGISTRY_TAG" 

我在OpenShift環境跑類似的命令,我猜你的環境變量CI_REGISTRY_IMAGE沒有設置,所以腳本正在它是空值。

我跑

$ oc new-app :master 
error: no match for ":master" 

The 'oc new-app' command will match arguments to the following types: 

    1. Images tagged into image streams in the current project or the 'openshift' project 
    - if you don't specify a tag, we'll add ':latest' 
    2. Images in the Docker Hub, on remote registries, or on the local Docker engine 
    3. Templates in the current project or the 'openshift' project 
    4. Git repository URLs or local paths that point to Git repositories 

--allow-missing-images can be used to point to an image that does not exist yet. 

See 'oc new-app -h' for examples. 

結帳這類似於你得到了一個錯誤:

error: no match for ":master" 

因此,嘗試導出一個環境變量。