-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major
-
Component/s: config-file-provider-plugin
-
None
I am having an issue pulling in inline environment variables in a Pipeline script. I have a Freestyle Project I want to convert to pipeline.
I am wanting to create a settings.php file for Drupal or Wordpress.
Test file
${ENV, var="X_DB_USER"}
${ENV, var="X_SITENAME"}
${ENV, var="DOMAIN_NAME"}
Pipeline:
pipeline {
environment {
dbName = "test-${env.BUILD_NUMBER}"
X_SITENAME = "${dbName}"
X_DB_USER = "mp"
DOMAIN_NAME = "https://www.example.com"
}
agent {
node {
label "ww7"
}
}
stages {
stage("init") {
steps {
configFileProvider(
[
configFile(
fileId: 'drupal7-test',
replaceTokens: true,
targetLocation: "/var/www/${dbName}/www/local.settings.php")
]) {
// some block
}
}
}
}
}
File output
<empty>
If I add a global environment variable it will write to the file, but I am unable to overwrite the values.
X_DB_USER global placeholder X_SITENAME global placeholder DOMAIN_NAME global placeholder
Using the web interface to add a file using job parameters I am able to use a file like:
<?php $$databases = array ( 'default' => array ( 'default' => array ( 'database' => '${DATABASE_NAME}', 'username' => '${DATABASE_USER}', 'password' => '${DATABASE_USER}', 'host' => 'localhost', 'port' => '', 'driver' => 'mysql', 'prefix' => '', // 'pdo' => array(ATTR_TIMEOUT => 2.0, MYSQL_ATTR_COMPRESS => 1, MYSQL_ATTR_USE_BUFFERED_QUERY => 1), ), ), );
How can I use dynamic variables pulled from a Jenkinsfile?
- is duplicated by
-
JENKINS-44022 Environment variable not replaced in config file
-
- Closed
-