当前位置: 首页 > news >正文

jenkinsfile小试牛刀

本文主要演示一下如何用jenkinsfile来编译java服务

安装jenkins

这里使用docker来安装jenkins

docker run --name jenkins-docker \
--volume $HOME/jenkins_home:/var/jenkins_home \
-p 8080:8080 jenkins/jenkins:2.416

之后访问http://${yourip}:8080,然后输入admin密码继续安装

jenkinsfile

pipeline {agent anytools {// Install the Maven version configured as "M3" and add it to the path.maven "M3"}stages {stage('Build') {steps {// Get some code from a GitHub repositorygit 'https://github.com/jglick/simple-maven-project-with-tests.git'// Run Maven on a Unix agent.sh "mvn -Dmaven.test.failure.ignore=true clean package"// To run Maven on a Windows agent, use// bat "mvn -Dmaven.test.failure.ignore=true clean package"}post {// If Maven was able to run the tests, even if some of the test// failed, record the test results and archive the jar file.success {junit '**/target/surefire-reports/TEST-*.xml'archiveArtifacts 'target/*.jar'}}}}
}

这里定义了Build,它先是git拉取代码,然后执行mvn进行编译,最后在post部分在状态为success时使用junit显示测试报告,并归档jar包

小结

jenkins2.x提供了pipeline as code的功能,可以通过jenkinsfile(类似gitlab ci yaml),使用dsl来定义流水线,这个相比于在界面上配置更为易用和清晰,也容易进行版本化管理。

doc

  • jenkins docker
http://www.lryc.cn/news/101052.html

相关文章:

  • C++ xmake构建
  • 推荐带500创作模型的付费创作V2.1.0独立版系统源码
  • wps图表怎么改横纵坐标,MLP 多层感知器和CNN卷积神经网络区别
  • rdb和aof
  • TCP网络通信编程之网络上传文件
  • Java中对Redis的常用操作
  • 链路追踪设计
  • Golang之路---02 基础语法——常量 (包括特殊常量iota)
  • Pytest学习教程_装饰器(二)
  • redis的如何使用
  • MyBatis(二)
  • 【【51单片机AD转换模块】】
  • Longest Divisors Interval(cf)
  • 配置文件、request对象请求方法、Django连接MySQL、Django中的ORM、ORM增删改查字段、ORM增删改查数据
  • CTF学习路线指南(附刷题练习网址)
  • 【Rust 基础篇】Rust默认泛型参数:简化泛型使用
  • 从源码分析Handler面试问题
  • shell编程 变量作用域
  • 华为eNSP:isis的配置
  • FS.05-SAS-UP-Methodology
  • Jmeter并发测试
  • 【JVM】浅看JVM的运行流程和垃圾回收
  • 使用低代码开发,需要注意哪些?
  • 面试总结-Redis篇章(八)——Redis分布式锁
  • 压力测试-商场项目
  • IDEA中文UT方法执行报错问题、wps默认保存格式
  • Vue如何实现编程式导航声明方法,前进和后退导航
  • torch.load 报错 ModuleNotFoundError 或 AttributeError
  • 前端,js , Error in created hook: TypeError ,有bug了
  • 百度文心千帆大模型平台:企业级大模型服务的新航标