Shell script not working as expected in jenkins

31 views
Skip to first unread message

Sai Pavwan

unread,
Feb 11, 2020, 7:06:39 PM2/11/20
to Jenkins Users
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. 

Mark Waite

unread,
Feb 11, 2020, 7:20:09 PM2/11/20
to Jenkins Users
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

--
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 jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/1be64daa-3235-4c49-9d05-501e8e31ddda%40googlegroups.com.

Sai Pavwan

unread,
Feb 11, 2020, 7:38:34 PM2/11/20
to Jenkins Users
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.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkins...@googlegroups.com.

Mark Waite

unread,
Feb 11, 2020, 9:35:49 PM2/11/20
to Jenkins Users
Sorry, I don't have any other suggestions to offer.

To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/6858e0f7-1662-426d-ba6a-eea46b93613b%40googlegroups.com.

Richard Bywater

unread,
Feb 11, 2020, 9:40:33 PM2/11/20
to jenkins...@googlegroups.com
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.

To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/6858e0f7-1662-426d-ba6a-eea46b93613b%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages