singh
(Navdeep Singh)
August 4, 2022, 11:20am
1
So I was trying to deploy a simple CD pipeline using docker by ssh’ing into my AWS Linux EC2 instance in WSL2 terminal. The job is failing everytime returning the following error:
Started by user Navdeep Singh Running as SYSTEM Building on the built-in node in workspace /var/lib/jenkins/workspace/todo-dev [todo-dev] $ /bin/sh -xe /tmp/jenkins6737039323529850559.sh + cd /home/ubuntu/project/django-todo /tmp/jenkins6737039323529850559.sh: 2: cd: can’t cd to /home/ubuntu/project/django-todo Build step ‘Execute shell’ marked build as failure Finished: FAILURE
Config:
DockerFile contents:
FROM python:3
RUN pip install django==3.2
COPY . .
RUN python manage.py migrate
CMD [“python”,“manage.py”,“runserver”,“0.0.0.0:8000”]
halkeye
(Gavin Mogan)
August 4, 2022, 3:22pm
2
Where are you doing the ssh part? It’s saying /home/ubuntu/project/django-todo isn’t available on the agent (built-in node
so controller).
I think you are missing the ssh part
You’ll probably want something like shell - SSH heredoc: bash prompt - Stack Overflow to run multiple commands over a single ssh session
singh
(Navdeep Singh)
August 6, 2022, 10:13am
3
On my WSL2 terminal. SSHing into my Amazon Linux machine from there. Actually what I did was following exactly these steps to deploy my first Jenkins job.
halkeye
(Gavin Mogan)
August 6, 2022, 4:01pm
4
Okay but you are not sshing at all in your job. Are you wanting to?
In my previous reply I told you what was wrong and at least one idea how to fix it. Do those not work? Do you need more help?
@halkeye could you please guide on further on these steps as I am facing the same problem.
I have launched AWS EC2, i am connecting to ubuntu server using putty and then I am using Jenkins to do Continues deployment part.
I have created a freestyle project, created a job with below build config steps:
cd /home/ubuntu/projects/django-todo
sudo docker build . -t todo-dev1
sudo docker run -d -p 8000:8000 todo-dev1
safaira
(Saniya Shaikh)
November 23, 2022, 6:44am
6
In my case, I solved this issue by doing following things.
Jenkins need root user password.
edit /etc/sudoers fille
go to /etc
do sudo visudo
add jenkins ALL=(ALL) NOPASSWD: ALL at bottom.
and make sure port 8000 is not occupied.
Hope, this will help you
Cero
December 30, 2022, 11:18am
7
I tried the above steps as well but still it is not working.
Pravab
(Pravab Kar)
February 26, 2023, 5:59pm
8
I think this problem is arising because you are using Jenkins in a Docker container. So the job steps are taking place inside the container.
To fix this, you can remove the container and manually install Jenkins in your ubuntu instance.
To Stop and Remove the Container
sudo docker stop [CONTAINER_ID]
sudo docker rm [CONTAINER_ID]
To Install Jenkins Manually
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key |sudo gpg --dearmor -o /usr/share/keyrings/jenkins.gpg
sudo sh -c 'echo deb [signed-by=/usr/share/keyrings/jenkins.gpg] http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt update
sudo apt install jenkins
Start Jenkins
sudo systemctl start jenkins.service
Then once more create the job and it should work fine.
hassanhah
(Syed hassan ali shah)
March 14, 2024, 6:45pm
9
this method is also not working