---
title: Set CICD with Jenkins
tags: common
---
:::danger
If you are running Jenkins locally, use ngrok to get outer access in order to set your webhook
:::
* Login to ngrok, copy and paste this inside your ngrok folder


* then run ngrok in the backgroud by adding & sign in the end of your command
`nohup ./ngrok http 8080 &`

* Then you can check your tunnels here!
* Copy the tunnel and add ==/github/webhook/== in the end of the url, set it as webhook in your GitHub repo settings

* Create a ==New Item== on Jenkins, select ==Pipeline==, and click on ==OK==



### Jenkinsfile
```javascript=1
pipeline {
agent any
stages {
stage('Build') {
steps {
echo '---start build---'
nodejs(nodeJSInstallationName: 'node14.15.4') {
sh 'npm i'
sh 'npm run build'
}
}
}
stage('Test') {
steps {
echo '---start test---'
echo 'Do check'
}
}
stage('Deploy') {
steps {
echo '---start deploy---'
sh 'ssh -T pmduser@10.20.30.215 "cd ~/Desktop/cicd/jenkins_home/workspace && docker-compose up -d --build"'
}
}
}
}
```
### docker-compose.yml
```dockerfile=1
version: '3.7'
services:
gqlts:
container_name: gqlts
build: ./gqlts/
environment:
- TZ=Asia/Taipei
ports:
- '8081:8081'
restart: always
frontend-admin:
container_name: frontend-admin
build: ./frontend-admin/
environment:
- TZ=Asia/Taipei
ports:
- '8000:8000'
restart: always
```