Gitlab CI can't clone gitlab repo - token

Has anybody has same problem?
I connected Gitlab ci with Gitlab. When test run Gitlab CI can't clone Gitlabs repo.
Got this error:
cd /home/gitlab_ci_runner/gitlab-ci-runner/tmp/builds && git clone http://gitlab-ci-token:
<mytoken>#gitlab.xlab.si/primoz_godec/scrum_app.git project-3 && cd project-3 && git checkout
<othertoken>
Cloning into 'project-3'...
fatal: protocol error: bad line length 8188

Problem was that http clone has been disabled on Gitlab. After enabling it everything was ok.

Related

Detected dubious ownership in repository GILAB CI/CD

I am facing this issue during try to deploy script with gitlab ci/cd:
Initialized empty Git repository in C:/builds/Tri.BuiV/test-gitlab-cicd/.git/
fatal: detected dubious ownership in repository at 'C:/builds/Tri.BuiV/test-gitlab-cicd'
'C:/builds/Tri.BuiV/test-gitlab-cicd' is owned by:
'S-1-5-83-1-1989435290-1148643240-1709935003-3943614564'
but the current user is:
'S-1-5-93-2-1'
To add an exception for this directory, call:
git config --global --add safe.directory C:/builds/Tri.BuiV/test-gitlab-cicd
I tried:
git config --global --add safe.directory C:/builds/Tri.BuiV/test-gitlab-cicd
But the same error, why?
I tried:
git config --global --add safe.directory C:/builds/Tri.BuiV/test-gitlab-cicd
But get the same issue.
If the error persist, it probably means your git config --global (which impacts %USERPROFILE%\.gitconfig) does not use the same account as the one running your GitLab CICD.
If GitLab runs with a different account, it might try to access folder initially created by you.
The GitLab pipeline itself would need to include
git config --global --add safe.directory $CI_PROJECT_DIR
This i what is being automatically added for GitLab 15.8 in MR 3538.

How to run git clone command in a pipeline step LFS enabled

I've a pipeline that is cloning another repository. Pipeline below is running on yyy repository, and it's supposed to clone xxx repository and do some work on it, then upload the results to AWS S3, I have lots of object to be worked on, so git clone step should be LFS enabled. git lfs client is configured on my base image. LFS is also enabled on my xxx repository. My deployment consumes so much time to clone repo with LFS enabled.
- step:
name: "Pipeline"
services:
- docker
caches:
- docker
script:
- ...
- ...
- ...
- ...
- git clone git#bitbucket.org:xxx.git
I've tried
clone:
lfs: true
option to reduce the consumed time but it seems it doesn't work with the setup above.
How can I reduce time consumption for this setup? Is there any workaround here?
Thank you.
It can be a little bit weird but I came up with the solution below,
I gave
clone:
enabled: false
in the pipeline, and I cloned the repo in the script part. Because my repo is huge, I limited everything to consume less time.
git clone git#bitbucket.org:xxx/<repo-name>.git --depth 1 --no-tags --single-branch -b <branch> --no-checkout .
It's working like a charm :)

Git clone not working on EC2 for a Jenkins pipeline

I am running a CI/CD pipeline as a test in Jenkins. The first task in this pipeline it to clone a repository
I am getting an error that says
cd /var/lib/jenkins/workspace/MyProjectPipeline-Dev/docker/apache
/var/lib/jenkins/workspace/MyProjectPipeline-Dev#tmp/durable-2f74d056/script.sh: line 9: cd: /var/lib/jenkins/workspace/MyProjectPipeline-Dev/docker/apache: No such file or directory
This pipeline is set up on an AWS EC2 instance. I installed git on this instance so I dont know why the clone isnt working.
Here is the log for the pipeline:
Because when you clone a git hub repo with git clone https://github.com/subsari/snippets.git it clones it into a directory snippets, so your docker/apache directory is actually inside the /var/lib/jenkins/workspace/MyProjectPipeline-Dev/snippets/
You need to cd as
cd /var/lib/jenkins/workspace/MyProjectPipeline-Dev/snippets/docker/apache
or you can also use the dir in your Jenkinsfile sa
dir("snippets/docker/apache"){
sh "pwd"
sh './script.sh'
}

How to checkout a private repo using Carthage?

I am trying to checkout a branch from our organization github repo using Carthage but it fails with error message
Cartfile
git "ssh://git#github.com:orginaztion/repo.git" "branch"
In command line
carthage checkout --use-submodules --use-ssh
Error message:
A shell task (/usr/bin/env git fetch --prune --quiet ssh://git#github.com/orginaztion/repo.git refs/tags/*:refs/tags/* +refs/heads/*:refs/heads/* (launched in /var/root/Library/Caches/org.carthage.CarthageKit/dependencies/repo)) failed with exit code 1
Am I doing something wrong here ?

Travis CI loading private submodule

At the moment I'm troubling with Travis-CI Pro and a private submodule.
This is some travis.yml code I've found, the $GIT_USER and $GIT_TOKEN envs are set in travis settings.
git:
submodules: false
before_install:
- sed -i 's/git#github.com:/https:\/\/$GIT_USER:$GIT_TOKEN#github.com\//' .gitmodules
- git submodule update --init --recursive
During the build process I get the following error:
$ sed -i 's/git#github.com:/https:\/\/$GIT_USER:$GIT_TOKEN#github.com\//' .gitmodules
0.67s$ git submodule update --init --recursive
Submodule 'ro-realm' (https://github.com/[secure]/ro-realm.git) registered for path 'ro-realm'
Cloning into '/home/travis/build/[secure]/ro-order-worker/ro-realm'...
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/[secure]/ro-realm.git/'
Thanks for your help.
I wouldn't call this a recommended solution, but how about this to fix the issue?
# Generate from github, confirm that user and token are correct
echo https://${GIT_USER}:${GIT_TOKEN}#github.com/chaconinc/DbConnector
git submodule add https://${GIT_USER}:${GIT_TOKEN}#github.com/chaconinc/DbConnector
git submodule update --init --recursive

Resources