The problem
I'm trying to build my application in Jenkins, and it is on a private repo on Github, also there's a private submodule.
I can clone the private repository in Jenkins by setting up it's credentials, but Jenkins can't clone the submodule, here's the output of a failed build:
Started by an SCM change
Building in workspace /var/lib/jenkins/jobs/Project/workspace
Fetching changes from the remote Git repository
Fetching upstream changes from git#github.com:user/repogit
using GIT_SSH to set credentials
Checking out Revision 9cc99b67cc676d0ea8ccd489a8327f5c6dbb8d7f (origin/branch)
[workspace] $ /bin/sh -xe /tmp/hudson2710403018107019432.sh
+ git submodule update --init --recursive
Initialized empty Git repository in /var/lib/jenkins/jobs/repository/submodule/.git/
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
Clone of 'git#github.com:user/submodule.git' into submodule path 'repository/submodule/' failed
Build step 'Execute shell' marked build as failure
Discard old builds...
#156 is removed because status FAILURE is not to be kept
Publishing Clover coverage report...
No Clover report will be published due to a Build Failure
Sending e-mails to:
Finished: FAILURE
Here's what I've tried to do in Jenkins
Tried to set the Additional behavior "Advanced sub-module behavior", with no success.
Tried to set up a new step before running the tests with phpunit:
git submodule update --init --recursive
Tried to set a git repository on the project of my submodule too, not just the main repository that is being tested, no luck too.
All of them causes the error that says that Jenkins can't find the repository of the submodule.
Any ideas of how can I solve this?
(The username, paths and repositories are correct, I've just changed them to post here)
Solved. In my credential I was using a direct SSH key (option "Enter directly"), instead of putting into a file.
I've just put the keys (public and private) in ~/.ssh, and changed my credentials to the option "From the Jenkins master ~/.ssh".
The problem was that the submodule wasn't using the credential that I've specified to the main repository, it was trying to use the default ssh key (.ssh/id_rsa).
Another solution is to pass -i my_key to the git submodule step (only need this if your key isn't in the default path (~/.ssh/id_rsa) )
Also don't forget to give the correct permissions to your keys, in my case I had to:
chown apache ~/.ssh/id_rsa*
chmod 700 ~/.ssh/id_rsa*
Related
I'm new to Git. i have everything worked before. but the problem came when i try to follow some tutorials regarding .gitignore not woking. Finally i used git clearcache but now i'm getting other error
I used :
git add .
git commit -m "testing gitignore"
git push origin arabic
Error :
You have both vendor/kartik-v/bootstrap-fileinput and vendor/kartik-v/bootstrap-fileinput/.github/CODE_OF_CONDUCT.md
You have both vendor/kartik-v/dependent-dropdown and vendor/kartik-v/dependent-dropdown/.github/CONTRIBUTING.md
You have both vendor/kartik-v/strength-meter and vendor/kartik-v/strength-meter/.github/CONTRIBUTING.md
You have both vendor/kartik-v/yii2-krajee-base and vendor/kartik-v/yii2-krajee-base/.github/CONTRIBUTING.md
You have both vendor/kartik-v/yii2-password and vendor/kartik-v/yii2-password/.github/CONTRIBUTING.md
You have both vendor/kartik-v/yii2-widget-datepicker and vendor/kartik-v/yii2-widget-datepicker/.github/CONTRIBUTING.md
You have both vendor/kartik-v/yii2-widget-depdrop and vendor/kartik-v/yii2-widget-depdrop/.github/CONTRIBUTING.md
You have both vendor/kartik-v/yii2-widget-fileinput and vendor/kartik-v/yii2-widget-fileinput/.github/CONTRIBUTING.md
You have both vendor/kartik-v/yii2-widget-select2 and vendor/kartik-v/yii2-widget-select2/.github/CODE_OF_CONDUCT.md
You have both vendor/kartik-v/yii2-widget-typeahead and vendor/kartik-v/yii2-widget-typeahead/.github/CONTRIBUTING.md
...
error: Error building trees
How i can fix this error ?
I'm unable to push to my repository now.
git clearcache is not a Git command. (Where did you get it?)
The error message suggests that whatever this git clearcache program is, it damaged Git's index. If you don't mind losing the effect of your git add ., you can re-build the index, then re-do the git add, using these basic shell commands:
rm .git/index
git reset
git add .
(this assumes you are at the top level of your repository, so that .git/index names Git's index file). Removing the file and running git reset rebuilds the index from the current commit, destroying the effect of all previous git add and/or git rm commands.
If git clearcache contains such commands, this will also undo its operations, but it looks like that may be necessary.
I had an issue where the directory on windows was in read-only mode
Click properties
Then if read-only is selected - de-select it and hit apply or ok. Next, you should close your IDE and then re-open it and try to make a new commit.
I'm pretty new to Git. I'm developing using PHP/Laravel on at least two machines; both Windows 10, let's call them office and home. I want to keep a sync environment on both. So I created an account on BitBucket.
I created my Laravel app using Laragon using the directory: d:\laragon\www\project
I created a clean remote repo in BitBucket and configured for use on the office PC, inside the project directory:
git init
git remote add origin https://...
git add .
git commit master
git push -u origin master
It copies some of the files to the remote repository. I understand this is because of the .gitignore file, and that's okay.
Now the thing is if I go to my home PC and do a:
git clone http://...
It will only get the non-ignored files. My question is, how do I have to configure the second development environment?
I tried to create a new app at the home's c:\laragon\www\project and then try to clone in this directory, but of course it says the directory is not empty, so does nothing.
Do I have to delete the .gitignore file the first time, so it syncs everything?
I'm assuming that you already have your second machine with the basic set up (php, composer, laravel, local server, node and so on..)
First of all you need to install your composer dependencies (listed in composer.json), to accomplish this run:
composer install
The .gitignore will only ignore.. well.. the desired ignored files, such as: node_modules and .env for example. To solve this, install your dependencies (listed in your package.json, that is not ignored by default) in your second machine using npm or yarn:
npm install
// or
yarn install
In the case of your .env file, I suggest you to clone the .env.example (creating the desired .env) and set your keys in every machine, because any of them can have a different setup.
Of course, your Laravel encryption key needs to be generated, so run:
php artisan key:generate
Finally, migrate your database (and populate it, in case you set up seeders) like this:
php artisan migrate --seed
// notice the '--seed' flag is used when you want to run your seeders
I have just begun learning the basics of Git.
I have installed Git locally and successfully integrated it to clone repos into my xampps/htdocs.
Now locally, in this repo I have moved all the files into the php_Basics folder. But when I try and commit to sync up with my GitHub repo it says no changes added to commit.
How do I commit the file restructure, and sync it to the GitHub repo?
Source:Reference
Details about github
Checklist------------------------------------
Move files to git cloned repository if not use git init then move files
configure git username
check status --- git status you will see changed files
git add file to staging for commit
git commit
git push
Note: if the editor for the commit message is finicky, you can start with a shorter commit message in command line:
cd /path/to/local/repo
git add .
git commit -m "my message"
git push -u origin master
I'm trying do to the following:
1) Create a new laravel project using:
sudo composer create-project laravel/laravel /var/www/html/laravel5`
2) Overwrite only the different files from github. I want to keep the following files and folders unchanged:
.env
.env.example
.gitattributes
.gitignore
vendor/
Clone from github is not working because the folder is not empty.
The only workaround that I found is:
create a new project
copy the files and folders that I want to another folder
clone the project from github
copy the files back to the folder
I'm using Xubuntu, Laravel 5.0 and Github.
Thanks in advance.
You should be able to do this via an all-git method rather than copy/paste from another directory. (I'm not sure why your workaround is a bad solution, though.)
The basic plan is:
Create a repository.
Checkout some bogus branch that you won't keep around.
Add the directories you want to keep to the index and commit them.
Force a checkout to the branch you want. It probably will need forcing because of the other things you didn't just commit.
Apply the patch of the recently created commit to your working directory.
And in commands:
cd /path/to/repo
git init
git branch temp-branch
git add .env && git add .env.example && git add .gitattributes && git add .gitignore && git add vendor/
git commit -m "Sustain Local Changes"
git remote add origin https://github.com/owner/repo
git fetch
git checkout -f master # Should detect origin/master. If it doesn't, just set a branch up manually. Replace master if that's not the branch you want.
git merge --no-commit --no-ff temp-branch
Personally, I find this a lot more ugly than your workaround.
I've created my own site on my local computer and it works wonderfully. I'm having tons of fun developing with it. But when it came time to move it to my server and test I ran into issue.
I'm using the FOSUserBundle. Obviously being a Git of it's own, when I did a git commit and push, git ignored everything in vendor/friendsofsymfony/user-bundle. So when I cloned to my server, the folder came empty, and of course now my site doesn't work.
I want to do this the right way. So if it means destroying the git repo and doing it a different way, I'm ok with that.
So far I've tried.
Following the original install instructions for FOSUserBundle
Running the following:
composer update friendsofsymfony/user-bundle
composer install friendsofsymfony/user-bundle
Both return "nothing to update/install"
I've also tried clearing composer's cache between each command attempt.
rm -rf ~/.composer/cache
Answer is in the comments. Ignore vendor/ use composer to install the appropriate files.
also this Symfony project cloned with git vendors not installed
What it sounds like your trying to do is create a mywebsite parent repo within which you have a third party child repo that has the FOSUserBundle code. This uses git submodules and requires related submodule commands like git submodule init.
The ... directory is there, but empty. You must run two commands: git submodule init to initialize your local configuration file, and git submodule update to fetch all the data from that project and check out the appropriate commit listed in your superproject...
I don't know anything about composer. Here is how you could do it with git.
cd mywebsite
git init
git submodule add <url-to-FOSUserBundle-repo>
You should now have a directory structure like this:
mywebsite
.git
.gitmodules
FOSUserBunder
.git
See also http://git-scm.com/book/en/v2/Git-Tools-Submodules