极客时间运维进阶训练营第四周作业
Mandatory Assignment
Jenkins master monitoring
Install "prometheus metrics plugin"
Install "CloudBees Disk Simple"
Jenkins distributed env
Multi slaves
Jenkins install slave
Master config
On the Jenkins master, install "SSH Build Agent" plugin, restart Jenkins master
Slave config
Install Java11
Create a user on the agent to be used by Jenkins.
Generate an ssh key for Jenkins user
Add the public key to the authorized_keys file of the Jenkins user on the agent node.
On the Jenkins slave, you can test ssh login
Now we’re ready to finish setting up the node via the Jenkins UI. In Jenkins Master, go to Manage Jenkins, then Manage Nodes, then click New Node. Here you can give your agent node a name, then select Permanent Agent and click OK. There are a variety of options you can use here to customize your node. All we care about right now is the Launch Method.
Select Launch Slave Agents via SSH for Launch Method.
Enter the hostname or IP address of your agent node in the Host field.
Click the Add button next to Credentials and select the Jenkins scope.
For the credential, set Kind to SSH username with private key.
Enter jenkins for the username.
For the private key, select Enter directly. Then, copy the contents of your private key file (~/.ssh/id_rsa by default) and paste it into the Key box.
If you used a passphrase when generating the key, enter that for Passphrase, otherwise, leave it blank.
Enter a descriptive id and description, then click Add.
Click Save to save the new node.
Now you should be able to see the new Jenkins agent
Config a test job to use new slave
Trigger the job
You should see it run successfully
Jekinsfile Syntax
Sample Jenkinsfile
Official Pipeline documentation: https://www.jenkins.io/doc/book/pipeline/syntax/
Install Sonarqube
Optimize system kernel parameters:
Install with docker-compose
Run docker-compose command:
Log into SonarQube
Dashboard
Optional Assignment
Jenkins install SonarQube Scanner Plugin
Go to Jenkins master, "manage Jenkins", "plugins"
Configure test job to run "SonarQube Scanner"
Job output
版权声明: 本文为 InfoQ 作者【9527】的原创文章。
原文链接:【http://xie.infoq.cn/article/2c5d919b92da8b1520bf7794c】。文章转载请联系作者。
评论