相关疑难解决方法(0)

如何在'script:'中使用YAML的多行命令?

我有一个使用的存储库,Travis CI.travis.yml那里我有这一行:

script:
- vim -Nu <(cat <<-EOF
  set nocompatible |
  filetype off
  EOF
  ) -c 'Script' > /dev/null
Run Code Online (Sandbox Code Playgroud)

遗憾的是,这不起作用,因为它被转换为单行并执行如下:

vim -Nu <(cat <<-EOF set no compatible | filetype off | EOF ) -c 'Script' > /dev/null
Run Code Online (Sandbox Code Playgroud)

这使得EOF标签不起作用,因为EOF需要在一行中.另一种方法是使用这样的常规引号:

script:
- vim -Nu <(cat 'set nocompatible |
  filetype off
  ) -c 'Script' > /dev/null
Run Code Online (Sandbox Code Playgroud)

哪个有效,并且很好,但我觉得必须有一种方法可以将换行符插入到.travis.yml.我现在有另一种选择,但将来我可能不会.你是怎么做到的?

bash continuous-integration yaml travis-ci

30
推荐指数
3
解决办法
1万
查看次数

在Cloudformation YAML中,在多行字符串中使用Ref(?使用Fn:Sub)

想象一下,你有一个aws资源,如

  Resources:
    IdentityPool:
      Type: "AWS::Cognito::IdentityPool"
      Properties:
        IdentityPoolName: ${self:custom.appName}_${self:provider.stage}_identity
        CognitoIdentityProviders:
          - ClientId:
              Ref: UserPoolClient
Run Code Online (Sandbox Code Playgroud)

"AWS :: Cognito :: IdentityPool"的Ref返回此资源的id.现在假设我想在多行字符串中引用该id.我试过了

Outputs:  
  AmplifyConfig:
    Description: key/values to be passed to Amplify.configure(config);
    Value: |
      {
        'aws_cognito_identity_pool_id': ${Ref: IdentityPool}, ##<------ Error
        'aws_sign_in_enabled': 'enable',
        'aws_user_pools_mfa_type': 'OFF',
      }
Run Code Online (Sandbox Code Playgroud)

我也尝试过使用Fn:Sub但没有运气.

   AmplifyConfig:
      Description: key/values to be passed to Amplify.configure(config);
      Value: 
        Fn::Sub 
          - |
            {
              'aws_cognito_identity_pool_id': '${Var1Name}',
              'aws_sign_in_enabled': 'enable',
            }
          - Var1Name:
              Ref: IdentityPool
Run Code Online (Sandbox Code Playgroud)

有什么办法吗?

string yaml ref multiline aws-cloudformation

8
推荐指数
2
解决办法
8283
查看次数