Shell script not working as expected in jenkins

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Shell script not working as expected in jenkins

Sai Pavwan
Hi , 
      I am on my jenkins which is hosted on ECS cluster. I have created a jenkins job and planned to run that job for every release. So coming to the point this script will transition jira tickets, will change the jira tickets status. The process of picking jira tickets will be filtered by commit messages between git branches. I am using a command git log origin/master..${BRANCH} --oneline --no-merges this will give you all the commit messages which will include Jira Ticket numbers. From that messages I am using sed command and regular expressions concepts to take out the ticket number like X1-(0-9). This extracted number will be passed to a Jira Query to transition ticket automatically. 
         So the thing is I developed this script in local system which works fine and it transitioning all the tickets like around 200 tickets for every release, so when i add this script to Jenkins job in Build --> Execute Shell its not working as expected. There is not fail in job but the response was absolutely wrong , if we have a 100 tickets in branch every time its getting only one ticket number out from the Repo's. Just because its working in my local and its working in Jenkins just want to make sure whether this problem is with the Jenkins or i am missing anything. Can you guys please help me out on this. Thanks in advance.
- Pavwan. 

--
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/1be64daa-3235-4c49-9d05-501e8e31ddda%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Shell script not working as expected in jenkins

Mark Waite-2
It is quite common that a script which works on a developer desktop does not work in another environment like Jenkins.

Common reasons include:
  • Scripts assuming they are running with a controlling terminal
  • Scripts assuming the existence of specific ssh private keys
  • Scripts assuming the existence of specific environment variables
  • Scripts assuming a specific user account name
  • Scripts assuming specific versions of tools are available
  • Scripts assuming specific execution environment (Windows, Linux, FreeBSD, macOS, etc.)
One way to diagnose those types of dependencies is to create a new account on your development computer and run the script from that new account.  Another technique is to create a new account on a Jenkins agent computer and run the script from there.  Another technique is to run the script from a cron or batch job as yourself.

Mark Waite

On Tue, Feb 11, 2020 at 5:06 PM Sai Pavwan <[hidden email]> wrote:
Hi , 
      I am on my jenkins which is hosted on ECS cluster. I have created a jenkins job and planned to run that job for every release. So coming to the point this script will transition jira tickets, will change the jira tickets status. The process of picking jira tickets will be filtered by commit messages between git branches. I am using a command git log origin/master..${BRANCH} --oneline --no-merges this will give you all the commit messages which will include Jira Ticket numbers. From that messages I am using sed command and regular expressions concepts to take out the ticket number like X1-(0-9). This extracted number will be passed to a Jira Query to transition ticket automatically. 
         So the thing is I developed this script in local system which works fine and it transitioning all the tickets like around 200 tickets for every release, so when i add this script to Jenkins job in Build --> Execute Shell its not working as expected. There is not fail in job but the response was absolutely wrong , if we have a 100 tickets in branch every time its getting only one ticket number out from the Repo's. Just because its working in my local and its working in Jenkins just want to make sure whether this problem is with the Jenkins or i am missing anything. Can you guys please help me out on this. Thanks in advance.
- Pavwan. 

--
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/1be64daa-3235-4c49-9d05-501e8e31ddda%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/CAO49JtF-SsixFJbq7Xxbj1OVxsuDdHJ24%2Bqy6BbeBdRt7ZKsow%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Shell script not working as expected in jenkins

Sai Pavwan
Hi Mark Waite, 
                          Thanks for your response on that.
   Firstly, I have take into consideration all of the things that you stated except the environment. My local Macos Terminal which is linux, but i am running my script in on Ubuntu which makes a little sense for a moment but in that case the build should fail and in the logs i am seeing only one ticket number extracted every time.
 And i am using commands like:
      sed, regular expresions, echo, sort, uniq, for loop and curl too.
   And also running through Cron Job is also a good idea but i have to include this script only in the job which deploys our code to STG Env. Cron Job is what we can schedule to run this at that particular time. But here the requirement is different, script should execute along with the code deploy job.
      Is there any other alternative that i can proceed by excluding these consequences .
- Pavwan.

On Tuesday, February 11, 2020 at 4:20:09 PM UTC-8, Mark Waite wrote:
It is quite common that a script which works on a developer desktop does not work in another environment like Jenkins.

