在gitlab yaml中将10个以上的参数传递给shell脚本

时间:2018-10-10 13:08:33

标签: shell gitlab-ci-runner

我编写了以下YAML文件,以使用gitlab CI运行器:

variables:



GCP_PROJECT_ID: project
  CLUSTER_NAME: cluster
  DAGS_BUCKET : gs://bucket/dags
  PLUGINS_BUCKET : gs://bucket/plugins
  JARS_BUCKET: gs://bucket/jars
  COMPOSER_ENVIRONMENT: test
  ENVIRONMENT_LOCATION: us
  FIRST_DAG: first-dag
  SECOND_DAG: second-dag
  CHECKPOINT_FOLDER: gs://bucket/checkpoints
  BIGQUERY_DATASET: test_dataset




.tags_fdedtt: 
  tags:
    - gcpd
    - ded

stages:
    - deploy

deploy:
  stage: deploy
  image: google/cloud-sdk
  script:
    - echo $KEY_FILE_CONTENT > key.json
    - gcloud auth activate-service-account --key-file=key.json
    - gcloud  beta composer environments storage dags delete   --environment  ${COMPOSER_ENVIRONMENT}  --project ${GCP_PROJECT_ID}   --location  ${ENVIRONMENT_LOCATION}
    - chmod +x variables.sh
    - ./variables.sh  ${CLUSTER_NAME}  ${GCP_PROJECT_ID}   ${JARS_BUCKET}   ${FIRST_DAG}  ${COMPOSER_ENVIRONMENT}   ${ENVIRONMENT_LOCATION}  ${CHECKPOINT_FOLDER}   ${BIGQUERY_DATASET}
    - gsutil cp   plugins/*.py   ${PLUGINS_BUCKET}
    - gsutil cp   dags/*.py   ${DAGS_BUCKET}
    - sleep 2m
    - gcloud beta composer environments run ${COMPOSER_ENVIRONMENT}  --project ${GCP_PROJECT_ID}  --location ${ENVIRONMENT_LOCATION}   trigger_dag   -- ${FIRST_DAG}

您可能会注意到,variables.sh文件在input中有很多参数,我想找到一种更复杂的方法来将变量传递给variables.sh脚本

否则,。/ variables.sh行将非常大。 您知道如何以一种时尚的方式解决此问题吗?

0 个答案:

没有答案