touch /.circleci/config.yml

create new folder “.circleci” and new file “config.yml” followed instruction of CircleCI add Projects for target Github repository.

Here is config.yml

# PHP CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-php/ for more details
#
version: 2
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/php:7.1-browsers
      
      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      # - image: circleci/mysql:9.4

    working_directory: ~/repo

    steps:
      - checkout

      # Download and cache dependencies
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "composer.json" }}
          # fallback to using the latest cache if no exact match is found
          - v1-dependencies-

      - run: composer install -n --prefer-dist

      - save_cache:
          paths:
            - ./vendor
          key: v1-dependencies-{{ checksum "composer.json" }}
        
      # run tests!
      - run: phpunit

Update project file

echo "This is circle ci test3!"

build

Somehow it seems like I understand or do not understand.
Now, we will start to touch Travis CI.

Create a folder with Github

Since GitHub had only file creation, I did not know how to create it.

But we will make folders from file creation.
follow circleci project step below.

Create a folder named .circleci and add a fileconfig.yml (so that the filepath be in .circleci/config.yml).

In this case, add “/” to the tail of text. Therefore, text should be “.circleci/” from “.crcileci”.

Then, automatically new folder has created.

Well done, let’s make sure not to create files trying to make folders.

Try using CircleCI

facebook, kickstarter, spotify are using CircleCI.

Aouth CircleCI with Github

CircleCI dashboard

Failed? What!!

let’s watch job detail

Build-agent version 0.1.1480-7a5183d3 (2019-01-22T18:14:45+0000)
Starting container bash:4.4.19
  using image bash@sha256:9f0a4aa3c9931bd5fdda51b1b2b74a0398a8eabeaf9519d807e010b9d9d41993

Using build environment variables:
  BASH_ENV=/tmp/.bash_env-5c486cf91773df0008cbcc61-0-build
  CI=true
  CIRCLECI=true
  CIRCLE_BRANCH=master
  CIRCLE_BUILD_NUM=2
  CIRCLE_BUILD_URL=https://circleci.com/gh/githubix/test/2
  CIRCLE_COMPARE_URL=
  CIRCLE_JOB=Build Error
  CIRCLE_NODE_INDEX=0
  CIRCLE_NODE_TOTAL=1
  CIRCLE_PREVIOUS_BUILD_NUM=1
  CIRCLE_PROJECT_REPONAME=test
  CIRCLE_PROJECT_USERNAME=githubix
  CIRCLE_REPOSITORY_URL=git@github.com:githubix/test.git
  CIRCLE_SHA1=faed9c8c981615655d296d6137e3abdb9dddfc0d
  CIRCLE_SHELL_ENV=/tmp/.bash_env-5c486cf91773df0008cbcc61-0-build
  CIRCLE_STAGE=Build Error
  CIRCLE_USERNAME=githubix
  CIRCLE_WORKFLOW_ID=bd789861-e6e6-428d-877a-888ff642a15c
  CIRCLE_WORKFLOW_JOB_ID=23b817b9-9ef5-4bcc-861e-93fddfe7e6c7
  CIRCLE_WORKFLOW_UPSTREAM_JOB_IDS=
  CIRCLE_WORKFLOW_WORKSPACE_ID=bd789861-e6e6-428d-877a-888ff642a15c
  CIRCLE_WORKING_DIRECTORY=~/project
#!/bin/sh -eo pipefail
# No configuration was found in your project. Please refer to https://circleci.com/docs/2.0/ to get started with your configuration.
# 
# -------
# Warning: This configuration was auto-generated to show you the message above.
# Don't rerun this job. Rerunning will have no effect.
false

It is said “No configuration was found in your project”

Oh, understood the issue that do I need to create yml file??

How to use Circle CI?

CicleCI is CI service.
https://circleci.com/

By registering from the above page, we can automatically build, test, and deploy like Jenkins.

Jenkins needs to set up a Jenkins server on its own, but since CircleCI is a service that can be used only by registering.

Features
– It is a CI service
– Can cooperate with GitHub
– Run the build in the container under the concept of container
– Free for one container use (billing is required for multiple use)

Concept of Container
Although it is not limited to CircleCI, the CI tool has the concept of “Container”

Features
– As the name implies “box/container” image
– Run build, test and deploy in the container
– As the number of containers increases, the speed increases as it can be executed in parallel. However, CircleCI will be charged for using more than two containers.

When executing two or more builds, waiting time occurs because only one can be executed even when we run a lot of test, it can take time only because it can only be executed in series.

Webhook for Jenkins and github

One of the functions to link GitHub and Jenkins is called “Webhook”. By using this Webhook, you can run Jenkins’ jobs when pushing a branch to the repository managed on GitHub, when creating a new Pull Request, and so on.

There are three main ways to link Jenkins with GitHub and Webhook by the following three methods.

Jenkins Standard Webhook
– Set up “build for remote” provided as standard function of Jenkins
Git Plugin
– A plugin that can provide functions that can clone and execute git repositories when building Jenkins GitHub Plugin.
Plug-in to receive push event from GitHub
– Jenkins can automatically register Webhook to GitHub

Jenkins Standard Webhook
Build and trigger

