LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-27-2019, 09:11 PM   #1
DennyY
Member
 
Registered: May 2018
Location: San Francisco, CA
Distribution: CentOS 7
Posts: 77

Rep: Reputation: 1
Question Jenkins + Docker issue


Hi All....so for some reason, jenkins can't find my directory/file, even though the file exists.

Quote:
jenkins@2cc94da61ef4:/tmp$ ls
hsperfdata_jenkins jetty-0.0.0.0-8080-war-_-any-8686928681707098259.dir script.sh
hsperfdata_root jna--1712433994 winstone3962611894380363157.jar

After I built this job:

Quote:
/tmp/jenkins6161673403768114483.sh: line 2: /tmp/script.sh: No such file or directory
Build step 'Execute shell' marked build as failure
Finished: FAILURE

This is what I THINK the issue is, but I don't know how to solve it:

Quote:
version: '3'
services:
jenkins:
container_name: jenkins
image: jenkins/jenkins
ports:
- "8008:8008"
volumes:
- "$PWD/jenkins_home:/var/jenkins_home"
networks:
- net
networks:
net:

And my browser now is I tried to change the port back to 8008, but it says it's already in use.

As you can see, I have no problem accessing my container, and jenkins dashboard is up and running also.

Thank you for your help~
 
Old 05-31-2019, 08:35 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,708

Rep: Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803
usually that means the script is not executable, or the shebang points to an invalid (nonexistent) interpreter.
 
Old 05-31-2019, 05:59 PM   #3
DennyY
Member
 
Registered: May 2018
Location: San Francisco, CA
Distribution: CentOS 7
Posts: 77

Original Poster
Rep: Reputation: 1
Question script + jenkins issue

Quote:
Originally Posted by pan64 View Post
usually that means the script is not executable, or the shebang points to an invalid (nonexistent) interpreter.
Hello.... thanks for the info.

The script is executable, both in terminal and inside the container:

Quote:
jenkins@1cc6d36bf4d5:/tmp$ ./script.sh john doe true
hello, john doe

But I don't understand what you mean by shebang may point to an invalid interpreter. Is this referring to my port number issue?

Thanks again ~

Last edited by DennyY; 05-31-2019 at 05:59 PM. Reason: typo
 
Old 06-01-2019, 01:03 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,708

Rep: Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803
no, I was speaking about: /tmp/jenkins6161673403768114483.sh: line 2: /tmp/script.sh: No such file or directory
https://en.wikipedia.org/wiki/Shebang_(Unix)
 
Old 06-01-2019, 06:35 PM   #5
DennyY
Member
 
Registered: May 2018
Location: San Francisco, CA
Distribution: CentOS 7
Posts: 77

Original Poster
Rep: Reputation: 1
Question script + jenkins issue

Quote:
Originally Posted by pan64 View Post
no, I was speaking about: /tmp/jenkins6161673403768114483.sh: line 2: /tmp/script.sh: No such file or directory
https://en.wikipedia.org/wiki/Shebang_(Unix)
Sorry to bother you again..... so I tried this way, but it gave me the same error message. Sorry, this is my learning curve.

Quote:
jenkins@1cc6d36bf4d5:/tmp/script.sh $FIRST_NAME $LAST_NAME $SHOW
Quote:
Building in workspace /var/lib/jenkins/workspace/my-first-job
[my-first-job] $ /bin/sh -xe /tmp/jenkins7768987608266287086.sh
+ jenkins@1cc6d36bf4d5:/tmp/script.sh Alex Smith true
/tmp/jenkins7768987608266287086.sh: line 2: jenkins@1cc6d36bf4d5:/tmp/script.sh: No such file or directory
Build step 'Execute shell' marked build as failure
Finished: FAILURE
What else can I try?

Thanks again
 
Old 06-01-2019, 06:43 PM   #6
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.8.2003
Posts: 4,869

Rep: Reputation: 1787Reputation: 1787Reputation: 1787Reputation: 1787Reputation: 1787Reputation: 1787Reputation: 1787Reputation: 1787Reputation: 1787Reputation: 1787Reputation: 1787
There's an error on line 2 of the script. Yes?
What's on line 2 of the script?...also, what's on line 1, since interpreters and compilers can get confused about line numbers.

Maybe post the first five lines of the script?
 
Old 06-01-2019, 07:18 PM   #7
DennyY
Member
 
Registered: May 2018
Location: San Francisco, CA
Distribution: CentOS 7
Posts: 77

Original Poster
Rep: Reputation: 1
Question script + jenkins issue

Quote:
Originally Posted by scasey View Post
There's an error on line 2 of the script. Yes?
What's on line 2 of the script?...also, what's on line 1, since interpreters and compilers can get confused about line numbers.

Maybe post the first five lines of the script?
hi casey..... here is the original script, and I can execute the script without any errors. I THINK somehow my jenkins can't see my container, but have no clues how to solve it.

Quote:
#!/bin/bash

FIRST_NAME=$1
LAST_NAME=$2
SHOW=$3

if [[ $SHOW = "true" ]]; then
echo "hello, $FIRST_NAME $LAST_NAME"
else
echo "If you want to see the name, please mark the show option"
fi

Quote:
[denny@linux jenkins-data]$ ./script.sh john doe
If you want to see the name, please mark the show option
Quote:
[denny@linux jenkins-data]$ ./script.sh john doe true
hello, john doe