Common reasons include:
  • Scripts assuming they are running with a controlling terminal
  • Scripts assuming the existence of specific ssh private keys
  • Scripts assuming the existence of specific environment variables
  • Scripts assuming a specific user account name
  • Scripts assuming specific versions of tools are available
  • Scripts assuming specific execution environment (Windows, Linux, FreeBSD, macOS, etc.)
One way to diagnose those types of dependencies is to create a new account on your development computer and run the script from that new account.  Another technique is to create a new account on a Jenkins agent computer and run the script from there.  Another technique is to run the script from a cron or batch job as yourself.

Mark Waite

On Tue, Feb 11, 2020 at 5:06 PM Sai Pavwan <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="Dz8OJrRzGQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">spa...@...> wrote:
Hi , 
      I am on my jenkins which is hosted on ECS cluster. I have created a jenkins job and planned to run that job for every release. So coming to the point this script will transition jira tickets, will change the jira tickets status. The process of picking jira tickets will be filtered by commit messages between git branches. I am using a command git log origin/master..${BRANCH} --oneline --no-merges this will give you all the commit messages which will include Jira Ticket numbers. From that messages I am using sed command and regular expressions concepts to take out the ticket number like X1-(0-9). This extracted number will be passed to a Jira Query to transition ticket automatically. 
         So the thing is I developed this script in local system which works fine and it transitioning all the tickets like around 200 tickets for every release, so when i add this script to Jenkins job in Build --> Execute Shell its not working as expected. There is not fail in job but the response was absolutely wrong , if we have a 100 tickets in branch every time its getting only one ticket number out from the Repo's. Just because its working in my local and its working in Jenkins just want to make sure whether this problem is with the Jenkins or i am missing anything. Can you guys please help me out on this. Thanks in advance.
- Pavwan. 

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="Dz8OJrRzGQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkins...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/1be64daa-3235-4c49-9d05-501e8e31ddda%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/1be64daa-3235-4c49-9d05-501e8e31ddda%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/1be64daa-3235-4c49-9d05-501e8e31ddda%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/1be64daa-3235-4c49-9d05-501e8e31ddda%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/6858e0f7-1662-426d-ba6a-eea46b93613b%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Shell script not working as expected in jenkins

Mark Waite-2
Sorry, I don't have any other suggestions to offer.

On Tue, Feb 11, 2020 at 5:38 PM Sai Pavwan <[hidden email]> wrote:
Hi Mark Waite, 
                          Thanks for your response on that.
   Firstly, I have take into consideration all of the things that you stated except the environment. My local Macos Terminal which is linux, but i am running my script in on Ubuntu which makes a little sense for a moment but in that case the build should fail and in the logs i am seeing only one ticket number extracted every time.
 And i am using commands like:
      sed, regular expresions, echo, sort, uniq, for loop and curl too.
   And also running through Cron Job is also a good idea but i have to include this script only in the job which deploys our code to STG Env. Cron Job is what we can schedule to run this at that particular time. But here the requirement is different, script should execute along with the code deploy job.
      Is there any other alternative that i can proceed by excluding these consequences .
- Pavwan.

On Tuesday, February 11, 2020 at 4:20:09 PM UTC-8, Mark Waite wrote:
It is quite common that a script which works on a developer desktop does not work in another environment like Jenkins.

Common reasons include:
  • Scripts assuming they are running with a controlling terminal
  • Scripts assuming the existence of specific ssh private keys
  • Scripts assuming the existence of specific environment variables
  • Scripts assuming a specific user account name
  • Scripts assuming specific versions of tools are available
  • Scripts assuming specific execution environment (Windows, Linux, FreeBSD, macOS, etc.)
One way to diagnose those types of dependencies is to create a new account on your development computer and run the script from that new account.  Another technique is to create a new account on a Jenkins agent computer and run the script from there.  Another technique is to run the script from a cron or batch job as yourself.

Mark Waite

On Tue, Feb 11, 2020 at 5:06 PM Sai Pavwan <[hidden email]> wrote:
Hi , 
      I am on my jenkins which is hosted on ECS cluster. I have created a jenkins job and planned to run that job for every release. So coming to the point this script will transition jira tickets, will change the jira tickets status. The process of picking jira tickets will be filtered by commit messages between git branches. I am using a command git log origin/master..${BRANCH} --oneline --no-merges this will give you all the commit messages which will include Jira Ticket numbers. From that messages I am using sed command and regular expressions concepts to take out the ticket number like X1-(0-9). This extracted number will be passed to a Jira Query to transition ticket automatically. 
         So the thing is I developed this script in local system which works fine and it transitioning all the tickets like around 200 tickets for every release, so when i add this script to Jenkins job in Build --> Execute Shell its not working as expected. There is not fail in job but the response was absolutely wrong , if we have a 100 tickets in branch every time its getting only one ticket number out from the Repo's. Just because its working in my local and its working in Jenkins just want to make sure whether this problem is with the Jenkins or i am missing anything. Can you guys please help me out on this. Thanks in advance.
