how to execute a bash script in a jenkins declarative pipeline

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

how to execute a bash script in a jenkins declarative pipeline

jesus fernandez
I have started recently using Jenkins in windows 10. I have a freestyle job that sync from the SCM, build a C++ solution and then it runs a batch script to upload to steam. I am trying to convert it to pipeline as I realized reading the documentation how much more powerful it is. My problem is that on the step to run the .bat file it gets stuck forever, this is the step:
```
...
Stage('batch script'){
            steps{
                bat 'start C:/Users/User/.jenkins/workspace/Project/Steam Build 
                Scripts/scripts/build_dev.bat'
            }
        }
...
```

and this is the simple .bat file:
```
"C:\Users\User\.jenkins\workspace\Project\Steam Build Scripts\builder\steamcmd.exe" +login "someUser" "somePassword" +run_app_build "C:\Users\User\.jenkins\workspace\Project\Steam Build Scripts\scripts\app-build-813780-dev.vdf" +quit

```

running the same file from the freestyle job works fine like this:10IC9 (1).png

--
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/e9a2b099-812c-4cb3-a459-0000f874e455n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

RE: how to execute a bash script in a jenkins declarative pipeline

Jérôme Godbout

Hi,

make sure to escape the path if it has spaces:

bat('start “C:/Users/User/.jenkins/workspace/Project/Steam Build Scripts/scripts/build_dev.bat”');

 

Why do you need the start? Is the command return before completion or something?

 

 

From: [hidden email] <[hidden email]> On Behalf Of jesus fernandez
Sent: September 24, 2020 8:24 AM
To: Jenkins Users <[hidden email]>
Subject: how to execute a bash script in a jenkins declarative pipeline

 

I have started recently using Jenkins in windows 10. I have a freestyle job that sync from the SCM, build a C++ solution and then it runs a batch script to upload to steam. I am trying to convert it to pipeline as I realized reading the documentation how much more powerful it is. My problem is that on the step to run the .bat file it gets stuck forever, this is the step:

```

...

Stage('batch script'){

            steps{

                bat 'start C:/Users/User/.jenkins/workspace/Project/Steam Build 

                Scripts/scripts/build_dev.bat'

            }

        }

...

```

 

and this is the simple .bat file:

```

"C:\Users\User\.jenkins\workspace\Project\Steam Build Scripts\builder\steamcmd.exe" +login "someUser" "somePassword" +run_app_build "C:\Users\User\.jenkins\workspace\Project\Steam Build Scripts\scripts\app-build-813780-dev.vdf" +quit

 

```

 

running the same file from the freestyle job works fine like this:

--
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/e9a2b099-812c-4cb3-a459-0000f874e455n%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/QB1PR01MB38447B0DED7787FED6E8BFA3CD390%40QB1PR01MB3844.CANPRD01.PROD.OUTLOOK.COM.
Reply | Threaded
Open this post in threaded view
|

Re: how to execute a bash script in a jenkins declarative pipeline

jesus fernandez
I also tried with call  but I get this error:
```
16:18:43 C:\Users\User\.jenkins\workspace\pipeline_test>call C:/Users/User/.jenkins/workspace/Age_2_DE/Steam Build Scripts/scripts/build_dev.bat 16:18:43 'C:/Users/User/.jenkins/workspace/Age_2_DE/Steam' is not recognized as an internal or external command, 16:18:43 operable program or batch file.  
```

El jueves, 24 de septiembre de 2020 a las 16:07:28 UTC+2, Jérôme Godbout escribió:

Hi,

make sure to escape the path if it has spaces:

bat('start “C:/Users/User/.jenkins/workspace/Project/Steam Build Scripts/scripts/build_dev.bat”');

 

Why do you need the start? Is the command return before completion or something?

 

 

From: [hidden email] <[hidden email]> On Behalf Of jesus fernandez
Sent: September 24, 2020 8:24 AM
To: Jenkins Users <[hidden email]>
Subject: how to execute a bash script in a jenkins declarative pipeline

 

I have started recently using Jenkins in windows 10. I have a freestyle job that sync from the SCM, build a C++ solution and then it runs a batch script to upload to steam. I am trying to convert it to pipeline as I realized reading the documentation how much more powerful it is. My problem is that on the step to run the .bat file it gets stuck forever, this is the step:

```

...

Stage('batch script'){

            steps{

                bat 'start C:/Users/User/.jenkins/workspace/Project/Steam Build 

                Scripts/scripts/build_dev.bat'

            }

        }

...

```

 

and this is the simple .bat file:

```

"C:\Users\User\.jenkins\workspace\Project\Steam Build Scripts\builder\steamcmd.exe" +login "someUser" "somePassword" +run_app_build "C:\Users\User\.jenkins\workspace\Project\Steam Build Scripts\scripts\app-build-813780-dev.vdf" +quit

 

```

 

running the same file from the freestyle job works fine like this:

--
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/e9a2b099-812c-4cb3-a459-0000f874e455n%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/c8fe5bae-54a6-4512-aa09-c2846b0c59bcn%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: how to execute a bash script in a jenkins declarative pipeline

jesus fernandez
but what you suggested worked! probaly I need to improve my batch scripting knowledge as it is none at the moment. THANKS A LOT! 
El jueves, 24 de septiembre de 2020 a las 16:19:09 UTC+2, jesus fernandez escribió:
I also tried with call  but I get this error:
```
16:18:43 C:\Users\User\.jenkins\workspace\pipeline_test>call C:/Users/User/.jenkins/workspace/Age_2_DE/Steam Build Scripts/scripts/build_dev.bat 16:18:43 'C:/Users/User/.jenkins/workspace/Age_2_DE/Steam' is not recognized as an internal or external command, 16:18:43 operable program or batch file.  
```

El jueves, 24 de septiembre de 2020 a las 16:07:28 UTC+2, Jérôme Godbout escribió:

Hi,

make sure to escape the path if it has spaces:

bat('start “C:/Users/User/.jenkins/workspace/Project/Steam Build Scripts/scripts/build_dev.bat”');

 

Why do you need the start? Is the command return before completion or something?

 

 

From: [hidden email] <[hidden email]> On Behalf Of jesus fernandez
Sent: September 24, 2020 8:24 AM
To: Jenkins Users <[hidden email]>
Subject: how to execute a bash script in a jenkins declarative pipeline

 

I have started recently using Jenkins in windows 10. I have a freestyle job that sync from the SCM, build a C++ solution and then it runs a batch script to upload to steam. I am trying to convert it to pipeline as I realized reading the documentation how much more powerful it is. My problem is that on the step to run the .bat file it gets stuck forever, this is the step:

```

...

Stage('batch script'){

            steps{

                bat 'start C:/Users/User/.jenkins/workspace/Project/Steam Build 

                Scripts/scripts/build_dev.bat'

            }

        }

...

```

 

and this is the simple .bat file:

```

"C:\Users\User\.jenkins\workspace\Project\Steam Build Scripts\builder\steamcmd.exe" +login "someUser" "somePassword" +run_app_build "C:\Users\User\.jenkins\workspace\Project\Steam Build Scripts\scripts\app-build-813780-dev.vdf" +quit

 

```

 

running the same file from the freestyle job works fine like this:

--
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/e9a2b099-812c-4cb3-a459-0000f874e455n%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/f8b508ad-2d67-49e3-aab7-0451c525cb4en%40googlegroups.com.