赞
踩
mv deploy.sh /usr/bin/
在镜像推送到Harbor仓库步骤的下面,再添加一个构建后操作
选择目标服务器,添加执行脚本和参数命令
deploy.sh 192.168.170.111:80 monster ${JOB_NAME} $version $host_port $container_port
直接deploy.sh,目标服务器放在bin目录下可以直接运行
紧跟着Harbor地址,Monster仓库
JOB_NAME就是当前Jenkins任务的名称mytest
version就是获取上面拉取的Gitlab标签版本号
host_port、container_port两个参数现在是获取不到的
所以需要再添加两个参数,在上面的参数化构建添加字符参数
一个宿主机端口host_port,默认值8081
一个容器端口container_port,默认值8080
开始构建,界面可以看见多了两个默认值的参数
Started by user 我是真滴帅 Running as SYSTEM Building in workspace /var/jenkins_home/workspace/mytest The recommended git tool is: NONE No credentials specified > git rev-parse --resolve-git-dir /var/jenkins_home/workspace/mytest/.git # timeout=10 Fetching changes from the remote Git repository > git config remote.origin.url http://192.168.170.111:8888/root/jenkins-cicd-mytest.git # timeout=10 Fetching upstream changes from http://192.168.170.111:8888/root/jenkins-cicd-mytest.git > git --version # timeout=10 > git --version # 'git version 2.30.2' > git fetch --tags --force --progress -- http://192.168.170.111:8888/root/jenkins-cicd-mytest.git +refs/heads/*:refs/remotes/origin/* # timeout=10 > git rev-parse refs/remotes/origin/main^{commit} # timeout=10 Checking out Revision b92e927c41d08ab99a8ac8a462535deadc68c972 (refs/remotes/origin/main) > git config core.sparsecheckout # timeout=10 > git checkout -f b92e927c41d08ab99a8ac8a462535deadc68c972 # timeout=10 Commit message: "删除docker-compose.yml,修改页面内容" > git rev-list --no-walk b92e927c41d08ab99a8ac8a462535deadc68c972 # timeout=10 [mytest] $ /bin/sh -xe /tmp/jenkins13710554383855071698.sh + git checkout v1.0.2 HEAD is now at b92e927 删除docker-compose.yml,修改页面内容 [mytest] $ /var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/maven/bin/mvn clean package -DskipTests [INFO] Scanning for projects... [INFO] [INFO] -------------------------< com.monster:mytest >------------------------- [INFO] Building mytest 0.0.1-SNAPSHOT [INFO] from pom.xml [INFO] --------------------------------[ jar ]--------------------------------- [WARNING] Parameter 'archive' is unknown for plugin 'spring-boot-maven-plugin:2.6.13:repackage (repackage)' [INFO] [INFO] --- clean:3.2.0:clean (default-clean) @ mytest --- [INFO] Deleting /var/jenkins_home/workspace/mytest/target [INFO] [INFO] --- resources:3.3.1:resources (default-resources) @ mytest --- [INFO] Copying 2 resources from src/main/resources to target/classes [INFO] [INFO] --- compiler:3.8.1:compile (default-compile) @ mytest --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 4 source files to /var/jenkins_home/workspace/mytest/target/classes [INFO] [INFO] --- resources:3.3.1:testResources (default-testResources) @ mytest --- [INFO] skip non existing resourceDirectory /var/jenkins_home/workspace/mytest/src/test/resources [INFO] [INFO] --- compiler:3.8.1:testCompile (default-testCompile) @ mytest --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to /var/jenkins_home/workspace/mytest/target/test-classes [INFO] [INFO] --- surefire:3.2.2:test (default-test) @ mytest --- [INFO] Tests are skipped. [INFO] [INFO] --- jar:3.3.0:jar (default-jar) @ mytest --- [INFO] Building jar: /var/jenkins_home/workspace/mytest/target/mytest.jar [INFO] [INFO] --- spring-boot:2.6.13:repackage (repackage) @ mytest --- [INFO] Replacing main artifact with repackaged archive [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.677 s [INFO] Finished at: 2024-03-16T17:27:43Z [INFO] ------------------------------------------------------------------------ [mytest] $ /var/jenkins_home/sonar-scanner/bin/sonar-scanner -Dsonar.host.url=http://192.168.170.111:9000 ******** -Dsonar.projectKey=mytest -Dsonar.projectname=mytest -Dsonar.java.binaries=target -Dsonar.source=./ -Dsonar.projectBaseDir=/var/jenkins_home/workspace/mytest INFO: Scanner configuration file: /var/jenkins_home/sonar-scanner/conf/sonar-scanner.properties INFO: Project root configuration file: NONE INFO: SonarScanner 5.0.1.3006 INFO: Java 17.0.7 Eclipse Adoptium (64-bit) INFO: Linux 3.10.0-1160.el7.x86_64 amd64 INFO: User cache: /var/jenkins_home/.sonar/cache INFO: Analyzing on SonarQube server 9.2.3 INFO: Default locale: "en", source code encoding: "UTF-8" INFO: Load global settings INFO: Load global settings (done) | time=614ms INFO: Server id: 54000601-AYjKh1Zs1hD1Rss9XdjF INFO: User cache: /var/jenkins_home/.sonar/cache INFO: Load/download plugins INFO: Load plugins index INFO: Load plugins index (done) | time=218ms INFO: Plugin [l10nzh] defines 'l10nen' as base plugin. This metadata can be removed from manifest of l10n plugins since version 5.2. INFO: Load/download plugins (done) | time=297ms INFO: Process project properties INFO: Process project properties (done) | time=1ms INFO: Execute project builders INFO: Execute project builders (done) | time=1ms INFO: Project key: mytest INFO: Base dir: /var/jenkins_home/workspace/mytest INFO: Working dir: /var/jenkins_home/workspace/mytest/.scannerwork INFO: Load project settings for component key: 'mytest' INFO: Load project settings for component key: 'mytest' (done) | time=191ms INFO: Load project branches INFO: Load project branches (done) | time=253ms INFO: Load project pull requests INFO: Load project pull requests (done) | time=26ms INFO: Load branch configuration INFO: Load branch configuration (done) | time=1ms INFO: Auto-configuring with CI 'Jenkins' INFO: Load quality profiles INFO: Load quality profiles (done) | time=600ms INFO: Auto-configuring with CI 'Jenkins' INFO: Load active rules INFO: Load active rules (done) | time=2826ms INFO: Indexing files... INFO: Project configuration: INFO: 10 files indexed INFO: 14 files ignored because of scm ignore settings INFO: Quality profile for java: Easyspeed INFO: Quality profile for web: Sonar way INFO: Quality profile for xml: Sonar way INFO: ------------- Run sensors on module mytest INFO: Load metrics repository INFO: Load metrics repository (done) | time=111ms INFO: Sensor JavaSensor [java] INFO: Configured Java source version (sonar.java.source): none INFO: JavaClasspath initialization INFO: JavaClasspath initialization (done) | time=7ms INFO: JavaTestClasspath initialization INFO: JavaTestClasspath initialization (done) | time=0ms INFO: Java "Main" source files AST scan INFO: 5 source files to be analyzed INFO: Load project repositories INFO: Load project repositories (done) | time=225ms INFO: 5/5 source files have been analyzed WARN: Dependencies/libraries were not provided for analysis of SOURCE files. The 'sonar.java.libraries' property is empty. Verify your configuration, as you might end up with less precise results. WARN: Unresolved imports/types have been detected during analysis. Enable DEBUG mode to see them. INFO: Java "Main" source files AST scan (done) | time=1189ms INFO: No "Test" source files to scan. INFO: No "Generated" source files to scan. INFO: Sensor JavaSensor [java] (done) | time=1406ms INFO: Sensor JaCoCo XML Report Importer [jacoco] INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=2ms INFO: Sensor CSS Rules [javascript] WARN: Error when running: 'node -v'. Is Node.js available during analysis? INFO: Sensor CSS Rules [javascript] (done) | time=1721ms INFO: Sensor C# Project Type Information [csharp] INFO: Sensor C# Project Type Information [csharp] (done) | time=1ms INFO: Sensor C# Analysis Log [csharp] INFO: Sensor C# Analysis Log [csharp] (done) | time=16ms INFO: Sensor C# Properties [csharp] INFO: Sensor C# Properties [csharp] (done) | time=0ms INFO: Sensor SurefireSensor [java] INFO: parsing [/var/jenkins_home/workspace/mytest/target/surefire-reports] INFO: Sensor SurefireSensor [java] (done) | time=2ms INFO: Sensor HTML [web] INFO: Sensor HTML [web] (done) | time=50ms INFO: Sensor XML Sensor [xml] INFO: 1 source file to be analyzed INFO: 1/1 source file has been analyzed INFO: Sensor XML Sensor [xml] (done) | time=179ms INFO: Sensor VB.NET Project Type Information [vbnet] INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=1ms INFO: Sensor VB.NET Analysis Log [vbnet] INFO: Sensor VB.NET Analysis Log [vbnet] (done) | time=12ms INFO: Sensor VB.NET Properties [vbnet] INFO: Sensor VB.NET Properties [vbnet] (done) | time=0ms INFO: Sensor com.github.mc1arke.sonarqube.plugin.scanner.ScannerPullRequestPropertySensor INFO: Sensor com.github.mc1arke.sonarqube.plugin.scanner.ScannerPullRequestPropertySensor (done) | time=0ms INFO: ------------- Run sensors on project INFO: Sensor Zero Coverage Sensor INFO: Sensor Zero Coverage Sensor (done) | time=7ms INFO: Sensor Java CPD Block Indexer INFO: Sensor Java CPD Block Indexer (done) | time=22ms INFO: CPD Executor 3 files had no CPD blocks INFO: CPD Executor Calculating CPD for 3 files INFO: CPD Executor CPD calculation finished (done) | time=6ms INFO: Load New Code definition INFO: Load New Code definition (done) | time=22ms INFO: Analysis report generated in 88ms, dir size=101.0 kB INFO: Analysis report compressed in 25ms, zip size=24.7 kB INFO: Analysis report uploaded in 55ms INFO: ANALYSIS SUCCESSFUL, you can browse http://ci.hkeasyspeed.com/dashboard?id=mytest INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report INFO: More about the report processing at http://ci.hkeasyspeed.com/api/ce/task?id=AY5IRf2h3PsONgf4Xut0 INFO: Analysis total time: 9.763 s INFO: ------------------------------------------------------------------------ INFO: EXECUTION SUCCESS INFO: ------------------------------------------------------------------------ INFO: Total time: 11.504s INFO: Final Memory: 18M/67M INFO: ------------------------------------------------------------------------ [mytest] $ /bin/sh -xe /tmp/jenkins15276106874998699608.sh + mv target/mytest.jar docker + docker build -t mytest:v1.0.2 docker/ DEPRECATED: The legacy builder is deprecated and will be removed in a future release. Install the buildx component to build images with BuildKit: **自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。** **深知大多数Linux运维工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!** **因此收集整理了一份《2024年Linux运维全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。** ![img](https://img-blog.csdnimg.cn/img_convert/246500ee0bdc91e3534c980357e103bc.png) ![img](https://img-blog.csdnimg.cn/img_convert/0917f46912881aa3b1c5bf508f80d33e.png) ![img](https://img-blog.csdnimg.cn/img_convert/4be4fca8edad7e11bccc481082d6c277.png) ![img](https://img-blog.csdnimg.cn/img_convert/9b769c29a66fa2b8b367bdb31e937648.png) ![img](https://img-blog.csdnimg.cn/img_convert/dbfde11a16bd57f43f5f1d3cb059de82.png) **既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Linux运维知识点,真正体系化!** **由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新** **如果你觉得这些内容对你有帮助,可以添加VX:vip1024b (备注Linux运维获取)** ![img](https://img-blog.csdnimg.cn/img_convert/7f8b9db46f767f874312ff503aaa9479.jpeg) 为了做好运维面试路上的助攻手,特整理了上百道 **【运维技术栈面试题集锦】** ,让你面试不慌心不跳,高薪offer怀里抱! 这次整理的面试题,**小到shell、MySQL,大到K8s等云原生技术栈,不仅适合运维新人入行面试需要,还适用于想提升进阶跳槽加薪的运维朋友。** ![](https://img-blog.csdnimg.cn/img_convert/71b37cea06848805faa7d0d639404728.png) 本份面试集锦涵盖了 * **174 道运维工程师面试题** * **128道k8s面试题** * **108道shell脚本面试题** * **200道Linux面试题** * **51道docker面试题** * **35道Jenkis面试题** * **78道MongoDB面试题** * **17道ansible面试题** * **60道dubbo面试题** * **53道kafka面试** * **18道mysql面试题** * **40道nginx面试题** * **77道redis面试题** * **28道zookeeper** **总计 1000+ 道面试题, 内容 又全含金量又高** * **174道运维工程师面试题** > 1、什么是运维? > 2、在工作中,运维人员经常需要跟运营人员打交道,请问运营人员是做什么工作的? > 3、现在给你三百台服务器,你怎么对他们进行管理? > 4、简述raid0 raid1raid5二种工作模式的工作原理及特点 > 5、LVS、Nginx、HAproxy有什么区别?工作中你怎么选择? > 6、Squid、Varinsh和Nginx有什么区别,工作中你怎么选择? > 7、Tomcat和Resin有什么区别,工作中你怎么选择? > 8、什么是中间件?什么是jdk? > 9、讲述一下Tomcat8005、8009、8080三个端口的含义? > 10、什么叫CDN? > 11、什么叫网站灰度发布? > 12、简述DNS进行域名解析的过程? > 13、RabbitMQ是什么东西? > 14、讲一下Keepalived的工作原理? > 15、讲述一下LVS三种模式的工作过程? > 16、mysql的innodb如何定位锁问题,mysql如何减少主从复制延迟? > 17、如何重置mysql root密码? **一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!** ![img](https://img-blog.csdnimg.cn/img_convert/b6dfa795de53f6741f0532f65d60cfb0.jpeg) 什么叫网站灰度发布? > 12、简述DNS进行域名解析的过程? > 13、RabbitMQ是什么东西? > 14、讲一下Keepalived的工作原理? > 15、讲述一下LVS三种模式的工作过程? > 16、mysql的innodb如何定位锁问题,mysql如何减少主从复制延迟? > 17、如何重置mysql root密码? **一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!** [外链图片转存中...(img-wfRW89p4-1712956382164)]
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。