Jenkins Day1


一. 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
三. freestyle job

We usually use freestyle as our first jenkins job.

0e0fdd9b11f944369efd61b457806a41.jpg
we can setup the github repository and crediential

2edb4468704e4461a2bc6a776eb4ed20.jpg
node envroinment
shell script

dca2fbee036d4aa9b41da5b468d01209.jpg

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
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"
    } 

 

 

 

 

 

 

 

b3f1381b2c5b4ec2b2d73e1fde002805.jpg

a4145103a59248ad81351acfb765ce1b.jpg

14fcd40793c941e397f0546726806812.jpg

 

 

 

  • 34
    点赞
  • 58
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值