一. install jenkins
1. in linux:
doc: https://www.jenkins.io/doc/book/installing/linux/#debianubuntu
sudo apt update
install java
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt update
sudo apt install jenkins
sudo systemctl start jenkins
sudo systemctl enable jenkins
2. install by docker
After I install it on my linux host, I just find that there is existing image of jenckins on docker hub:
https://www.jenkins.io/doc/book/installing/docker/
Don't forget use -v when use docker run jenkins
3. Error may come across
The following signatures couldn't be verified because the public key is not available:
a. NO_PUBKEY 3B4FE6ACC0B21F32
Fix: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5BA31D57EF5975CA
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y update
sudo apt install jenkins
b. run time issue
Job for jenkins.service failed becasused a timeout was exceeded
See logs:
journalctl -xeu jenkins.service
systemctl status jenkins
I fix it by: chown -R jenkins:jenkins /var/lib/jenkins
二. Internal net penetration
I need to vist my jenkins outside of my internal network which means I need a net penetration to get a public net ip/domain
ngrok:
Don't need any public network ip
https://dashboard.ngrok.com/
1. sign up on ngrok
2. got a auth token
3. install ngrok
4. setup the token
5. ngrok http http://localhost:${port your service use}, then it can random assign you a valiable domain
![874b7d3360ec4e2f97a33bdfe7dfb2f7.jpg](https://img-blog.csdnimg.cn/874b7d3360ec4e2f97a33bdfe7dfb2f7.jpg)
三. freestyle job
We usually use freestyle as our first jenkins job.
we can setup the github repository and crediential
node envroinment
shell script
![b2427686725b40178f030258196956be.jpg](https://img-blog.csdnimg.cn/b2427686725b40178f030258196956be.jpg)
四. pipeline job(we usually leverage in our project)
1. workplace
by default it will locate at: /var/lib/jenkins/workspace/${project_name}
or you could see it by: echo "Workspace directory is: ${env.WORKSPACE}"
![e6746ac853aa4567a2c3ff5449dec30b.jpg](https://img-blog.csdnimg.cn/e6746ac853aa4567a2c3ff5449dec30b.jpg)
2. post section:
It can always do something after all stages run out, or after success/failure
post {
always {
cleanWs()
}
success {
archiveArtifacts artifacts: 'a.txt'
}
}
3. env variable and parameters
parameters {
string(name: 'TEST1', defaultValue: 'test', description: 'test')
booleanParam(name: 'SKIP_E2E', defaultValue: false, description: 'skip e2e or not')
}
environment {
HELLO_WORLD = "Hello World"
}