I'm on the Jenkins ver. 2.176.1.
I wish to connect to mysql database by passing host, port, and credentials in Jenkins pipeline for SELECT / INSERT queries to an existing database table.
As, I have understood there is no good plugin that works for MySQL connectivity (tried a couple which do not mask the password); I decided to set the MySQL hostname and Port as environment variables and username and password as credentials in Jenkins.
I have three plugins installed for this purpose viz. Credentials plugin, Credentials Binding plugin,Plain Credentials plugin.
I then setup mysql credentials by clicking: Jenkins->Credentials->System->Global credentials (unrestricted)
Now; in-order to generate code for pipeline for accessing these credentials i go to-> http:///pipeline-syntax/ see below snapshot:
Below are three queries I have:
1. The credentials drop-down (marked with RED ARROW in the snapshot above) in the pipeline syntax generator does not populate anything & seems disabled. I was expecting the mysql credentials ID to show up in the drop-down as expected. Can you suggest what could be the issue here ? Also, I have administrator role.
2. I need the syntax to pass the MySQL username and password as variables to a different Jenkins job from my pipeline script below. Please suggest how can I ?
steps { build job: 'myjob1', parameters: [string(name: 'Region', value: "${params.Region}"),<mysql-username>,<mysql-password>)] }
3. Is there Alternate / better solution than the one I chose for Masking Database credentials ?