我正在尝试设置我的项目以部署go应用程序。当我尝试将sed与从工作传入的参数一起使用时-它工作正常当我尝试将sed与从作为上下文变量引用的作业传入的参数一起使用时,它不起作用。看到这个例子
version: 2.1
jobs:
deploy-application:
docker:
- image: circleci/golang:1.13
environment:
GO111MODULE: "on"
working_directory: /go/src/github.com/me/go-circle-elasticbeanstalk
parameters:
ebAppName:
description: "The name to set the elastic beanstalk application to"
default: "null"
type: string
elkHost:
description: "The host to send logs to for elastic search"
default: "null"
type: string
steps:
- run: sudo apt-get -y -qq update
- run: sudo apt-get install python-pip python-dev build-essential
- run: sudo pip install awsebcli --upgrade
- checkout
- run: sed -i 's/MY-FLIGHTS-APP-PLACEHOLDER/<< parameters.ebAppName >>/g' .elasticbeanstalk/config.yml
- run: sed -i 's/FILEBEAT-HOST-PLACEHOLDER/<< parameters.elkHost >>/g' .ebextensions/01_filebeat.config
- run: ls -latr
- run: go env
- run: export GO111MODULE=on
- run: go env
- run: go build ./...
- run: go build -o application server.go
- run: ls -latr
- run: ls -latr .elasticbeanstalk
- run: zip my-server.zip application -r .ebextensions damien.test
- run: ls -latr
- run: eb deploy
workflows:
deploy-go-server:
jobs:
- deploy-application:
name: deploy-dev
ebAppName: my-flights-dev
elkHost: $ELK_HOST
filters:
branches:
only: develop
context: my-dev
- deploy-application:
name: deploy-stage
ebAppName: my-flights
elkHost: $ELK_HOST
filters:
branches:
only: stage
context: my-stage
ebAppName的值始终正确设置但是,elkHost的值始终显示为$ ELK_HOST,并且永远不会读取组织上下文值
对我在这里可以解决的任何帮助?我在另一个项目上使用了这种方法,效果很好我注意到,如果我输出到文件,但elkHost的值很好,但不适用于sed
感谢您的任何帮助
欢呼达米安
如果要将参数作为变量名发送,请使用env_var_name类型;如果参数类型为字符串,则在运行工作流时解析参数,即${EB_APP_NAME}
。
version: 2.1
jobs:
build:
parameters:
elkHost:
type: env_var_name
default: ELK_DEFAULT_HOST # Note: replace with env var (without $) or remove it if the param is mandatory.
ebAppName:
type: string
default: 'my-app-name'
docker:
- image: ubuntu:latest
steps:
- run: |
echo "--elkHost ${<< parameters.elkHost >>} \\
--ebAppName << parameters.ebAppName >>"
workflows:
workflow:
jobs:
- build:
elkHost: ELK_HOST
ebAppName: ${EB_APP_NAME}