How can i execute shell scripts from Jenkins ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

How can i execute shell scripts from Jenkins ?

Kendiol
Hello everyone,

I'm a complete newbie to Jenkins.
I'm trying to get Jenkins to monitor the execution of my shell script
so i that i don't have to launch them manually each time but i can't
figure out how to do it.
I found out about the "monitor external job" option but i can't
configure it correctly.
I know that Jenkins can understand Shell script exit code so this is
what i did :

test1(){
ls /home/user1 | grep $2
case $? in
        0) msg_error 0 "Okay."
                ;;
        *) msg_error 2 "Error."
                ;;
esac
}


It's a simplified version of my functions.
I execute them manually but i want to launch them from Jenkins with
arguments and get the results of course.
Can this be done ?

Thanks.

Reply | Threaded
Open this post in threaded view
|

Re: How can i execute shell scripts from Jenkins ?

skidad
Create a Jenkins job, ( i created a free-style software project)
In the configuration of that job there is a "Build" section with "Add
build step" pulldown.
Add a "Execute Shell" step, and  insert your code.

Hope this helps!
Derek . . .

On Sep 27, 10:00 am, Kendiol <[hidden email]> wrote:

> Hello everyone,
>
> I'm a complete newbie to Jenkins.
> I'm trying to get Jenkins to monitor the execution of my shell script
> so i that i don't have to launch them manually each time but i can't
> figure out how to do it.
> I found out about the "monitor external job" option but i can't
> configure it correctly.
> I know that Jenkins can understand Shell script exit code so this is
> what i did :
>
> test1(){
> ls /home/user1 | grep $2
> case $? in
>         0) msg_error 0 "Okay."
>                 ;;
>         *) msg_error 2 "Error."
>                 ;;
> esac
>
> }
>
> It's a simplified version of my functions.
> I execute them manually but i want to launch them from Jenkins with
> arguments and get the results of course.
> Can this be done ?
>
> Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: How can i execute shell scripts from Jenkins ?

HARDION Vincent
Hi,

Also you can define parametrized build.
These parameters will appear as env var.
More explanation here : https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Build

Best regards,

Vincent

On 27 Sep 2011, at 22:19, Derek Brown wrote:

> Create a Jenkins job, ( i created a free-style software project)
> In the configuration of that job there is a "Build" section with "Add
> build step" pulldown.
> Add a "Execute Shell" step, and  insert your code.
>
> Hope this helps!
> Derek . . .
>
> On Sep 27, 10:00 am, Kendiol <[hidden email]> wrote:
>> Hello everyone,
>>
>> I'm a complete newbie to Jenkins.
>> I'm trying to get Jenkins to monitor the execution of my shell script
>> so i that i don't have to launch them manually each time but i can't
>> figure out how to do it.
>> I found out about the "monitor external job" option but i can't
>> configure it correctly.
>> I know that Jenkins can understand Shell script exit code so this is
>> what i did :
>>
>> test1(){
>> ls /home/user1 | grep $2
>> case $? in
>>         0) msg_error 0 "Okay."
>>                 ;;
>>         *) msg_error 2 "Error."
>>                 ;;
>> esac
>>
>> }
>>
>> It's a simplified version of my functions.
>> I execute them manually but i want to launch them from Jenkins with
>> arguments and get the results of course.
>> Can this be done ?
>>
>> Thanks.

Reply | Threaded
Open this post in threaded view
|

Re: How can i execute shell scripts from Jenkins ?

Kendiol
Thanks guys, so to execute my script I simply put ./myscript as the
command of the FreeStyle Build and i set the pamaeters to call my
functions.


On 28 sep, 07:36, Vincent Hardion <vincent.hard...@synchrotron-
soleil.fr> wrote:

> Hi,
>
> Also you can define parametrized build.
> These parameters will appear as env var.
> More explanation here :https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Build
>
> Best regards,
>
> Vincent
>
> On 27 Sep 2011, at 22:19, Derek Brown wrote:
>
>
>
> > Create a Jenkins job, ( i created a free-style software project)
> > In the configuration of that job there is a "Build" section with "Add
> > build step" pulldown.
> > Add a "Execute Shell" step, and  insert your code.
>
> > Hope this helps!
> > Derek . . .
>
> > On Sep 27, 10:00 am, Kendiol <[hidden email]> wrote:
> >> Hello everyone,
>
> >> I'm a complete newbie to Jenkins.
> >> I'm trying to get Jenkins to monitor the execution of my shell script
> >> so i that i don't have to launch them manually each time but i can't
> >> figure out how to do it.
> >> I found out about the "monitor external job" option but i can't
> >> configure it correctly.
> >> I know that Jenkins can understand Shell script exit code so this is
> >> what i did :
>
> >> test1(){
> >> ls /home/user1 | grep $2
> >> case $? in
> >>         0) msg_error 0 "Okay."
> >>                 ;;
> >>         *) msg_error 2 "Error."
> >>                 ;;
> >> esac
>
> >> }
>
> >> It's a simplified version of my functions.
> >> I execute them manually but i want to launch them from Jenkins with
> >> arguments and get the results of course.
> >> Can this be done ?
>
> >> Thanks.- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -
Reply | Threaded
Open this post in threaded view
|

