We created a clone from the dev server for the jenkis CI to improve our work, we configurated it and the tests started working as we wanted. Then we find out that the git plugin in the jenkins is not liked with the project's workspace. It's a PHP REST api project, every server has it's own configuration. So we gave to the jenkins the path of the project to use that - this is the "Checkout to a sub-directiory" option. Then when a new PR is created, then jenkins is tiggered and it's start the build, and at first it's trying to delete the complete workspace.
I wouldn't think that it would be impossible to run tests on an already existing project with the jenkins, but this is ablosutly not the way how to do it. Every server has it's own configurations, so those are not part of the git repo, plus there is a base installation for the framework, and that's also not part of the git repository.
Now my question is what information are we missing, and how could we configure the git pluggin to make the jenkins start working on our existing project?
Ensure that you have the GitHub plugin and Git Pull Request Plugin installed in your jenkins workspace, now all you have check these 2 option
Also note that you have to add your public in Git which you would have done I'm guessing, now a hook will be created and you can send a request from Git and if you have a green tick ALL GOOD, else you have to debug it try this link Github webhook URL config issue? How to fix it?
Related
We are working on a Magento payment module, let's call it ABC. We are using Docker for the development. So, for development, we are using a Magento image and adding the module code to the htdocs/app/code via volumes from docker-compose.yml. Our Github repo contains the module code only. We have added some tests for the module under app/code/ABC/Payment/Test folder. We want to setup a Github workflow that will run the test automatically on pull request.
The issue is some of the code depends on the Magento core classes like Magento\Framework\App\Config\ScopeConfigInterface, Magento\Store\Model\StoreManagerInterface and so on which won't be available in our Github repo. Is there any Github actions with which we can setup Magento, copy the module codes into it and run the module's tests?
Any help would be greatly appreciated. We are unable to figure this out.
You could require magento using composer within your github workflow. https://github.com/marketplace/actions/composer-php-actions
If you use grumphp (https://github.com/phpro/grumphp) you can have a look at this example: https://github.com/phpro/phpro-mage2-module-translations/blob/master/.github/workflows/grumphp.yml
You have not shared much about what precisely is making you unable to figure it out for Github Actions, however reading your question it looks to me like you already have figured out for development: Using Docker.
Now Github Actions as well supports Docker. All you need is to run the setup script for the development environment that establishes that Docker setup within the Github Action before running your tests.
You may want to add an additional environment for it, so that you can branch between the development system and Github Actions, but theoretically it should already work without.
Then after you have cloned the code, and then setup the Docker environment, execute the tests in the Github Action. The tests should run now.
I am using Laravel 5.6.
My Current Code deployment process is as follow
Made some changes to file
Commit and push it to branch.
Once everything is perfect merge it to master and pull master branch to code production server(Where my code is).
My Issue
If I have some dependencies which is maintained by composer. I just add it to current branch and made changes to other files.
When I merge it with master and pull it to production server I need to run composer update command manually.
Server gives errors when we try to access it that it dependencies class or service provider not found(As we need to add it to config/app.php in Laravel) When it is updating composer dependencies.
After updating it is working perfectly.
So I want to avoid that 5-10 sec error which comes while updating composer dependencies.
I have two options
Put Application on maintenance mode while updating code. -> I cannot do that.
Every time whenever there is dependencies upload it using two merge. -> I Don't want to do that.
Is there any other best practices solutions to this problem so that we can avoid such errors.
You should never update on the production server, just composer install. You can hook this to your merge git action, accordingly to how you deploy to production (CI/CD, scripting or all manual?). Here documentation for git hooks: https://git-scm.com/docs/githooks
this is for git-hooks post-merge: https://git-scm.com/docs/githooks#_post_merge
The best way to deploy to avoid this problem is that each time you deploy, you do so to a new folder. Then, once the deployment is complete, you switch the folder.
This could be done using a symlink, or similar:
deploys
1551270000
1551280000
live > deploys/1551280000
Then make a new deployment (1551290000):
deploys
1551270000
1551280000
1551290000
live > deploys/1551280000
Then when it’s finished, change the symlink:
deploys
1551270000
1551280000
1551290000
live > deploys/1551290000
This is what Capistrano and others do. I would recommend using a tool like that rather than trying to write your own – this problem has already been solved.
When I merge it with master and pull it to production server I need to run composer update command manually.
No you dont. You should only run
> composer install
on the live server to make sure composers dependancies are up to date with changes.
I am trying to stick this all pieces together, so I have:
Remote:
Dev server, where Http Server + DB + my site - folder, where all files of my future project will be.
Bitbucket account
Locally installed:
PhpStorm
Git
SourceTree
What would be a queue of actions to setup all this stuff to make them work together in right way?
Problems I faced:
If I first create PHP project then I can't clone repository from Bitbucket to not empty folder.
How to tie existing project to newly created repository of Bitbucket? Because usually project starts with creating some skeleton from git, so I can't start with empty project folder...
Imagine I make changes, save it to remote server, check it works, then commit it to Bitbucket then I realize I need back to code which was few commits before.
How could I roll back my project code? And then how will I update this on a remote server? Do I need delete all files and upload them again from project?
Problem 1:
Normaly you start with a local project and push it to the remote but it works also the other way round, checkout the remote repo to your computer and then copy the project files into that folder, then use SourceTree to commit and push them.
Problem 2:
You don't rollout commits, you rollout tags and branches. Best is you start with a master branch where you have everything that works 100% and when you develop and work locally you have a second branch develop for testing. When your tests and stuff in develop branch work, you merge it into the master branch. If you want to go a step further, try git-flow.
I am developing a wordpress website and it is live. I am currently using file-zilla to update my code. Until now I wasn't in need of any version control, but now it seems that I need to manage a repository as well. We have also added two freelancers in a development team. So, it becomes difficult for us to manage development of this website.
I have read several blogs and I came to a decision that I will use Git for version control. However, I am struggling to find proper steps which explain to me about setting up a development environment for a team of freelancers. Also, I got a little information about bitbucket, but I am not sure if that is necessary for me. I am looking for the best answer to get started.
(Assuming you are leaving core Wordpress files alone and working only with themes and / or plugins as is best practice:)
Create a git repository every theme and plugin that you are working on using a server of your choice: I would go with Bitbucket for free private repos that you can invite the devs to.
Since you already have the files pushed by FileZilla, you would go into each of the folders for the themes and plugins you are using and push them as existing repos using SSH like so:
First initilize the repos and commit:
$git init
$git add .
$git commit -a -m "initial commit"
Then push
$git remote add origin git#bitbucket.org:my_org/my_repo.git
$git push -u origin --all # pushes up the repo and its refs for the first time
$git push -u origin --tags # pushes up any tags
If you are editing core files as well which would be highly discouraged, then you would create just one repo for the entire Wordpress folder, and then initialize, add, commit and push as above.
Development environments would be set up by the devs themselves using the platforms of their choice. Or ask them to use Vagrant if you want them to have similar environments.
I know this has been asked before, but I couldn't get the answer I needed.
Currently I'm developing an website using PHP and was using Notepad++ before, and it all worked well because I'm developing with a co-worker so we both keep on changing different files on the FTP.
Switched to NetBeans. All went ok, pulled the entire website via FTP to my local computer and everytime I edited a file and saved it uploaded to the FTP. But, there is a problem. If my colleague updates a file, it doesn't update on my local folder. So, I thought: "Let's try versioning".
Created a team on bitbucket, created a repository. All went ok.
But now, I'm in a struggle to get everything up and running on both NetBeans (mine and colleague's) so that my colleague is editing a file on his NetBeans and constantly saving so that it gets saved on FTP and only when he stops working on that file push it to BitBucket so that I can pull after.
Suggestions?
About setting up your work environment :
In order to set up your bitbucket repository and local clone, go read this link (official doc).
You will need to repeat the cloning part once for each PC (e.g : once on yours, once on your colleague's).
Read the account management part to see how you can tag your actions with your account, and your colleague's action with his own account.
Start using your git workflow ; when you are tired of always typing your password to upload modifications to your bitbucket account, take the time to read the ssh keys setup part - read carefully, you will need to execute the procedure once for you and once for your colleague.
Using your local git repository with Netbeans is pretty straightforward :
From netbeans, run the File > New Project ... command (default: Ctrl+Shift+N),
Select PHP application with Existing Sources and click Next >,
For the Sources Folder: line, select your local git directory,
Fill the remaining fields, and if you want the last Run configuration screen, then click Finish.
After the project is created in netbeans, you can modify the Run configuration part by right clicking on the project's icon, selecting the Properties menu entry, and going to the Run configuration item.
About solving your workflow "problem" :
Your current FTP workflow can lead you to blindly squash your colleague's modifications (when uploading), or have your colleague's modification blindly squash your own local modifications (when downloading). This is bad, and you will generally notice it only after the bad stuff happened - too late.
Correctly using version control allows you to be warned when this could potentially happen, and to keep an almost infinite undo stack on the modifications of the project's files. The cost, however, is that both of you will have to add several actions in your day to day workflow - some choices can not be made automatically.
You may find it cumbersome in the beginning, but it really pays off, and quite quickly - we're talking big bucks here. So use it and learn.
On top of using Ctrl+S to save your modifications on disk, you and your colleague will need to integrate 3 extra commands in your daily work :
Save your work to your local repository (git add / git commit)
Download the latest modifications shared by your colleague (git pull)
Upload your work to the central repository (git push)
You can access these commands :
from a terminal,
from a GUI frontend : you can try TortoiseGit for windows, or gitk for linux,
from Netbeans :
in the contextual menu of the files/folders in the project tree (right click on the item, there is a "Git" entry),
using the Team > Git > ... menu
Since you provided a git tag, I'll describe what's to do for Git.
set up a remote bare repo on a server that you both could access (BitBucket in your case):
http://git-scm.com/book/en/Git-on-the-Server-Getting-Git-on-a-Server
you both clone that remote repo to your local machines:
http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository#Cloning-an-Existing-Repository
each of you works in her part of the application. When one is done, publish the work to the server:
http://git-scm.com/book/en/Git-Basics-Working-with-Remotes#Pushing-to-Your-Remotes
By now, the remote server holds the version that was just pushed. What's missing is the deployment of the website. This has been discussed here:
Using GIT to deploy website
Doing so, you will decouple your work from that of your colleague since you're not changing files over FTP all the time. You work in your part, your partner works on her part. The work is getting merged and then a new version of the website gets published.
You can create git or Mercurial repositories in Atlassian Bitbucket (http://bitbucket.org). If your team is new to version control, i advise you no forks in your first project.
The easy solution ins to use Atlassian SourceTree (http://www.sourcetreeapp.com/) to control your code since there is a bug in netbeans. See NetBeans + Git on BitBucket
You need to create a new repository in bitbucket. I assume you already configure the ssh2 keys. Using Git you need:
git clone --bare --shared php_project php_project.git
git commit
Using Mercurial you need:
hg init
hg commit
Good luck / boa sorte
Pedro