- Pavwan. 

--
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/1be64daa-3235-4c49-9d05-501e8e31ddda%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/6858e0f7-1662-426d-ba6a-eea46b93613b%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/CAO49JtHMBsagwMPq1_6%2Bz_T5vzwd%2BR5ccjgiTJhAJtHQHRR8KA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Shell script not working as expected in jenkins

Richard Bywater-3
In reply to this post by Sai Pavwan
Without seeing some kinds of logs to understand what the script is doing and what output is wrong then there could be many things wrong.

One thing to note is that MacOS Terminal is not Linux - there are a number of tools that are different as MacOS is BSD based. "sed" is one of those and so the behaviour and options of sed differs greatly between the sed that comes with MacOS and GNU sed which runs on most Linux servers.

As you say you are using ECS to run this, have you tried running on the process a local docker container with the right Linux variant to see if it works?

Richard.

On Wed, 12 Feb 2020 at 13:39, Sai Pavwan <[hidden email]> wrote:
Hi Mark Waite, 
                          Thanks for your response on that.
   Firstly, I have take into consideration all of the things that you stated except the environment. My local Macos Terminal which is linux, but i am running my script in on Ubuntu which makes a little sense for a moment but in that case the build should fail and in the logs i am seeing only one ticket number extracted every time.
 And i am using commands like:
      sed, regular expresions, echo, sort, uniq, for loop and curl too.
   And also running through Cron Job is also a good idea but i have to include this script only in the job which deploys our code to STG Env. Cron Job is what we can schedule to run this at that particular time. But here the requirement is different, script should execute along with the code deploy job.
      Is there any other alternative that i can proceed by excluding these consequences .
- Pavwan.

On Tuesday, February 11, 2020 at 4:20:09 PM UTC-8, Mark Waite wrote:
It is quite common that a script which works on a developer desktop does not work in another environment like Jenkins.

Common reasons include:
  • Scripts assuming they are running with a controlling terminal
  • Scripts assuming the existence of specific ssh private keys
  • Scripts assuming the existence of specific environment variables
  • Scripts assuming a specific user account name
  • Scripts assuming specific versions of tools are available
  • Scripts assuming specific execution environment (Windows, Linux, FreeBSD, macOS, etc.)
One way to diagnose those types of dependencies is to create a new account on your development computer and run the script from that new account.  Another technique is to create a new account on a Jenkins agent computer and run the script from there.  Another technique is to run the script from a cron or batch job as yourself.

Mark Waite

On Tue, Feb 11, 2020 at 5:06 PM Sai Pavwan <[hidden email]> wrote:
Hi , 
      I am on my jenkins which is hosted on ECS cluster. I have created a jenkins job and planned to run that job for every release. So coming to the point this script will transition jira tickets, will change the jira tickets status. The process of picking jira tickets will be filtered by commit messages between git branches. I am using a command git log origin/master..${BRANCH} --oneline --no-merges this will give you all the commit messages which will include Jira Ticket numbers. From that messages I am using sed command and regular expressions concepts to take out the ticket number like X1-(0-9). This extracted number will be passed to a Jira Query to transition ticket automatically. 
         So the thing is I developed this script in local system which works fine and it transitioning all the tickets like around 200 tickets for every release, so when i add this script to Jenkins job in Build --> Execute Shell its not working as expected. There is not fail in job but the response was absolutely wrong , if we have a 100 tickets in branch every time its getting only one ticket number out from the Repo's. Just because its working in my local and its working in Jenkins just want to make sure whether this problem is with the Jenkins or i am missing anything. Can you guys please help me out on this. Thanks in advance.
- Pavwan. 

--
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/1be64daa-3235-4c49-9d05-501e8e31ddda%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/6858e0f7-1662-426d-ba6a-eea46b93613b%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/CAAy0hwcGGS1DYwm4rYHX86cr3qEhN-OoEn6PfmBtQ9ndtdYqtg%40mail.gmail.com.