How can i execute sql commands using jenkins

9,680 views
Skip to first unread message

Sivakrishna Yarra

unread,
Jan 23, 2017, 8:43:07 AM1/23/17
to Jenkins Users
Hi,
I am using Jenkins as a CI. how can i execute sql statements by using jenkins tool. I am using Mysql is the database. Can you please help on this.

jer...@bodycad.com

unread,
Jan 23, 2017, 8:48:50 AM1/23/17
to Jenkins Users
Hi,
you need to execute either a bat or sh command with the mysql binaray:


You can either cat the command into a temporary file then pipe it to the command or have the scripts already prepared.

Jerome

Sivakrishna Yarra

unread,
Jan 23, 2017, 8:56:37 AM1/23/17
to jenkins...@googlegroups.com
Hi Jerome,
Thanks for the info. I have a .sql file which contains multiple set of queries.
I will execute this .sql file by using shell script. For this script i had created a Jenkins Job.
But How i will get to know from JenkinsCI  if any exception has came ..?

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/SPYKGgr_5VA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/74149b4a-6ae4-4cad-b630-0f8c1f462125%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

jer...@bodycad.com

unread,
Jan 23, 2017, 9:25:11 AM1/23/17
to Jenkins Users
Are you running inside a pipeline script or the "old" way?


If this is a new project, you may want to try the new pipeline, it will make thing more flexible.

Sivakrishna Yarra

unread,
Jan 23, 2017, 9:35:53 AM1/23/17
to jenkins...@googlegroups.com
I am using old way like i had copied the shell script file in to linux server. Through Jenkins job i am calling the shell script.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/SPYKGgr_5VA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-users+unsubscribe@googlegroups.com.

jer...@bodycad.com

unread,
Jan 23, 2017, 10:09:06 AM1/23/17
to Jenkins Users
If I remember well, the command return value is the fail/pass. So you may want to craft your command to return non 0 and make the build fail when something did not goes as planed.

Sivakrishna Yarra

unread,
Jan 24, 2017, 12:39:50 AM1/24/17
to jenkins...@googlegroups.com
Thanks man.. I got it

On Mon, Jan 23, 2017 at 8:39 PM, <jer...@bodycad.com> wrote:
If I remember well, the command return value is the fail/pass. So you may want to craft your command to return non 0 and make the build fail when something did not goes as planed.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/SPYKGgr_5VA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-users+unsubscribe@googlegroups.com.

farr...@techfoursolutions.com

unread,
May 1, 2019, 8:32:25 AM5/1/19
to Jenkins Users
Hi My Scenario is that what if i want to run multiple queries using jenkins time to time . As using shell script i need to change the script every time for which i have to login server .

Kumar Praful

unread,
Apr 14, 2020, 9:54:23 AM4/14/20
to Jenkins Users
Hi All,

I have almost similar requirement. I am taking backup of databases (as .sql file ) through cron job daily on ubuntu system. Now, I am thinking to run a mysql in docker container and then through Jenkins pipeline job (groovy), I want to restore the db backup file in the docker mysql backup. This will ensure me availability of DB if any fails sudden. 
Could you please help me out with your Jenkins Job ?

Thanks
Kumar Praful


On Monday, January 23, 2017 at 7:13:07 PM UTC+5:30, Sivakrishna Yarra wrote:
Reply all
Reply to author
Forward
0 new messages