【问题标题】:Jenkins - Symfony with environment variablesJenkins - 带有环境变量的 Symfony
【发布时间】:2019-01-17 14:01:52
【问题描述】:

我一直在努力使用 Jenkins 和 symfony 3.4 构建自动化构建。

如何在 Jenkins 中正确设置 symfony 可以找到的环境变量。

这是我的管道。

node {
def app
stage('composer install') {
    sh 'export $(cat env/env_vars | xargs)'
    sh 'composer install --optimize-autoloader'
}

stage('yarn install') {
    sh 'yarn install'
}

stage ('build assets') {
    sh 'yarn encore production'
}

stage('Clone repository') {
    // clone
}

stage('Build image') {
    // build here
}

stage('Push image') {
  // push here
}
}

然后在我运行我的构建之后。

我总是收到这条消息

....
Creating the "app/config/parameters.yml" file 
Some parameters are missing. Please provide them.
database_host ('%env(DATABASE_HOST)%'): Script Incenteev\ParameterHandler      
\ScriptHandler::buildParameters handling the symfony-scripts event terminated with an exception


[Symfony\Component\Console\Exception\RuntimeException]  
Aborted
....

我已经使用了一些 jenkins 插件,例如 EnvInjector 和类似的东西。但是symfony还是找不到我的环境变量。

【问题讨论】:

    标签: symfony jenkins continuous-integration environment-variables


    【解决方案1】:

    你可以这样解决这个问题:

    stage('composer install') { sh 'export $(cat env/env_vars | xargs) && composer install --optimize-autoloader' }

    这将使环境变量在同一个 shell 会话中可用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多