Jenkins

How do I run a stage in Jenkins only on pull request?

蹲街弑〆低调 提交于 2021-01-24 08:50:15
问题 I have a Jenkinsfile-based pipeline with several stages in it right now that is triggered by webhook on every commit to Github. I'd like to keep the "build" and "unit tests" stages running on every commit, but ONLY run the "integration tests" stage when the branch is up for pull request. What I want: stage("build)"{ // runs every commit } stage("unit tests"){ // runs every commit } stage("integration tests"){ // runs ONLY on pull request } I've been unable to find a solution to this, any

jenkins学习之Jenkins流水线parallel并发执行

南楼画角 提交于 2021-01-23 09:03:51
动态的创建 一个 并行的 流水线。并且可以设置agent的。 例1 pipeline { agent any stages { stage('BuildAll') { parallel { stage('build-win') { steps { sh "env | grep -i NODE_NAME" runParallel items: ("a".."d").collect { "Win-${it}" } } } stage('build-Mac') { steps { sh "env | grep -i NODE_NAME" runParallel items: ("a".."d").collect { "Mac-${it}" } } } } } } } def runParallel(args) { parallel args.items.collectEntries { name -> [ "${name}": { node('master') { stage("${name}") { stage("${name}-a") { sh "env | grep -i NODE_NAME" } stage("${name}-b") { sh "env | grep -i NODE_NAME" } } } } ] } } 例2 pipeline { agent any

How to use Log Parser Plugin in a Jenkins Workflow script

空扰寡人 提交于 2021-01-23 08:56:29
问题 The Log Parser Plugin is now compatible with Workflow but how do I use it? 回答1: Easiest is to use Snippet Generator to get an example step statement using it. 回答2: Snippet Generator is a good idea; however, it is not generating the complete line to make it work. It is necessary to add at the end of the code line " , projectRulePath: '' ". Final line will be in the way, for example: logParser failBuildOnError: true, parsingRulePAth: '/myRulesPath', showGraphs:true, unstableOnWarning: true,

How to use Log Parser Plugin in a Jenkins Workflow script

末鹿安然 提交于 2021-01-23 08:55:42
问题 The Log Parser Plugin is now compatible with Workflow but how do I use it? 回答1: Easiest is to use Snippet Generator to get an example step statement using it. 回答2: Snippet Generator is a good idea; however, it is not generating the complete line to make it work. It is necessary to add at the end of the code line " , projectRulePath: '' ". Final line will be in the way, for example: logParser failBuildOnError: true, parsingRulePAth: '/myRulesPath', showGraphs:true, unstableOnWarning: true,

Permission denied error - jenkins (shell script)

℡╲_俬逩灬. 提交于 2021-01-23 05:33:14
问题 I'm using a jenkinsfile to test one of our instances. For this I created a bash script. Problem is that jenkins doesn't have permissions to run the script. Any idea how to fix this? Jenkinsfile: stage("Testing instances"){ if (terragruntAction == 'apply' || terragruntAction == 'test'){ echo "Testing" sh '../check_services.sh' } } output: ../check_services.sh: Permission denied I tried to do: git update-index --chmod=+x check_services.sh on the git folder that gets checkouted by Jenkins but no

Jenkins报错'Gradle build daemon disappeared unexpectedly'的问题解决

喜你入骨 提交于 2021-01-22 13:34:16
Jenkins报错'Gradle build daemon disappeared unexpectedly'的问题解决 参考文章: (1)Jenkins报错'Gradle build daemon disappeared unexpectedly'的问题解决 (2)https://www.cnblogs.com/liushengchieh/p/9729786.html 备忘一下。 来源: oschina 链接: https://my.oschina.net/u/4438370/blog/4919369

What is 测试金字塔?

感情迁移 提交于 2021-01-22 10:10:05
【答疑解惑 】 | 作者 / Edison Zhou 这是 恰童鞋骚年 的第 271 篇原创内容 我的女朋友是一名测试工程师,但她之前却不知道测试金字塔的概念,为此我曾经在家里的白板上画了一个图一层一层给她讲解过。我和同事在给团队面试测试和开发岗位时,也会必问到这个问题,想到可能有很多开发童鞋都不知道,这里我就用一篇推文给大家科普一下。 1 传说中的金字塔 我们都知道,针对项目的测试有很多分类,比如单元测试、集成测试、组件测试、端到端测试 以及 探索性测试等。那么,测试金字塔其实就是给我们的一个指导,它指导我们要在不同类型的测试工作投入多少的精力是最合适的。 废话不多说,先上图: 测试金字塔示意图(来自波波老师的课程) 从上图中我们可以看到,测试金字塔建议我们: (1) 尽可能地多做单元测试 和 集成测试 ,因为他们的执行速度相较于上层的几个测试类型来说快很多且相对稳定,可以一天多次执行。一般来说,我们都会将单元测试 和 集成测试 做到持续集成构建任务中去,比如放到Jenkins中每天定时执行1~2次,或者每次push代码到git仓库后执行,总之,就是要确保可以频繁执行以确保代码质量。 (2) 尽可能地少做 组件测试、端到端测试 和 探索性测试 ,因为他们的执行速度相较单元测试 和 集成测试 会慢很多,且不够稳定,无法做到一天多次执行,每次执行都要等很久才能获得反馈结果。但是

测试金字塔的奥秘和数学

£可爱£侵袭症+ 提交于 2021-01-22 09:44:41
三角形的故事 它可能被称为“测试自动化金字塔”,但在大多数情况下看起来都像三角形一样可怕。如果使用吉萨大金字塔的尺寸和本文中讨论的数学方程式,您将最终对测试金字塔的每一层的作用和依赖性以及建立牢固基础的重要性有更深入的了解。 通过将自动测试金字塔视为一个三角形,我们可以使用几何和三角元素查找每个级别的大小。为了弄清楚这一点,我们首先将金字塔分解成3个独立的三角形。我们将确定每个三角形的面积,然后使用切片技术确定每个级别的大小。 我们需要做的第一步是使用来自吉萨大金字塔的这些尺寸来找到三角形的总面积: 使用这些尺寸,我们可以找到组成金字塔一侧的三角形的总面积。 面积=½(230 * 147)≈16905 从顶部(UI级别)开始,我们可以找出每个级别的大小以及它所占整个金字塔的百分比。 用户界面级别 将大金字塔的高度平均分为3个部分,这意味着我们的顶部UI层高49米。 现在,我们可以使用一些三角函数和 勾股定理 来查找该三角形的区域,以查看所涉及的数学细节 。 通过数学运算,我们发现金字塔的UI层的面积为1909.4,约占金字塔总数的11%。 服务级别 使用相同的过程找到中间层的面积,我们发现金字塔的服务层为5726.76,约占金字塔总数的33%。 单位等级 为了找到单位层的面积,我们从测试金字塔的总面积中减去服务和UI层的总面积 16905-5726.76-1909.4 = 9268

Jenkins configurations gets reverted by SYSTEM user anomaly

狂风中的少年 提交于 2021-01-21 10:02:08
问题 I am running Jenkins version 2.85 on Kubernetes as pod(Affinity set to one workernode). I am creating Jobs using Salt Jenkins module by passing XML to this module. I am using Jenkins Global Library for preforming job execution. My Job config looks like this I am calling GobalLibrary with my parameters like repoURL, componet etc.., Things goes well for weeks and now I landed to a weird situation where my job configurations(config.xml) gets updated/revert automatically. Intermittently my "Build

How to read subfolders in jenkins pipeline

瘦欲@ 提交于 2021-01-21 10:01:34
问题 I'm trying to write a pipeline jenkins job that loop through the subfolder of a specific directory and launch something. The problem is to access the filesystem. For some reason it does not seems to read the file system at all, neither its own workspace. This is the snippet I'm using node ('label') { workspacePath = '/opt/installersWS' ws(workspacePath){ stage ("test"){ ...some stuff... runtimeBuildDir = new File(workspacePath + "/components") echo runtimeBuildDir.getPath() if