Re: How can i execute shell scripts from Jenkins ?

Braj Mohan
In reply to this post by skidad
Hi Derek Brown,

Can i directly call my .sh file into build section.

Thanks

On Wednesday, 28 September 2011 01:49:58 UTC+5:30, Derek Brown wrote:
Create a Jenkins job, ( i created a free-style software project)
In the configuration of that job there is a "Build" section with "Add
build step" pulldown.
Add a "Execute Shell" step, and  insert your code.

Hope this helps!
Derek . . .

On Sep 27, 10:00 am, Kendiol <[hidden email]> wrote:

> Hello everyone,
>
> I'm a complete newbie to Jenkins.
> I'm trying to get Jenkins to monitor the execution of my shell script
> so i that i don't have to launch them manually each time but i can't
> figure out how to do it.
> I found out about the "monitor external job" option but i can't
> configure it correctly.
> I know that Jenkins can understand Shell script exit code so this is
> what i did :
>
> test1(){
> ls /home/user1 | grep $2
> case $? in
>         0) msg_error 0 "Okay."
>                 ;;
>         *) msg_error 2 "Error."
>                 ;;
> esac
>
> }
>
> It's a simplified version of my functions.
> I execute them manually but i want to launch them from Jenkins with
> arguments and get the results of course.
> Can this be done ?
>
> Thanks.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/8cb077b4-c41a-49ae-bdb1-793b9014a066%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: How can i execute shell scripts from Jenkins ?

malpanisiddhesh
Mohan,

Yes of course you can do that. Simply ad the shell script file name in the 'Execute Shell' step as explained by Derek. Remember that you've give the path of your file relative to your workspace directory. Suppose your worskapce dir is 'build-dev' and the shell script 'patch.sh' is located in a dir 'scripts' under the workspace. Then you'll have to give it's path as:

./scripts/patch.sh

And you're good to go.

Cheers,
Siddhesh

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/ab9e0848-a4a2-4c86-ad6d-7699760ed998%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: How can i execute shell scripts from Jenkins ?

Gil Jensen
can you tell me why Jenkins would get a different result from the  shell scripts  alone?

On Wednesday, March 18, 2020 at 12:25:34 PM UTC-4 Siddhesh Malpani wrote:
Mohan,

Yes of course you can do that. Simply ad the shell script file name in the 'Execute Shell' step as explained by Derek. Remember that you've give the path of your file relative to your workspace directory. Suppose your worskapce dir is 'build-dev' and the shell script 'patch.sh' is located in a dir 'scripts' under the workspace. Then you'll have to give it's path as:

./scripts/patch.sh

And you're good to go.

Cheers,
Siddhesh

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/c6d9f1a7-ac7a-4e88-9267-ee8ec1386223n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

RE: How can i execute shell scripts from Jenkins ?

Jensen, Gil

Thank you, I have done this but they are still not running equally

 

Thanks and Regards

General Dynamics Land Systems

Gil Jensen

M:616-610-0914

D:586-825-5421

[hidden email]

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Gil Jensen
Sent: Friday, March 5, 2021 12:04 PM
To: Jenkins Users <[hidden email]>
Subject: Re: How can i execute shell scripts from Jenkins ?

 


CAUTION EXTERNAL EMAIL

THIS EMAIL WAS SENT FROM OUTSIDE GDLS. PLEASE DO NOT OPEN ANY URL LINKS, OPEN ATTACHMENTS OR REPLY TO THIS EMAIL IF YOU ARE UNABLE TO VERIFY THE SENDER’S EMAIL ADDRESS

can you tell me why Jenkins would get a different result from the  shell scripts  alone?

On Wednesday, March 18, 2020 at 12:25:34 PM UTC-4 Siddhesh Malpani wrote:

Mohan,