Continue to configure Webhook with GitHub. From the repository page you can add it from Setting > Webhooks > Add Webhook.

Go to Github repository

See webhooks and add webhook

Jenkins
「Jenkinsの管理」>「ユーザーの管理」>「(API Token を取得したいユーザーID)」>「設定」>「APIトークンの表示」

Payload URL
http://[USER_ID]:[API_TOKEN]@[JENKINS_HOST]/job/[JOB_NAME]/[build|buildWithParameters]?token=[TOKEN_NAME]

Oh, Ok.
close jenkins
[vagrant@localhost app]$ sudo service jenkins stop
Shutting down Jenkins [ OK ]

Jenkins setting and how to use it?

Job
Job describes a series of operations that Jenkins wants to run. If you think that is something like batch files or Linux shell script now.

1. put name for Enter an item and press free style project build

2. Next page, chose build and set shell execution

3. write shell script

echo 'hello jenkins'

4. save task and run build

console output

ユーザーhpscriptが実行
ビルドします。 ワークスペース: /var/lib/jenkins/workspace/HelloJenkins
[HelloJenkins] $ /bin/sh -xe /tmp/jenkins6861841405666017940.sh
+ echo ‘hello jenkins’
hello jenkins
Finished: SUCCESS

Wow, Perhaps it’s fun to play.

install Jenkins into CentOS

First make sure java is installed
[vagrant@localhost app]$ java -version
openjdk version “1.8.0_191”
OpenJDK Runtime Environment (build 1.8.0_191-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

Add jenkins repository
[vagrant@localhost app]$ sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
–2019-01-22 21:14:32– http://pkg.jenkins-ci.org/redhat/jenkins.repo
pkg.jenkins-ci.org をDNSに問いあわせています… 52.202.51.185
pkg.jenkins-ci.org|52.202.51.185|:80 に接続しています… 接続しました。
HTTP による接続要求を送信しました、応答を待っています… 200 OK
長さ: 71
`/etc/yum.repos.d/jenkins.repo’ に保存中

100%[======================================>] 71 –.-K/s 時間 0s

2019-01-22 21:14:36 (3.39 MB/s) – `/etc/yum.repos.d/jenkins.repo’ へ保存完了 [71/71]

[vagrant@localhost app]$ sudo rpm –import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key

install jenkins
[vagrant@localhost app]$ sudo yum install -y jenkins


[vagrant@localhost app]$ sudo service jenkins start
Starting Jenkins [ OK ]

wow

Jenkins vs TravisCI vs CircleCI

CI stands for Continuous Integration. In CI(Continuous Integration), developers frequently merge their code changes into the central repository and run automated builds and test each time.

I would like to compare popular CI tools.
– Jenkins
– TravisCI
– CircleCI

1. Jenkins
As a feature of Jenkins, it is highly scalable, it can do whatever you can customize, and build on on-premise.
Although it was a popular CI tool with abudant articles, since it is necessary to prepare a server for CI, maintenance and operation of that server becomes necessary.
– To incorporate it into the workflow including actual production, introduction needs to be done systematically.
– Failure to manage will take cost consuming.

2. TravisCI
Since it is cloud, there is no need to manage and operate the server.
Increased compatibility with Github
Abundant article
It is difficult to debug because SSH does not put it in a container
Since it is cloud, ip changes every time it builds

3. CircleCI
Since it is cloud, there is no need to manage and operate the server.
Support is strong
Abundant article
Since it is put in a container with ssh, it is easy to debug
You can start using it for free
Recently the version has gone up and it corresponds to docker and workflow
Because it is Cloud, every time it builds IP changes.

Display the uploaded image on Laravel 5.7

Create a file name and move it from the temporary folder to under item. Pass variable of file name from controller to view.
ImageIndexController.php

class ImageIndexController extends Controller
{
    public function index(){
    	return view('imageindex');
    }

    public function store(Request $request){

        $filename = date("YmdHis") . "." . $request->file('image')->guessExtension();
    	$request->file('image')->move(public_path('item'), $filename);
    	return view('imageindex',compact('filename'));
    }
}

If there is a variable in the “If statement”, display it.
imageindex.blade.php

@if(!empty($filename))
      <img src="/item/{{$filename}}">
      @else
      @endif

1. upload the image and put register button

2. Then image is displayed on view page.

Ok, first step is well done.
I think I need to insert a file pass to mysql.

/dev/null 2>&1

#/bin/bash

echo "this is standard output"

[vagrant@localhost app]$ ./echo.sh
-bash: ./echo.sh: /bin/sh^M: bad interpreter: そのようなファイルやディレクトリはありません
[vagrant@localhost app]$ sed -i ‘s/\r//’ echo.sh
[vagrant@localhost app]$ ./echo.sh
this is standard output

It took an hour to come here.

If it is executed normally, it will be displayed on the standard output, but if you redirect it, it will be able to output to another location.

When redirecting to standard error output
[vagrant@localhost app]$ ./echo.sh >&2
this is standard output

When redirecting to standard output
[vagrant@localhost app]$ ./echo.sh >&1
this is standard output

[vagrant@localhost app]$ ./echo.sh > /dev/null
/dev/null is a unix special file, it is an empty file.

Merging standard error output to standard output
2>&1

somehow I got it.