Is there a way to hide "funding" messages when running composer commands? - php

When using Composer, sometimes messages are displayed after installing or updating:
X packages you are using are looking for funding.
Use the `composer fund` command to find out more!
I want to know if there's a solution similar to this answer for npm, but for Composer.
Is there a way to hide the messages about projects needing funding? I checked the output of composer --help and didn't see any obvious flags.

There is no specific flag to target those two lines.
You can always use --quiet to get rid of all output, and have a completely silent run.
If for some reason you are particularly bothered by those two lines, but do not want to lose the rest of the output, you could always pipe stderr through grep and exclude those lines:
composer update 2> >(grep -v "composer fund" | grep -v "looking for funding")
Which results in:
Notice in the screenshot above the conspicuous lack of any reference to funding.
If all this is worth doing or not, I'll leave up to you.

Spam! In your terminal! Worse when "the good guys" do it!
But this is open source, so let's fix it.
You'll need to already have Composer installed for this (you need Composer to compile Composer like this).
You'll also need jq.
All together:
sudo apt install jq
cd "$(mktemp -d)"
ver=$(curl -s 'https://getcomposer.org/versions' | jq -r '.stable[0].version')
git clone https://github.com/composer/composer.git .
git checkout ${ver}
unset ver
sed -Ei 's/^(\s+if\s?\()\$fundingCount(\) \{)$/\1FALSE\2/g' ./src/Composer/Installer.php
composer install
composer compile
composer_location=$(which composer)
if [[ -f "${composer_location}" ]]; then
\cp -f composer.phar "${composer_location}"
chmod u+x "${composer_location}"
fi
unset composer_location
Separately:
Install jq:
sudo apt install jq
Make a temporary folder and change directory to it:
cd "$(mktemp -d)"
Get the version number of the latest stable Composer and store it in the ver variable:
ver=$(curl -s 'https://getcomposer.org/versions' | jq -r '.stable[0].version')
Clone the Composer git repository to this temporary directory and check out the code at the latest stable version of Composer:
git clone https://github.com/composer/composer.git .
git checkout ${ver}
Clean up after ourselves, unsetting the ver variable which we don't plan to use again.
unset ver
Replace if ($fundingCount) { with if (FALSE) { in src/Composer/Installer.php:
sed -Ei 's/^(\s+if\s?\()\$fundingCount(\) \{)$/\1FALSE\2/g' ./src/Composer/Installer.php
Obtain the dependencies for compiling Composer, but using Composer (which is why you need Composer installed first). I mean, you can do this manually, but heck, why.
composer install
Compose a new composer.phar with this current, altered code base:
composer compile
Store the current location of teh Composer binary in a variable.
composer_location=$(which composer)
Just in case you aliased the composer command, in which case that wouldn't have saves a file name's location, we check if it is a file and then proceed to replace it with our new one and make our new one executable by you, the user.
if [[ -f "${composer_location}" ]]; then
\cp -f composer.phar "${composer_location}"
chmod u+x "${composer_location}"
fi
That backslash before the cp is also an alias buster. Often people alias cp to cp -i and we just want this to work right now.
Finally just unset the composer_location variable to be neat.
If you follow the regex in that sed line, great, if not, it is best to skip that line and manually apply the change so that you know what is happening on your own device, vim src/Composer/Installer.php then replace if ($fundingCount) { with if (FALSE) {.
Off course this means you are running an unsigned copy of composer (with the alteration being your own). But since they breached your trust already who cares about thát "trust" chain.
Also, if you run composer self-update it will replace your Composer with an unpatched one again and you will have to follow these steps again. Since they breached your trust (yes again) best to update manually like this anyway (just follow these steps again and you will update too), I just put it in Ansible for all our company's developers' desktops.

Related

Symfony 6 AWS Beanstalk run npm run build

I'm new to AWS and I've gotten as far as getting the following error in Symfony:
Asset manifest file "/var/app/current/public/build/manifest.json" does not exist.
In local, this would be fixed by running npm run build. I've tried adding NPM_CONFIG_PRODUCTION=true in the environment variables, but I think that might just be for node.js apps?
I've also tried SSHing onto the EC2 instance and installing node on there, but I ran into errors trying to install either npm or nvm. I feel like this is the wrong approach anyway, since it seems like the idea of beanstalk is that you shouldn't need to ssh onto the instance.
Perhaps I should just include the node_modules folder in the zip uploaded, but since one of the recommended ways to produce the zip is to use git, this doesn't seem correct either.
After a lot of digging around, it seems like there's 3 options here:
SSH onto the instance(s) and the following worked for me (Amazon Linux 2 - ARM chip)
curl --silent --location https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo yum -y install nodejs
(cd /var/app/current/;sudo npm add --dev #symfony/webpack-encore)
(cd /var/app/current/;sudo npm install)
(cd /var/app/current/;sudo npm run build)
The problem with this, is if you have multiple instances that scale up and down with a load balancer, it isn't really practical to do this.
Add the above as a hook:
The following sh file could be put in the following directory: .platform/hooks/predeploy
#!/bin/bash
curl --silent --location https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo yum -y install nodejs
(cd /var/app/current/;sudo npm add --dev #symfony/webpack-encore)
(cd /var/app/current/;sudo npm install)
(cd /var/app/current/;sudo npm run build)
However, I've since learnt that it's best advised to just include the node_modules in the zip that gets uploaded. I guess this way the time to get the server up is reduced.
Include the node_modules folder in the zip that gets uploaded.
To include the node_modules folder, since this is naturally ignored by GIT, I used the EB CLI and added a .ebignore file, which is a clone of the .gitignore file, but includes the node_modules and public folders. Also be cautious in your build process that you're not including the node dev dependencies.

Composer missing after upgrading to OS X 10.11 El Captian

So simply put. I did an in-place update from 10.10.5 to 10.11.1 recently and just discovered that my composer package manager is no longer working.
I've tried a number of solutions and have it installed into the correct directory, but my alias 'composer' which was set globally is now not able to find the composer file.
Following the steps as always
First, Download
curl -sS https://getcomposer.org/installer | php
Then move
sudo mv composer.phar /usr/local/bin/
Then update bash_profile
vim ~/.bash_profile
Finally add alias
alias composer="php /usr/local/bin/composer.phar"
And my end result, when calling composer is this
Could not open input file: /usr/local/bin/composer/
Any ideas why this might happen?
Found the answer by talking to someone on reddit.
///
First off, try going to the composer file in /usr/local/bin and double-click it. It should open up in a new Terminal window. This should at least confirm that the file can be executed.
Second, you shouldn't need to have an alias to use composer. You merely point your path to it like this:
export PATH="~/.composer/vendor/bin:$PATH"
If you have any other path variables you'll just attach a colon to the end of it like so:
export PATH="/usr/local/php5/bin:~/.composer/vendor/bin:$PATH"
Hope this helps.

How to completely uninstall symfony and composer from a mac

I want to completely remove symfony and composer from my mac. I have been googling for five hours and no documentation can be found on how to uninstall composer and symfony completely from my mac. Why is that so hard to find? even on the Symfony website.
Symfony on your computer is just a folder containing the framework and the structure of the files, so you can delete that folder and you are done. Composer is just an binary file (phar) that can run on the command line. Locate where that file is and delete it.
Symfony could be anywhere on your mac.
The 'installer' for mac that comes from here https://symfony.com/download (dd 2019/10) dumps symfony in your home directory in ~/.symfony . I dislike that, too.
ls -al ~/.symfony
if it's there,
rm -rf ~/.symfony
That 'installer' suggests you may want to move it here
ls -al /usr/local/bin/symfony
if it's there
rm -rf /usr/local/bin/symfony
I agree with the above answer to
rm -rf ~/.symfony
but you do not need to run ls to check beforehand, if it's there, it is going to be deleted. If not, it is being ignored.
Better do
whereis symfony
to check where your binary is and delete it.
Last but not least check if you have installed it via apt, this is a valid solution:
cd /etc/apt/sources.list.d && ls | grep symfony-cli
sudo rm symfony-cli.list && sudo apt update
This will avoid checking for updates on every apt update

Running Composer returns: "Could not open input file: composer.phar"

I am new to symfony2 and reading symblog. In third chapter while trying with data-fixtures I tried the command:
php composer.phar update
but I got the error:
Could not open input file: composer.phar
So I googled a little and tried
php composer.phar install
but still getting the same error. So please guide how to deal with this composer to install new extentions or bundles like data-fixtures in symfony2 using wamp.
If you followed instructions like these:
https://getcomposer.org/doc/00-intro.md
Which tell you to do the following:
$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer
Then it's likely that you, like me, ran those commands and didn't read the next part of the page telling you to stop referring to composer.phar by its full name and abbreviate it as an executable (that you just renamed with the mv command). So this:
$ php composer.phar update friendsofsymfony/elastica-bundle
Becomes this:
$ composer update friendsofsymfony/elastica-bundle
I had the same problem on Windows and used a different solution. I used the Composer_Setup.exe installation file supplied by the composer website and it does a global install.
After installing, make sure your PATH variable points to the directory where composer.phar is stored. This is usually C:\ProgramData\ComposerSetup\bin (ProgramData might be a hidden directory). It goes without saying, but also be sure that the PHP executable is also in your PATH variable.
You can then simply call
composer install
instead of
php composer.phar install
Background
It is helpful to know that there are two ways to install (and use) Composer: locally as a file in your project directory, or globally as a system-wide executable.
Installing Composer locally simply means that you are downloading a file (composer.phar - which is a PHP Archive) into your project directory. You will have to download it for every project that requires Composer.
Like a regular PHP file that you want to execute on the command line, you will have to run it with PHP:
php composer.phar update
Which basically tells the php executable to run the file composer.phar with update as argument.
However, if you install it globally, you can make composer itself executable, so you can call it without php (and don't have to download it for every project). In other words, you can use composer like this:
composer update
Since you are executing php composer.phar update, and you are getting the error Could not open input file: composer.phar, you probably don't have composer.phar in your current directory.
Solution
If you have Composer installed globally, simply run composer update instead of php composer.phar update.
If you don't have Composer installed yet, download the PHAR using the following command:
curl -sS https://getcomposer.org/installer | php
This will download the installer and run it using php. The installer will download the actual Composer PHAR to your current working directory, and make it executable.
To install Composer globally (I recommend this), copy the file to a location in your PATH. The exact location differs per operating system and setup, see https://getcomposer.org/doc/00-intro.md#globally for more information.
Personally, I prefer to install Composer in my home directory so I don't need sudo to install or update the composer executable (which can be a security risk). As I'm on Linux, I use the following command:
mv composer.phar ~/.local/bin/composer
If anyone else came this low on the page and still didn't find a working answer (like I did), use this:
$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer.phar
$ alias composer='/usr/local/bin/composer.phar'
$ composer --version
et voila! A working composer :-)
To solve this issue the first thing you need to do is to get the last version of composer :
curl -sS https://getcomposer.org/installer | php
I recommend you to move the composer.phar file to a global “bin” directoy, in my case (OS X) the path is:
mv composer.phar /usr/local/bin/composer.phar
than you need to create an alias file for an easy access
alias composer='/usr/local/bin/composer.phar'
If everything is ok, now it is time to verify our Composer version:
composer --version
Let's make composer great again.
I found this worked as I did not have curl installed. On Windows 8 with XAMPP installed. It will add it to your local build I use .gitignore to avoid the repo
php -r "readfile('https://getcomposer.org/installer');" | php
I got it from here: https://getcomposer.org/download/
This worked for me:
composer install
Without
php composer install
Run the following in command line:
curl -sS https://getcomposer.org/installer | php
Yesterday I was trying to install Yii2 framework on Windows 10 and I have same problem(Could not open input file: composer.phar) running this command:
php composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.9
Issue is composer.phr file is not in current directory,you need to give full path composer.phr like
php C:\ProgramData\Composer\bin\composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.9
Or you can create yii2 project using this command:
composer create-project yiisoft/yii2-app-advanced advanced 2.0.9
Or
composer.phar create-project yiisoft/yii2-app-advanced advanced 2.0.9
I had the same issue. It is solved when I made composer globally available. Now I am able to tun the commands from any where in the folder.
composer update
composer require "samplelibraryyouwant"
Use this :
php -r "readfile('https://getcomposer.org/installer');" | php
Hi friends, follow the steps to fix this issue in MAC OS
Step 1: first run the command in Terminal with your project directory
$ curl -sS https://getcomposer.org/installer | php
Step 2: Move the composer.phar in your project directory
$ mv composer.phar /Applications/MAMP/htdocs/bashrushAPI/composer.phar
Step 3: Setup alias the composer
$ alias composer='/Applications/MAMP/htdocs/bashrushAPI/composer.phar'
Step 4: Check the composer version now
$ composer --version
Composer version 1.7.2 2018-08-16 16:57:12
Step 5: Confirm the project folders and file placed on bellow
$ ls
CONTRIBUTING.md docker-compose.yml templates
README.md logs tests
composer.json phpunit.xml vendor
composer.lock public
composer.phar src
Step 6: Now update composer
$ composer.phar update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
Step 7: Run your sample project
$ php composer.phar start
php -S localhost:8080 -t public
[Thu Sep 27 03:16:11 2018] ::1:51177 [200]: /
[Thu Sep 27 03:16:11 2018] ::1:51178 [404]: /favicon.ico - No such file or directory
Easy answer, navigate to the directory where you already have the composer.json file that you want to run (ideally your project folder) then download composer into the same folder, then instantly run the install command like so:
php composer.phar install
This will automatically find the composer.json and run your required scripts. Good luck. This stuff is a breeze for terminal wizards and totally bizarre to the rest of us
I am using windows 8.0. In my case to install or update i just use composer install or something else instead of php composer.phar. This worked for me
like
composer require google/apiclient:1.*
To googlers who installed composer via HomeBrew:
make a symbolic link for /usr/local/bin/composer
ln -s /usr/local/bin/composer /usr/local/bin/composer.phar
I got this error "Could not open input file: composer.phar" while installing Yii2 using below mentioned command.
php composer.phar create-project yiisoft/yii2-app-basic basic
Solutions which worked for me was, I changed the command to
composer create-project yiisoft/yii2-app-basic basic
I hope it help!
your composer.phar should be placed in above way.
For windows, I made composer.cmd and used the below text:
php c:\programs\php\composer.phar %*
where composer.phar is installed and c:\programs\php\ is added to my path.
Not sure why this isn't done automatically.
For Windows10 Pro, Following steps fix the issue. select properties check the Unblock program option. run the installer, run the command CMD with Admin rights. At command promp run composer --version to make sure it is globally installed. you should be able to now run composer require drush/drush This is for drush dependency using composer.
Command like this :
composer.phar require intervention/image
error: composer.phar: command not found
I solved the problem by following this process
i set the composer globally and renamed composer.phar to composer then run this command composer require intervention/image . and now it's working fine
Just open cmd as Administrator and go into your project folder and check it is working or not using composer command.
The above error is because of the composer is not accessible globally.
So you need to run "cmd" as Administrator.
This is working fine for me.
If you are using Ubuntu/Linux and you are trying to run
php composer.phar require intervention/image on your command line.
Use sudo composer require intervention/image instead. This will give you want you are looking for.
I had an issue getting a package.json's script to run composer dumpautoload.
I had the file /usr/local/bin/composer.phar, and also the file ~/.bash_profile (on OSX) contained:
alias composer="php /usr/local/bin/composer.phar"
This allowed composer to work from the command line, but it didn't allow scripts to execute composer.
The fix was this:
$ cd /usr/local/bin
$ mv composer.phar composer
$ sudo chmod +x composer // +x allows the file to be executable, such as by CLI scripts
But that yielded this error Could not open input file: /usr/local/bin/composer.phar
The fix was to update ~/.bash_profile (sudo nano ~/.bash_profile), and change the composer alias to:
alias composer="php /usr/local/bin/composer"
# ie: `.phar` extension removed
Now everything is behaving as expected.
Your composer.phar must be in Source files. I had same problem and I just cut my composer.phar into mine framework-standard-edition folder, where is my whole strong textproject.
if the composer is already install all you need is to know where the composer.phar file is (its directory) after that you move to your symfony project where you have the composer.json and from that directory you execute your composer.phar file. In windows here is what you have to do.
symfony project directory_where_composer.json_is>php the_directory_where_composer.phar_is/composer update
That's all
use two steps .
curl -sS https://getcomposer.org/installer | php
sudo php composer.phar update
You can do
curl -sS https://getcomposer.org/installer | php
The -sS flag meaning don't show progress, do show errors
and then
php composer.phar install
from:
How do I get cURL to not show the progress bar?
https://packagist.org/
I've reach to this problem when trying to install composer on a Window 7 machine from http://getcomposer.org/download page. As there was an existing compose version (provided by acquia Dev Desktop tool) the installation fails and the only chance was to fix this issue manually. (or to remove Dev Desktop tool composer).
Anyway the error message is quite straightforward (Could not open input file: composer.phar), we should then tell the system where the file is located.
Edit composer.bat file and should look like:
#SET PATH=C:\Program Files (x86)\DevDesktop\php5_4;%PATH%
php.exe composer.phar %*
See that composer.phar doesn´t have a file path. When standing in a different folder than the one where composer.phar is located the system won´t be able to find it. So, just complete the composer.phar file path:
#SET PATH=C:\Program Files (x86)\DevDesktop\php5_4;;%PATH%
SET composerScript=composer.phar
php.exe "%~dp0%composerScript%" %*
Reopen your window console and that should do the trick.
EDIT: this has an issue because it always uses %~dp0%composerScript%
folder as composer execution. Then all configurations are done in that
folder (besides standing on your current project folder) and not in your project folder.
So far I haven't found a was to make a manual composer installation to
work globally on Windows. Perhaps you should go ahead with composer for windows installation mentioned above.
Do not access the composer by
composer composer.pher install
use
composer install
You can just try this command if you're already installed the Composer :
composer update
or if you want add some bundle to your composer try this :
composer require "/../"

Continuous Integration using composer

I have a PHP project in which I load packages through Composer. I also run Continious Integration using Jenkins, on a dedicated CI server. Once every hour, Jenkins queries my repository for changes, and if present, if executes a test run.
First step of the testrun is making a fresh checkout of the repository, and performing a build of the application, using Phing. One of the steps of the build is performing an
composer install
Since Jenkins always works with a fresh checkout, composer will always fetch all packages on every test run, even if none of the packages have been changed since the previous run. This has a couple of disadvantages:
It takes a relativally long time to complete a test run (composer needs to fetch for example Zend Framework, which is rather large
It put unnecessary strain on the packagist server, if new packages are fetched every hour
If, for some reason, the composer install fails, so does my test run.
I was thinking of possibly storing the packages that composer fetches on a central spot at the CI server, so Jenkins would be able to access the packages at that location for every test run. Of course, now I have to rewrite part of my application to handle the fact that the vendor folder is in a different location when on the CI server. Secondly, I have to tell Jenkins to keep track of changes on the composer.lock file, to see if he needs to run composer anyway. I'm afraid none of those two things are really trivial.
Does anyone have any suggestions of a other/better way to do this, or is it the best option to just fetch all packages through composer on every test run. Admiditally, it's the best way to make sure you always use the correct packages, but it sortof feels like a waste of bandwith, certainly in later stages of development, when the list of packages will hardly change anymore.
One way to speed it up is to use composer install --prefer-dist which only downloads zips even for dev packages. This is preferred for unique builds since it skips the whole history of the project.
As for sparing packagist, don't worry about it too much, one build every hour isn't going to make a huge difference compared to all the open source libs that build on travis at every commit.
One thing you could do is to store vendors in a location outside of project's workspace in jenkins so that it remains between the builds. You not necessarily need to change your application. Just update the build script so that it creates a symbolic link to the vendors location.
I use capifony for deployment and it uses this approach to keep the vendors between releases.
One thing to note is that Composer caches packages that it downloads. So once they are downloaded the first time, they should work even if Packagist is down (not 100% sure), and network bandwidth spared (100% sure).
Second thing is: why are you running tests by doing a fresh checkout of the repository? It is entirely possible to keep a copy of your code in the workspace in Jenkins, and just make sure you wipe on every test run the caches, logs and other artifacts. This will speed up not only composer install, but also the git pulls, especially for big repos!
Side note: for our own Jenkins platform, where workspaces are not cleaned between tests, the main drawback we found with composer is the sheer amount of disk space taken by having the full vendor dir in each workspace. I tried to work around this by using symlinks and sharing the vendors (named based on hashes of composer.lock), but then composer autoloader had a bit of problems finding where to load classes from...
Steps to install zf2 project on Jenkins
mkdir /path/to/your/project
1. Install the composer
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
Note: If the above fails due to permissions, run the mv line again with sudo.
A quick copy-paste version including sudo:
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
create a composer.json file in the root directory of the project
add all the pacakages you require
{
"name": "amarjitsingh",
"description": "amarjitsingh",
"license": "BSD-3-Clause",
"keywords": [
"framework",
"zf2"
],
"homepage": "http://domain.com/",
"require": {
"php": ">=5.5",
"zendframework/zendframework": "~2.5",
"phpoffice/phpword": "dev-master",
"doctrine/doctrine-orm-module": "0.7.0",
"imagine/Imagine": "0.5.*",
"zf-commons/zfc-user": "dev-master"
},
"autoload" : {
"psr.0" : "/module"
}
}
run 'composer install' to install these packages.
set up git on your machine
if you are using ubuntu you can set up GIT using the folowing commands
sudo apt-get update
sudo apt-get install git
Set Up Git
git config --global user.name "Your Name"
git config --global user.email "youremail#domain.com"
check the config list
git config --list
once you have setup GIT then c
cd /path/to/your/project
. once you have packes installed the create a '.gitignore' file in the dcument
root and add 'vendor' inside it.
git init
git remote add origin https://username#bitbucket.org/username/zf2ci.git
apply below command to ADD, COMMIT, AND PUSH the files
git add .
git commit -m 'Initial commit with contributors'
git push -u origin master
git pull
using cloud you can use AWS . I am using digital ocean
1 create a droplet
2.name it as you wish , in mycase it is zf2ci
3. choose a package
4. choose the OS my cas eis Ubuntu 14.04
5. In applications tab choose LAMP
6 once you done with that you will get IP address, username root and password.
7. login the ip by using the putty
8. user root
9. password pass
10. once you get into it it will prompt to you to change the password
11. goto web root eg /var/www/html
12. install GIT
13. apt-get install git
14. clone the repo
15. git clone https://username#bitbucket.org/username/zf2ci.git
16. install composer on this machine
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
Note: If the above fails due to permissions, run the mv line again with sudo.
A quick copy-paste version including sudo:
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
goto app path /var/ww/html/zf2ci
run 'composer install --no-dev' we are installing it with no dev option becuasae we only install well tested code on app server
Step3
Create a Jenkins server
1. set up another droplet for Jenkins
2. image ubuntu
3.install Lamp
install Jenkns
Installing Jenkins
Before we can install Jenkins, we have to add the key and source list to apt. This is done in 2 steps, first we'll add the key.
1.1
wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | apt-key add -
Secondly, we'll create a sources list for Jenkins.
1.2
echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list
1.3
Now, we only have to update apt's cache before we can install Jenkins.
apt-get update
1.4
As the cache has been updated we can proceed installing Jenkins. Note that Jenkins has a big bunch of dependencies, so it might take a few moments to install them all.
apt-get install jenkins
1.5 open the ip with port 8080
eg http://127.0.0.1:8080
1.6 install git on jenkins server
sudo apt-get update
sudo apt-get install git
1.7 install composer
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
1.8 enable user authentication
1.9
enable bitbucket plugin for Jenkins
1.9.1
Manage Jenkins->Manage Plugins->Bitbucket Plugin->download and install
1.9.2
create job
create job->
project name(eg. zf2ci)->
source code management (git) provide ssh url(git#bitbucket.org:username/zf2ci.git)->
branches to built (*/master) this is the branch where each time any user commits and merge the code with Master branch -Jenkins gets invoked
1.9.3
Build Triggers
choose the option(build when a chnage is pushed) this will wok when we make a POST hook on bit bucket
1.9.4
Build->Execute shell
composer install
./vendor/bin/phpunit ./tests
our tests sits intests dir
1.9.5
set a ssh key pair
login to jenkins Serevr through putty
su jenkins
cd
ls -la( check what is in the jenkins home directory)
ssh-kegen -t rsa (dsa by default but choose rsa key ,it is faster)
press enter(on path)
press enter(leave the pass phrase empty , the whole point here is to avoid passwords in the automated jobs)
pres enter
cd .ssh
ls -la (you will find id_rsa.pub) file there
cat id_rsa.pub
(select all and copy the contents of the file)
1.9.6
goto bitbucket
switch to the repo zf2ci
goto settings
click deployment keys->add key
add label (jenkins)
key*(paste the the contents of the id_rsa.pub)file here
save key
summary
`zf2ci->settings->deployment keys->add key->type` label and paste id_rsa.pub key->save
1.9.7
register POST hook for repo
Settings->
Integrations->
Hooks->
POST(search for POST Hook)->
Add the url /IP of the Jenkins Server) (`172.62.235.100:8080/bitbucket-hook/`)
(the body of the post contanis information about the repository, branch, list of recent commits, user)
1.9.8
login to Jenkins server
su jenkinks
cd
cd .ssh
git ls-remote -h ssh://git#bitbucket.org:username/zf2ci.git HEAD
1.9.9
save project on Jenkins
1.9.10
add the following command in the
Execute Shell->command
[rsync -y -vrzhe "ssh -o StrictMostKeyChecking=no" --exclude vendor/ . root#ipaddress:/var/www/html/zf2ci( of app server)]
ssh root#ipaddress<<EOF
cd /var/www/html/zf2ci
composer install --no-dev
EOF

Categories