I have my website hosted on Digital Ocean and my repo on gitlab. I do not have an instance of gitlab installed on my Digital Ocean Server. I am just using the .gitlab-ci.yml file.
In my CI script, I ssh into digital ocean, CD into my project and attempt to pull the latest code.
I have also generated an ssh key on the digital ocean server and added it to my ssh-keys on Gitlab.
I'm not sure if there is a firewall that I can't get past or something.
unfortunately, it errors out with this error.
Running with gitlab-ci-multi-runner 1.9.0 (82714ae)
Using Docker executor with image ruby:2.1 ...
Pulling docker image ruby:2.1 ...
Running on runner-4e4528ca-project-1209495-concurrent-0 via runner- 4e4528ca-machine-1484021348-29523945-digital-ocean-4gb...
Cloning repository...
Cloning into '/builds/Rchampin/ryan_the_developer_django'...
Checking out b3783fbf as master...
$ ssh root#myIP
Pseudo-terminal will not be allocated because stdin is not a terminal.
Host key verification failed.
ERROR: Build failed: exit code 1
Here is my CI script.
before_script:
- ssh root#myIP
- cd /home/rchampin/ryan_the_developer_django
pull:
script:
- git pull
You have some optinos to try in this question
ssh -t -t
# or
ssh -T
That should avoid requesting a pseudo terminal.
Related
I am trying to do ssh to an ec2 instance through Jenkins pipeline,using a pem file present on my local system, but I am unable to connect to ec2 instance.
ssh command
ssh -i test.pem -o StrictHostKeyChecking=no ubuntu#ip -p22
I am to able to connect to aws instance through my local machine. I am running jenkins pipeline on master node only. is there any issue with the user of pem file as the username is ubuntu for the pem file not as jenkins?
I am able to resolve this issue by installing the ssh agent plugin in jenkins. After installing ssh agent plugin we need to configure server details under Manage Jenkins -> Manage Credential. Here we need to give the host name, user and passkey which would be your pem file.
While adding the ssh agent into your jenkins pipeline script, one can follow the below approach.
sshagent(credentials : ['id_name_added_underManageCredential']){
sh "ssh command"
}
I'm using Gitlab and Docker to get continuous integration to my spring boot application and I'm getting this error:
Cannot connect to the Docker daemon at tcp://xxx.xxx.xx.xxx:2375. Is the docker daemon running?
.development.env:
export SPRING_ACTIVE_PROFILE='development'
export DOCKER_REPO='DOCKER_HUB_ID/app_name:dev'
export APP_NAME='app_name_dev'
export PORT='8080'
export SERVER_IP='xxx.xxx.xx.xxx' #SERVER_IP
export SERVER_SSH_KEY="$DEV_SSH_PRIVATE_KEY"
export DOCKER_HOST='tcp://xxx.xxx.xx.xxx:2375' #SERVER_IP
.gitlab-ci.yml
services:
- docker:19.03.7-dind
stages:
- build and push docker image
docker build:
image: docker:stable
stage: build and push docker image
before_script:
- source .${CI_COMMIT_REF_NAME}.env #.development.env
script:
- docker build --build-arg SPRING_ACTIVE_PROFILE=$SPRING_ACTIVE_PROFILE -t $DOCKER_REPO .
- docker login -u $DOCKER_USER -p $DOCKER_PASSWORD docker.io
- docker push $DOCKER_REPO
This is the whole logs from gitlab:
Running with gitlab-runner 13.5.0 (ece86343)
on gitlab-server JuhWVkPJ
Preparing the "docker" executor
00:38
Using Docker executor with image docker:stable ...
Starting service docker:19.03.7-dind ...
Pulling docker image docker:19.03.7-dind ...
Using docker image sha256:14af3ba31e635475ec8f7fbe17470424514777621e627a91c41bbbe028dbae16 for docker:19.03.7-dind with digest docker#sha256:2683fcdf7480ea101415833f7793fb058c5f20227890a953b0a70bfc350af5bc ...
Waiting for services to be up and running...
*** WARNING: Service runner-juhwvkpj-project-13-concurrent-0-7c99eb8ace2e2ae6-docker-0 probably didn't start properly.
Health check error:
service "runner-juhwvkpj-project-13-concurrent-0-7c99eb8ace2e2ae6-docker-0-wait-for-service" timeout
Health check container logs:
Service container logs:
2020-12-30T03:14:07.879506461Z Generating RSA private key, 4096 bit long modulus (2 primes)
2020-12-30T03:14:08.459745140Z ..............................................++++
2020-12-30T03:14:08.673203110Z ..................++++
2020-12-30T03:14:08.673231544Z e is 65537 (0x010001)
2020-12-30T03:14:08.713960023Z Generating RSA private key, 4096 bit long modulus (2 primes)
2020-12-30T03:14:08.851463609Z ..............++++
2020-12-30T03:14:09.403244538Z .....................................................++++
2020-12-30T03:14:09.403286293Z e is 65537 (0x010001)
2020-12-30T03:14:09.516423752Z Signature ok
2020-12-30T03:14:09.516463300Z subject=CN = docker:dind server
2020-12-30T03:14:09.516471290Z Getting CA Private Key
2020-12-30T03:14:09.536975767Z /certs/server/cert.pem: OK
2020-12-30T03:14:09.553642146Z Generating RSA private key, 4096 bit long modulus (2 primes)
2020-12-30T03:14:09.927078677Z ...................................................++++
2020-12-30T03:14:10.107451624Z ...................++++
2020-12-30T03:14:10.108457646Z e is 65537 (0x010001)
2020-12-30T03:14:10.156096074Z Signature ok
2020-12-30T03:14:10.156125397Z subject=CN = docker:dind client
2020-12-30T03:14:10.156302268Z Getting CA Private Key
2020-12-30T03:14:10.178703934Z /certs/client/cert.pem: OK
2020-12-30T03:14:10.194290163Z mount: permission denied (are you root?)
2020-12-30T03:14:10.194438175Z Could not mount /sys/kernel/security.
2020-12-30T03:14:10.194456604Z AppArmor detection and --privileged mode might break.
2020-12-30T03:14:10.195933829Z mount: permission denied (are you root?)
*********
Pulling docker image docker:stable ...
Using docker image sha256:b0757c55a1fdbb59c378fd34dde3e12bd25f68094dd69546cf5ca00ddbaa7a33 for docker:stable with digest docker#sha256:fd4d028713fd05a1fb896412805daed82c4a0cc84331d8dad00cb596d7ce3e3a ...
Preparing environment
00:01
Running on runner-juhwvkpj-project-13-concurrent-0 via gitlab-server...
Getting source from Git repository
00:03
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/abdallah/harvis/.git/
Checking out 5568bbc9 as DM_Module...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:36
$ source .${CI_COMMIT_REF_NAME}.env
$ whoami
root
$ docker build --build-arg SPRING_ACTIVE_PROFILE=$SPRING_ACTIVE_PROFILE -t $DOCKER_REPO .
Cannot connect to the Docker daemon at tcp://xxx.xxx.xx.xxx:2375. Is the docker daemon running?
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1
I think the error is in DOCKER_HOST, what should I assign it?
I'd appreciate any help or suggestion.
The Docker daemon can listen for Docker Engine API requests via three different types of Socket: unix, tcp, and fd
your docker daemon is trying to connect via tcp (2375), and it seems not enabled.
you need to start docker daemon with -H tcp://<ip>:2375
or put it in /etc/docker/daemon.json
"hosts": ["tcp://<ip>:2375", "unix:///var/run/docker.sock"],
EDIT
Binding to 0.0.0.0 is dangerous as David pointed out.
I'd like to have a section like this in my docker-compose.yml file:
services:
thing:
build: git#server.company.com/path/to/project.git
Then I'd like to build it with docker-compose build thing
But when I try that it fails with
ERROR: error fetching: fatal: 'git#server.company.com/path/to/project.git' does not appear to be a git repository
fatal: Could not read from remote repository.
Presumably it's failing because it needs my ssh keys to access the repository and the docker daemon is running in a linux VM which doesn't have access to my keys.
How can I pass a ssh key, or an ssh agent socket to the docker daemon so it can access a private repository?
i am trying to deploy laravel 5.4 app with bitbucket pipeline and get eror
"fatal: Could not get last commit. Network down? Wrong URL? Use 'git ftp init' for the inital push., exiting..."
i read an article on this site
i create this yaml file
image: samueldebruyn/debian-git
pipelines:
default:
- step:
script:
- apt-get update
- apt-get -qq install git-ftp
- git ftp push --user $FTP_USERNAME --passwd $FTP_PASSWORD ftp://site.com
and got eror
git ftp push --user $FTP_USERNAME --passwd $FTP_PASSWORD site_url
fatal: Could not get last commit. Network down? Wrong URL? Use 'git ftp init' for the inital push., exiting...
some hosting provider don't allow external app and block all port just open 80 and 4 more for ftp ssl and ssh if you want to deploy your laravel in share hosting just upload all your data to root except public folder and than upload all data of public folder to your index folder www or public_html
here is screenshot of example
I have a local git repository which I am trying to clone onto a vagrant machine. I'm trying to use ansible's "git" module to do this, I have the following task,
- name: Clone repository
git: repo=git://../.git dest=/home/vagrant/source accept_hostkey=True
When I run this task I receive the error,
failed: [webserver] => {"cmd": "/usr/bin/git ls-remote git://../.git -h refs/heads/HEAD", "failed": true, "rc": 128}
stderr: fatal: unable to connect to ..:
..[0: 42.185.229.96]: errno=Connection timed out
msg: fatal: unable to connect to ..:
..[0: 42.185.229.96]: errno=Connection timed out
FATAL: all hosts have already failed -- aborting
It looks like it's trying to find the repository on my VM rather than on my local machine? How to I clone from my local repo?
The git module executes completely inside the VM- you have to give it a path that's reachable by the VM. Either do a vagrant NFS shared/synced folder with your host, or expose it to the VM over the network via http/ssh. Be aware that non-NFS shared folders in vagrant with Virtualbox (and possibly other providers) just do dumb copies back and forth, not true "sharing" (ie, depending on how big your repo is, you might be sorry if it's not NFS).
The git commands will be run from the remote machine, in this case your Vagrant VM, not your local machine.
One way to accomplish this is through SSH remote port forwarding. You can forward connections from a port on the remote (Vagrant VM) to a host+port from your local machine.
Your local machine needs to make the git repository available. This can be done with sshd, but I will use the relatively obscure git-daemon, as it is easier to set up.
In your Ansible inventory file, add the following options to your Vagrant VM host. This will forward requests from your remote machine on port 9418 to your local machine at port 9418 (git-daemon) for the duration of the connection.
# inventory
webserver ansible_ssh_extra_args="-R 9418:localhost:9418"
# *OR* for a group of hosts
[webservers:vars]
ansible_ssh_extra_args="-R 9418:localhost:9418"
For this example, I will assume the GIT_DIR on your local machine is located at /home/you/repos/your-git-repo/.git. Before running your Ansible playbook, start the following command in another terminal (add a --verbose option if you want to see output):
git daemon \
--listen=127.0.0.1 \
--export-all \
--base-path=/home/you/repos \
/home/you/repos/your-git-repo/.git
Your task would look like this:
- git: repo=git://localhost/your-git-repo dest=/home/vagrant/source
Now when git connects to localhost (relative to your Vagrant VM), requests are forwarded to the git daemon running on your local machine.