Ask A Question

View Question

Hello
I am looking a way to duplicate several database connections over multiple applications.
Is there any way to do it ?

Another question,

  • it is possible to define a database connection based on variable like this way :

Connection Name : $ConnectionName
Server : $DBServer
Connection String : Server=$ApplicationName$PipelineStageName.SQL.$DomaineName\$ApplicationName$PipelineStageName;Integrated Security=true;

Best Regards

Product: BuildMaster
Version: 6.1.5

Hi Philippe,

You should be able to use a System Variable (administration/variables) to store the connection string that you want to use over multiple applications.

Also,
Yes. you can define a connection string as per your example.

Does this help?

Thanks,
Jason

A lot :)

I ll make a try

Thanks a lot

I made a try of the SQL string based on variable and it is not working :(

Philippe,

You will need to use variable value renderers to accomplish this.

then value render text will be your string i.e. Server=$ApplicationName$PipelineStageName.SQL.$DomaineName\$ApplicationName$PipelineStageName;Integrated Security=true;

then you can reference that variable in your application by adding it as a release variable or build variable.

Jason

I am a silly sysadmin and not smart like a dev gu :-)

I can't make it works.

I define a variable value renderer:

Variable : $SQLString
Scope : AppsGroup
Value:$ApplicationName$PipelineStageName.SQL.$DomaineName\$ApplicationName$PipelineStageName;Integrated Security=true;

In the Application, I set a release variable $MySQLString to $SQLString

In the DatabaseConnection, I created a new DB connection and set the Connection DB string to $MySQLString.

I got this error msg:

Unhandled exception: System.ArgumentException: Le format de la chaîne d'initialisation n'est pas conforme à la spécification qui débute à l'index 0.
   à System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue)
   à System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey)
   à System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules)
   à System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
   à System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous)
   à System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)
   à System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key)
   à System.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
   à System.Data.SqlClient.SqlConnection..ctor(String connectionString, SqlCredential credential)
   à Inedo.BuildMasterExtensions.SqlServer.SqlServerDatabaseProvider.<GetConnectionAsync>d__15.MoveNext()
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
   à System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   à Inedo.BuildMasterExtensions.SqlServer.SqlServerDatabaseProvider.<ExecuteQueryAsync>d__14.MoveNext()
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
   à System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   à Inedo.BuildMaster.DatabaseConnections.ExecuteDatabaseScriptsJob.<ExecuteAsync>d__8.MoveNext()
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
   à System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   à Inedo.Agents.AgentCommand`1.<Inedo-Agents-IAgentCommandWithResponse-ExecuteAsync>d__5.MoveNext()
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
   à System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   à Inedo.Agents.AgentCommandDispatcher.<ExecuteCommandAsync>d__5.MoveNext()
``

Hi Philippe,

When you add the Release variable does it appear to have the correct connection string on the page? I'm going to try and replicate this error on my end but want to make sure the rendering is working first.

Thanks,
Jason

It resolves the value, but as there is a value which depend on the pipeline name, a part is missing.

Variable : $SQLString
Scope : AppsGroup
Value:$ApplicationName$PipelineStageName.SQL.$DomaineName\$ApplicationName$PipelineStageName;Integrated Security=true;

Release variable:
SQLString

Display Value : APPLI.SQL.LOCAL.LAN\APPLI
``
For each Pipeline step (3 steps DEV, QA, PRD for example), I should have the following DB connection:

* APPLIDEV.SQL.LOCAL.LAN\APPLIDEV
* APPLIQA.SQL.LOCAL.LAN\APPLIQA
* APPLIPRD.SQL.LOCAL.LAN\APPLIPRD

Setting the variable $SQLString at the pipeline level give nothing.

Hi Philippe,

I see that the $PiplineStageName is not available at the Release level. So this will only work as a Build variable.

Does this help?

Thanks!
Jason

You are right, the PipelinestageName Variable is correctly set at the build level..

But, it is assigned with the last Pipeline used and it is a little confusing for what I am looking for (for each pipeline step correspond a DB string)

Never mind, I will make the DB connection by hand

Thank you for the spending time

Answer Question