Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8894251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:26:57+00:00 2026-06-14T23:26:57+00:00

I have a Jenkins job which runs a shell script. It works perfectly when

  • 0

I have a Jenkins job which runs a shell script. It works perfectly when the script is placed directly in the Build command field. But if I put the script in a .sh file and then call that fine from the Build command field:

sh $sh_dir/deploy.sh $repo_dir $name $ref $env $site_dir

$sh_dir is an env variable and the rest are job parameters. It doesn’t work, it fails on the first command which is simply

cd $1/$2

Again, this works perfectly when put directly in the command field, but not when in the .sh file. The output from the .sh file job is:

Started by user anonymous
Building in workspace /var/lib/jenkins/workspace/deploy
[deploy] $ /bin/sh -xe /tmp/hudson6229756058999358596.sh

+ /var/lib/jenkins/scripts/deploy.sh /home/repos magento master live /home/sites
cd: 1: can't cd to /home/repos/magento

Yes the directory does exist and yes it is owned by jenkins.

I’m going out of my mind trying to figure this out.

Edit: result of deploy.sh with -x:

Started by user anonymous
Building in workspace /var/lib/jenkins/workspace/deploy
[deploy] $ /bin/sh -xe /tmp/hudson3304816709711757032.sh
+ sh -x /var/lib/jenkins/scripts/deploy.sh /home/repos magento develop staging /home/sites
+ cd /home/repos/magento
cd: 1: can't cd to /home/repos/magento
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:26:58+00:00Added an answer on June 14, 2026 at 11:26 pm

    The discussion in the comments was taken to chat.

    The problem was eventually discovered to be Windows line endings (CRLF) causing confusion. For example, the directory /home/repos/magento\r with a CR at the end really doesn’t exist. There are Windows CIF shared folders lurking around. The solution will involve working out how to convert the scripts to native Unix (LF only) line endings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a Jenkins job, I have a windows batch Command build step, which runs
I have a Jenkins build which builds a maven project with -PmyProfile clean package
I have setup jenkin and create a jenkins job to build my maven project,
I have a Jenkins job which compiles and publishes our Java project to a
I have Jenkins job that calls Python script in it's configuration. Script creates few
When you have a long running job in Jenkins which is composed of many
I have two scripts in the pre-build step in a Jenkins job, the first
For some reason I have to access Jenkins global environment variables like BUILD ID,
I have a big Maven multi-module build set up in my Jenkins. It is
I have jenkins set up to build any branch and merge it into master.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.