Friday, May 31, 2013

PHP error - It is not safe to rely on the system's timezone settings

To fix the bellow error:

1. Find you php.ini files
2.  to see your php.ini files- you need to pass in the INFO_GENERAL parameters as without the parameters you will get the same error as phpinfo() will trigger the timezone issue settings
3. Edit your php.ini files and go to

; Defines the default timezone used by the date functions

; http://php.net/date.timezone

;date.timezone =


Change to what ever your time zone is. For a list of php timezone please visit http://id1.php.net/manual/en/timezones.asia.php

; Defines the default timezone used by the date functions

; http://php.net/date.timezone

date.timezone = "Asia/Dubai"


Ps: don't forget to delete the ";"

4. Restart your apache server. if you are using mac use "sudo apachectl restart"


date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Dubai' for 'WIT/7.0/no DST' instead

CException CAssetManager is invalid

To fix the below error:
 1. Set the group permission to WWW using
 sudo chown user:www assets (mac)
 sudo chown user.www assets (linux)

------------------
Websever Error

CException

CAssetManager.basePath "/Users/user/Sites/website-code/assets" is invalid. Please make sure the directory exists and is writable by the Web server process.

/Users/user/YII/framework/web/CAssetManager.php(138)

126     }
127 
128     /**
129      * Sets the root directory storing published asset files.
130      * @param string $value the root directory storing published asset files
131      * @throws CException if the base path is invalid
132      */
133     public function setBasePath($value)
134     {
135         if(($basePath=realpath($value))!==false && is_dir($basePath) && is_writable($basePath))
136             $this->_basePath=$basePath;
137         else
138             throw new CException(Yii::t('yii','CAssetManager.basePath "{path}" is invalid. Please make sure the directory exists and is writable by the Web server process.',
139                 array('{path}'=>$value)));
140     }
141 
142     /**
143      * @return string the base url that the published asset files can be accessed.
144      * Note, the ending slashes are stripped off. Defaults to '/AppBaseUrl/assets'.
145      */
146     public function getBaseUrl()
147     {
148         if($this->_baseUrl===null)
149         {
150             $request=Yii::app()->getRequest();

Monday, May 27, 2013

Windows Batch File Not Executing

I use jenkins to automate my cucumber test automation. I use windows to execute the batch command in Jenkins

bundle install --path vendor
set test_env=test_server 
bundle exec cucumber features\regression\dashboard.feature

However, only the first line is executed by jenkins. It turns out that jenkins creates a .bat file for those above commands and jenkins calls the commands as

cmd \c call hudson.bat

And apparently the cmd "Call" command only works on the first command.

To fix the issue simply append the keyword "call" on every command.

The solution:
call bundle install --path vendor
set test_env=test_server
call bundle exec cucumber features\regression\dashboard.feature

Jenkins does not execute All Windows Batch Command

I use jenkins to automate my cucumber test automation. I use windows to execute the batch command in Jenkins

bundle install --path vendor
set test_env=test_server 
bundle exec cucumber features\regression\dashboard.feature

However, only the first line is executed by jenkins. It turns out that jenkins creates a .bat file for those above commands and jenkins calls the commands as

cmd \c call hudson.bat

And apparently the cmd "Call" command only works on the first command.

To fix the issue simply append the keyword "call" on every command.

The solution:
call bundle install --path vendor
set test_env=test_server
call bundle exec cucumber features\regression\dashboard.feature

Friday, May 24, 2013

Cannot run program sh in jenkins

Error from Jenkins console:

[cuke-test] $ sh -xe C:\Users\username\AppData\Local\Temp\4\hudson4066016990068916818.sh
The system cannot find the file specified
FATAL: command execution failed
java.io.IOException: Cannot run program "sh" (in directory "c:\jenkins\workspace\cuke-test"): CreateProcess error=2, The system cannot find the file specified
 at java.lang.ProcessBuilder.start(Unknown Source)
 at hudson.Proc$LocalProc.<init>(Proc.java:244)
 at hudson.Proc$LocalProc.<init>(Proc.java:216)
 at hudson.Launcher$LocalLauncher.launch(Launcher.java:763)
 at hudson.Launcher$ProcStarter.start(Launcher.java:353)
 at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:988)
 at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:955)
 at hudson.remoting.UserRequest.perform(UserRequest.java:118)
 at hudson.remoting.UserRequest.perform(UserRequest.java:48)
 at hudson.remoting.Request$2.run(Request.java:326)
 at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
 at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
 at java.util.concurrent.FutureTask.run(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 at hudson.remoting.Engine$1$1.run(Engine.java:58)
 at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
 at java.lang.ProcessImpl.create(Native Method)
 at java.lang.ProcessImpl.<init>(Unknown Source)
 at java.lang.ProcessImpl.start(Unknown Source)
 ... 17 more
Build step 'Execute shell' marked build as failure

Solution:
- It turns out that I copied a job from a linux slave and therefore the default build step that was used was "Execute shell". To fix the issue just change the "Execute shell" to "Execute Windows batch command"

Tuesday, May 7, 2013

Git Setup Remote Tracking Branch


Git global setup

git config --global user.name "Test User"
git config --global user.email "testuser@gmail.com"

Create Repository

mkdir testproject
cd testproject
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@gitlab.testserver-123.testuser/testprojects.git
git push -u origin master

Existing Git Repo?

cd existing_git_repo
git remote add origin git@gitlab.testserver-123.testuser/testprojects.git
git push -u origin master

Friday, May 3, 2013

Capybara Check Select Options

To check Select options using Capybara

To choose the select option:

select('Morning', :from => 'Shift')

To check the value of the select options:

page.has_select?('Shift', :selected => 'Morning')