Skip to content

Latest commit

 

History

History
112 lines (81 loc) · 2.22 KB

README.md

File metadata and controls

112 lines (81 loc) · 2.22 KB

jenkins-ci

Create pipeline with Blue Ocean

In jenkins dashboard, click Open Blue Ocean

Click Create New Pipeline and follow the instructions. You can create/edit Jenkinsfile use Blue Ocean interface. If you want to create/edit Jenkinsfile with preferred editor, click Cancel.

Sample of Jenkinsfile

pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        echo 'This is the Build Stage'
      }
    }
    stage('Test') {
      steps {
        echo 'This is the Testing Stage'
      }
    }
    stage('Deploy') {
      steps {
        echo 'This is the Deploy Stage'
      }
    }
  }
}

Setup jenkins service

Github service (deprecated)

In your repository, click Settings

Click Integration & services >> Add service. Select Jenkins (Github plugin)

jenkins service

Enter you jenkins hook url then click Add service

jenkins hook url

Note: If you run jenkins on localhost, you can use ngrok to setup the hook url.

Push the changes to github, and you can see green check in your commits. That means the commit pass your pipeline.

Note: Github service is announced as deprecated by Github. Use webhook instead.

Github webhook

  1. In repository, click Settings
  2. Click Webhooks > Add webhook
  3. Enter Payload URL, select content type application/json
  4. Select webhook event you want to receive.
  5. Add Webhook

Success PR

git checkout -b success_pr
echo 'success' >> README.md
git add .
git commit -m "Add readme"
git push -u origin success_pr

success PR

Failure PR

git checkout -b failure_pr

Change Jenkinsfile

pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        // invalid command to let build fail
        sh 'ggcomand'
      }
    }
  }
}
git add .
git commit -m "Add broken commit"
git push -u origin failure_pr

failure PR