Yes of course you can do that. Simply ad the shell script file name in the 'Execute Shell' step as explained by Derek. Remember that you've give the path of your file relative to your workspace directory. Suppose your worskapce dir is 'build-dev' and the shell script 'patch.sh' is located in a dir 'scripts' under the workspace. Then you'll have to give it's path as:

./scripts/patch.sh

And you're good to go.

Cheers,
Siddhesh

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/c6d9f1a7-ac7a-4e88-9267-ee8ec1386223n%40googlegroups.com [groups.google.com].


This is an e-mail from General Dynamics Land Systems. It is for the intended recipient only and may contain confidential and privileged information. No one else may read, print, store, copy, forward or act in reliance on it or its attachments. If you are not the intended recipient, please return this message to the sender and delete the message and any attachments from your computer. Your cooperation is appreciated.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/92c2c353d49b4d5ea5c66f18e5a26732%40gdls.com.
Reply | Threaded
Open this post in threaded view
|

Re: How can i execute shell scripts from Jenkins ?

Eric Pyle-3
In reply to this post by Gil Jensen
Typically such problems are because the shell script is tested under a different user account than the one used by Jenkins. This may result in commands not being found due to different $PATH settings or permission errors because of different user permissions. It's hard to be more specific without knowing more about the errors you are seeing.

Eric

On 3/5/2021 12:03 PM, Gil Jensen wrote:
can you tell me why Jenkins would get a different result from the  shell scripts  alone?

On Wednesday, March 18, 2020 at 12:25:34 PM UTC-4 Siddhesh Malpani wrote:
Mohan,

Yes of course you can do that. Simply ad the shell script file name in the 'Execute Shell' step as explained by Derek. Remember that you've give the path of your file relative to your workspace directory. Suppose your worskapce dir is 'build-dev' and the shell script 'patch.sh' is located in a dir 'scripts' under the workspace. Then you'll have to give it's path as:

./scripts/patch.sh

And you're good to go.

Cheers,
Siddhesh

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/c6d9f1a7-ac7a-4e88-9267-ee8ec1386223n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/ddb470f6-4eac-0cbe-2909-117690147526%40cd-adapco.com.
Reply | Threaded
Open this post in threaded view
|

RE: How can i execute shell scripts from Jenkins ?

Jensen, Gil

Thanks Eric

 

Thanks and Regards

Gil Jensen

General Dynamics Land Systems

M:616-610-0914

D:586-825-5421

[hidden email]

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Eric Pyle
Sent: Friday, March 5, 2021 2:47 PM
To: [hidden email]
Subject: Re: How can i execute shell scripts from Jenkins ?

 


CAUTION EXTERNAL EMAIL

THIS EMAIL WAS SENT FROM OUTSIDE GDLS. PLEASE DO NOT OPEN ANY URL LINKS, OPEN ATTACHMENTS OR REPLY TO THIS EMAIL IF YOU ARE UNABLE TO VERIFY THE SENDER’S EMAIL ADDRESS

Typically such problems are because the shell script is tested under a different user account than the one used by Jenkins. This may result in commands not being found due to different $PATH settings or permission errors because of different user permissions. It's hard to be more specific without knowing more about the errors you are seeing.

Eric

On 3/5/2021 12:03 PM, Gil Jensen wrote:

can you tell me why Jenkins would get a different result from the  shell scripts  alone?

On Wednesday, March 18, 2020 at 12:25:34 PM UTC-4 Siddhesh Malpani wrote:

Mohan,

Yes of course you can do that. Simply ad the shell script file name in the 'Execute Shell' step as explained by Derek. Remember that you've give the path of your file relative to your workspace directory. Suppose your worskapce dir is 'build-dev' and the shell script 'patch.sh' is located in a dir 'scripts' under the workspace. Then you'll have to give it's path as:

./scripts/patch.sh

And you're good to go.

Cheers,
Siddhesh

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/c6d9f1a7-ac7a-4e88-9267-ee8ec1386223n%40googlegroups.com [groups.google.com].

 

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/ddb470f6-4eac-0cbe-2909-117690147526%40cd-adapco.com [groups.google.com].


This is an e-mail from General Dynamics Land Systems. It is for the intended recipient only and may contain confidential and privileged information. No one else may read, print, store, copy, forward or act in reliance on it or its attachments. If you are not the intended recipient, please return this message to the sender and delete the message and any attachments from your computer. Your cooperation is appreciated.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/107cb34f902c48aa8e3dfa838cdf064e%40gdls.com.