Quote:
[denny@linux jenkins-data]$ ./script.sh john doe false
If you want to see the name, please mark the show option
And this is executed inside the container:

Quote:
jenkins@1cc6d36bf4d5:/tmp$ ./script.sh john doe true
hello, john doe

And this is my docker-compose.yml file:

Quote:
version: '3'
services:
jenkins:
container_name: jenkins
image: jenkins/jenkins
ports:
- "8008:8008" ### but my jenkins browers now is http://192.168.1.113:8080/
volumes:
- "$PWD/jenkins_home:/var/jenkins_home"
networks:
- net
networks:
net:

thanks again.....
 
Old 06-02-2019, 03:35 AM   #8
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,708

Rep: Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803
What you posted is insufficient, so I can only guess:
1. you have a script in the jenkins job which should start this script.sh. You need to post that code too.
2. instead of jenkins@1cc6d36bf4d5:/tmp/script.sh you need to specify only /tmp/script.sh in that script.
3. if you want to execute something inside docker you need to specify a node in jenkins (which is the dockerized environment) and define an executor on that node (and use that executor when you configure your job).
4. if you want to start docker and run script within your jenkins job you need to execute this job on the host and use something like docker run .....

But again, please tell us how is your job configured and also the other relevant details (like node, executor and docker configuration).
 
Old 06-02-2019, 03:09 PM   #9
DennyY
Member
 
Registered: May 2018
Location: San Francisco, CA
Distribution: CentOS 7
Posts: 77

Original Poster
Rep: Reputation: 1
Angry script + jenkins issue

Quote:
Originally Posted by pan64 View Post
What you posted is insufficient, so I can only guess:
1. you have a script in the jenkins job which should start this script.sh. You need to post that code too.
2. instead of jenkins@1cc6d36bf4d5:/tmp/script.sh you need to specify only /tmp/script.sh in that script.
3. if you want to execute something inside docker you need to specify a node in jenkins (which is the dockerized environment) and define an executor on that node (and use that executor when you configure your job).
4. if you want to start docker and run script within your jenkins job you need to execute this job on the host and use something like docker run .....

But again, please tell us how is your job configured and also the other relevant details (like node, executor and docker configuration).
hi again..... thanks again for your time.

so this is my configuration now:

Quote:
version: '3'
services:
jenkins:
container_name: jenkins
image: jenkins/jenkins
ports:
- "8008:8008" ### but my browser now says http://192.168.1.113:8080/
volumes:
- "$PWD/jenkins_home:/var/jenkins_home"
networks:
- net
networks:
net:
when I execute this script outside of the container, it works:

Quote:
[denny@linux jenkins-data]$ ./script.sh john wick true
hello, john wick
when I execute this script inside the container, it also works:

[denny@linux jenkins-data]$ docker exec -ti jenkins bash

Quote:
jenkins@1cc6d36bf4d5:/tmp$ ./script.sh john wick true
hello, john wick
but it failes inside my jenkins.... this is inside my build command option, with parameters and boolean option specified:

Quote:
/tmp/script.sh $FIRST_NAME $LAST_NAME $SHOW
And this is the error message ......just can't seem to locate my file.....

Quote:
Started by user Denny Yang
Building in workspace /var/lib/jenkins/workspace/my-first-job
[my-first-job] $ /bin/sh -xe /tmp/jenkins8956354125154299112.sh
+ /tmp/script.sh Denny Doe true
/tmp/jenkins8956354125154299112.sh: line 2: /tmp/script.sh: No such file or directory
Build step 'Execute shell' marked build as failure
Finished: FAILURE
I know you mentioned about jenkins node, but I have no clue where to locate it.

Thanks again, and trust appreciat your time helping me with this....
-Denny
 
Old 06-03-2019, 12:44 AM   #10
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,708

Rep: Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803Reputation: 4803
so again, would be nice to know how is that jenkins job was configured.
Please do not repeat what you have already posted.
 
1 members found this post helpful.
Old 06-06-2019, 10:47 AM   #11
DennyY
Member
 
Registered: May 2018
Location: San Francisco, CA
Distribution: CentOS 7
Posts: 77

Original Poster
Rep: Reputation: 1
Thumbs up Jenkins + Docker issue

Quote:
Originally Posted by pan64 View Post
so again, would be nice to know how is that Jenkins job was configured.
Please do not repeat what you have already posted.
Please accept my apologies...... I can't believe how I could miss "Configure System" in Jenkins. After I checked, I noticed that the IP listed on there wasn't the same as shown on my browser. So the script worked after I edit the IP address. I guess I was too focused on what was in "Manage Jenkins", and that specific build. But then again, no excuses....

Thanks again for all of your help~

And now, another issue came up last night..... trying to solve it now... lol
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Jenkins All-In With Docker Containers to Enhance DevOps Workflow LXer Syndicated Linux News 0 06-20-2015 11:14 AM
Jenkins with Vagrant issue sathya_css Linux - Server 0 05-07-2015 05:44 PM
Where did the Jenkins in Jenkins CI come from? vmccord General 2 10-13-2014 02:10 PM
LXer: Docker Founder Explains What Docker is all About LXer Syndicated Linux News 0 08-21-2014 09:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration