Jenkins not recognizing composer command - php

I have a local install of JenkinsCI. Installed via instructions in the Chapter 2 of Jenkins The Definitive Guide. I start Jenkins via Java Web Start/JNLP file on my MAC running El Capitan. All that went great, sample project is working.
I know want to get my Codeception Acceptance test running via Jenkins. I'm following the most recent blog post about this on the Codeception site: http://codeception.com/02-04-2015/setting-up-jenkins-with-codeception.html#.VwWxE2PLRAZ.
Using the Execute shell build step, my build fails with the following message:
Started by user anonymous
Building in workspace /Users/Cosette/.jenkins/workspace/Project Name
[Project Name] $ /bin/sh -xe
/var/folders/ns/ly6hv_513tl6qqslrb2vj_dw0000gn/T/hudson9210778078639547082.sh
composer install
/var/folders/ns/ly6hv_513tl6qqslrb2vj_dw0000gn/T/hudson9210778078639547082.sh:
line 2: composer: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
My guess is that maybe this install type doesn't install the Jenkins user? Please note I am very beginner level and this is my first question here on stackoverflow. Also, That should be a + sign in front of "composer install".

You should download composer from https://getcomposer.org/, rename it to composer, make executable with chmod +x and place somewhere in the PATH of Jenkins.

I have yet to find an answer to ensuring the Jenkins user has access to files under other users. I eventually gave up and installed via homebrew, eliminating the Jenkins user all together. For now I'm just placing everything necessary to run in Users/UserName/.jenkins/Home/workspace/Project-name

Related

WebdriverIO and Docker Setup

I am trying to setup a docker container with WebdriverIO built into it, with the eventual aim of being able to run a CI/CD pipeline in gitlab, but I have absolutely no idea where to start.
My application is a PHP/MySQL based app which was also recently dockerised. I access it locally on http://localhost.
I have tried to create a docker image with wdio built into it, but it fails when trying to do the
npm init wdio --yes
as the --yes command doesn't force any of the default settings, which goes against the official documentation. This then causes the wdio installation to fail.
What is confusing me even more is that there seems to be very few tutorials for this, the wdio documentation doesn't seem great, and what tutorials I can find all seem to mention selenium. FYI, I am just a dev that has been tasked to take some existing WDIO scripts and get them ready for CI/CD, I don't know a massive amount about WDIO in the first place.
Does anyone have any basic steps I could follow that would describe the process of taking some local WDIO scripts, and getting them to run inside a container, with the end goal of being to have them into some sort of CI/CD pipeline?
When trying to create the image, the following command does not seem to work:
npm init wdio --yes
It would be much more appropriate if you have initialize a wdio project and copy it to the Dockerfile.
This is what it might look like:
FROM node:16
USER root
#===============================
# Set default workspace
#===============================
RUN mkdir /home/workspace \
&& chmod 2777 /home/workspace
COPY . /home/workspace
WORKDIR /home/workspace
This way, your docker image contains your whole project built in.
Then you could append the following command to make sure the environment is ready for webdriverI/O to execute.
#==================================
# Install needed packages
#==================================
RUN apt update && apt upgrade -y
RUN npm install
If you need anything like browser and webdriver, you could install it via dozens of approaches.
You can use ENTRYPOINT or CMD to make it execute the specified test suites once the container is up.
If you wanna complete CI or CD flow with docker containers, it will depend on which service you may utilize.

How can I composer update on OpenShift?

I am trying to use Slim on OpenShift with a free node. I can run composer update from the SSH sessions without any problem.
The only problem is every time I want to commit files through git I have to go to the console and run composer install again. My question is there is any easy way to workaround this? I tried a BASH script in /project/.openshift/action_hooks/post_deploy but the server is not creating the vendor folder under runtime/repo
I always do it via action hooks:
Inside my project directory I have a script called by /project/.openshift/action_hooks/post_deploy where post_deploy is a bash script.
Here goes what I have been using:
#!/bin/bash
export MY_PHPCOMPOSER=$OPENSHIFT_DATA_DIR/composer.phar
# if composer not exists, download
if [ ! -f $MY_PHPCOMPOSER ]; then
cd $OPENSHIFT_DATA_DIR
echo "Downloading composer..."
php -r "readfile('https://getcomposer.org/installer');" | php
fi
$MY_PHPCOMPOSER -n -q self-update
cd $OPENSHIFT_REPO_DIR
# install
php -dmemory_limit=1G $MY_PHPCOMPOSER install
So post_deploy script will perform every time which you push your repo to openshit. It work like a charm!
Side note
Since not always the OpenShift composer's version is updated it's safe
to download a new composer copy and use it.
Also, don't forget adjusting permissions settings.
Helpful links
Openshift builds
Openshift Default Build Lifecycle
I know that my answer is late but according to the Openshift documentation you can enable composer install after each build by just creating a marker file:
touch .openshift/markers/use_composer

error: git was not found - installing laravel with composer windows

I'm getting an error saying:
failed to clone https://github.com/php-fig/log.git, git was not found, check that it is installed and in your PATH env.
'git' is not recognized as and internal or external command, operable program or batch file
when I try and run composer create-project laravel/laravel learning-laravel.
I installed the git GUI which also comes with a command line shell, but I don't know why its not recognising the command (I'm issuing the create-project command in the normal windows command line prompt).
I also tried running the command from the git shell, which worked, but when I tried php artisan serve it gave me an error saying CLI has stopped working.
Does anyone know how to fix the git error? I'd rather use the windows command shell instead of the git one as it can then go into my wamp/www file
You need to add the directory you installed git to to your PATH environment variable.
Right click on Computer.
Click Advanced System Settings
Click Environment Variables inside the Advanced Menu
Under System Variables, scroll to PATH
Add ;"C:\path\to\git\bin";"C:\path\to\git\cmd"
Test the git command in the command prompt to see if it worked. Git is usually located in Program Files or Program Files(x86).
There is an easier (but temporal) way to add a path variable in Windows.
Paste this in your command prompt:
SET PATH=%PATH%;C:\Program Files\Git\bin
This will work for the rest of the command prompt session. Don't forget installing Git before this.
You'll need to add git to your system PATH if you want to use it in regular command prompt.
Here's a guide on modifying your system path in Windows:
http://www.computerhope.com/issues/ch000549.htm
you need to uninstall git and reinstall ( or update ) in the options you need to change from git bash only to allow git to be added to command line as well, also since it then adds it to your path you may or may not need to restart your computer
I was having some issues using git on Windows. I found this information only and it worked for me.
http://ccn.ucla.edu/wiki/index.php/Setting_Up_and_Using_Git#Windows

having problems with the shopify php api when looking for the shopify_api

PHP API using: https://github.com/sandeepshetty/shopify_api
I have PHP 5.3.27 installed
I installed Composer (by going to
the website and using their install.exe)
It mentions that
"This will download shopify_api into the
vendor/sandeepshetty/shopify_api directory."
But I do not see the folders or files anywhere on the computer.
The plugin author is saying that if you download Composer with the instructions he provided (via Terminal), then Composer will autoload those files for you. Unfortunately, though easier, simply going to the source URL for the Composer tool won't do that for you.
First, make sure you have created the composer.json file and stored it in your project directory. Then, log into your server or system via the command line (Terminal for Mac OS, Putty for Windows). Cd into your project directory, and install by entering these commands:
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar install

How to install PHPUnit with WAMP?

I'm a newbie programmer and I have tried for an embarrassingly long time to get PHPUnit set up and working with WAMP. I have read the documentation and went through various sites to see what I'm doing wrong, but I give up! I need someone to explain this to me in simple terms.
I've probably seen all the guides on how to set it up, but feel free to link me to something you believe is foolproof!
Try this blog : http://nishutayaltech.blogspot.com/2011/04/installing-phpunit-on-windows.html
This setup is for Windows. Hope this will help you.
Also check this out, may be useful http://www.mark-leong.com/installing-php-and-phpunit-on-windows-7/
// adding required pear channels
pear channel-update pear.php.net
pear upgrade-all
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear update-channels
// performing install
pear install --alldeps --force phpunit/PHPUnit
If everything ok, check whether phpunit have been installed by putting in command line
phpunit -v
If you encountered any errors or interrupted installing
pear clear-cache
may be usefull in that case.
1) download https://phar.phpunit.de/phpunit.phar
2) run it via php phpunit.phar
Btw if that file ever goes away you can look at the original directions here: https://github.com/sebastianbergmann/phpunit
I recommend using composer. It can be used per project, but also 'globally'.
Make a folder on your C drive called 'globalpackages', then cd into it from the command line.
run 'composer require phpunit/phpunit'
once that finishes run 'composer install'
once that finishes you can check the contents of C:\globalpackages\vendor\phpunit' and should see two phpunit files, one of them a bat.
Add C:\globalpackages\vendor\phpunit to your system path and then you will be able to run phpuni from anywhere on your system.
For me this is the fastests and easiest way.
Make sure you have wamp with WAMP with PHP 7 installed as phpunit requires PHP7 to work! or at least 6.2
Go to folder
wamp64\bin\php\php7.0.10
(wherever you installed your wamp - BEWARE last folder is name of PHP version you have so it might be different then above )
We will be working in this folder during entire installation. So if I say edit file etc it means in this folder.
Download newest version of phpunit from https://phpunit.de/
At the time of writing this I get version phpunit 6.2 and php7.0.10
4. Copy downloaded file to wamp64\bin\php\php7.0.10 folder
For me it's: phpunit-6.2.2.phar
for you it might be different version.
Now change name of the phpunit-6.2.2.phar to phpunit.phar
Now make sure you have added your php to PATH in Environment Variables
To do this on Windows 10 and Windows 8
6a. In Search, search for and then select: System (Control Panel)
6b. Click the Advanced system settings link.
6c. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New.
6d. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Paste location of your PHP. For me it would be: D:\AnyFolderYouInsalledWampTo\wamp64\bin\php\php7.0.10
(if in PATH there was other command or path just add ";" at the end. For exmaple:
%someOtherCommand%; D:\AnyFolderYouInsalledWampTo\wamp64\bin\php\php7.0.10)
6e. Click OK. Close all remaining windows by clicking OK.
In cmd (to run cmd go to search in Windows and type cmd.exe and click Enter)
go to folder wamp64\bin\php\php7.0.10
(to go to folder type for example cd D:\AnyFolderYouInsalledWampTo\wamp64\bin\php\php7.0.10)
now once you are in this folder run this command in cmd:
echo #php "%~dp0phpunit.phar" %* > phpunit.cmd
now run this command:
phpunit
you should get list of all commands available in phpunit
now run this:
phpunit --check-version
you will get info what phpunit version you have and if you are using the newest version.
if this doesn't work go to wamp64\bin\php\php7.0.10
Edit file phpunit.bat
Add this line:
""%PHPBIN%" "D:\AnyFolderYouInsalledWampTo\wamp64\bin\php\php7.0.10\phpunit.phar" %*
Repeat point 9.
if it still doesn't work let me know.
Very well done, Emil! You're a star! Perfect answer to install PHPUnit with WAMP on Windows. Look no further than Emil.
https://stackoverflow.com/users/5753967/emil

Categories