【问题标题】:accessing environment variable in gocd pipeline for aws EMR add step为 aws EMR 添加步骤访问 gocd 管道中的环境变量
【发布时间】:2019-01-22 13:33:01
【问题描述】:

如何在 gocd 步骤中传递环境变量作为参数。在这里,当我通过 ${KAFKA_CODE} 时,它会给出错误。当我只通过 $KAFKA_CODE 时,命令在集群上提交为aws s3 cp $KAFKA_CODE /home/hadoop/。但我希望这是 aws s3 cp s3://code_path/spark-jobs.zip /home/hadoop/ 请让我知道如何解决这个问题,因为我是 gocd 新手

format_version: 3
pipelines:
  copy_code_cluster:
    group: MyGroup
    materials:
      terraform_git:
        git: git@gitlab.xxxx.com/spark-jobs.git
        branch: develop

    environment_variables:
      KAFKA_CODE: "s3://code_path/spark-jobs.zip"

    stages:
    - provision:
        clean_workpace: true
        jobs:
          terraform:
            tasks:
              - exec:
                  command: /bin/sh
                  arguments:
                    - "-c"
                    - "aws emr add-steps --cluster-id 'j-xxxxxxx' --steps 'Name= \"copy zip  to cluster home directory\" , Jar=\"command-runner.jar\",Args=[ \"aws\" , \"s3\" , \"cp\", \"$KAFKA_CODE\" ,  \"/home/hadoop/\"]' "

【问题讨论】:

    标签: environment-variables amazon-emr go-cd


    【解决方案1】:

    这是通过使用参数而不是 environment_variables 解决的。 environment_variables 不能在任务内部访问。只能访问参数。

    format_version: 3
    pipelines:
      copy_code_cluster:
        group: MyGroup
        materials:
          terraform_git:
            git: git@gitlab.xxxx.com/spark-jobs.git
            branch: develop
    
        parameters:
          KAFKA_CODE: "s3://code_path/spark-jobs.zip"
    
        stages:
        - provision:
            clean_workpace: true
            jobs:
              terraform:
                tasks:
                  - exec:
                      command: /bin/sh
                      arguments:
                        - "-c"
                        - "aws emr add-steps --cluster-id 'j-xxxxxxx' --steps 'Name= \"copy zip  to cluster home directory\" , Jar=\"command-runner.jar\",Args=[ \"aws\" , \"s3\" , \"cp\", \"#{KAFKA_CODE}\" ,  \"/home/hadoop/\"]' "
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-30
      • 2021-12-10
      • 1970-01-01
      • 1970-01-01
      • 2022-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多