jenkins-declarative-pipeline

Check parallel stages status

混江龙づ霸主 提交于 2021-02-10 17:33:25
问题 I have something like this: stages { stage('createTemplate') { parallel { stage('template_a') { creating template a } stage('template_b') { creating template b } } } stage('deployVm') { parallel { stage('deploy_a') { deploy vm a } stage('deploy_b') { deploy vm b } } } } How can I make sure that deployVm stages run when and only when respective createTemplate stages were successful? 回答1: You may want to run one parallel like this: parallel { stage('a') { stages { stage ('template_a') { ... }

Using Docker for Windows in Jenkins Declarative Pipeline

你说的曾经没有我的故事 提交于 2021-02-07 21:50:26
问题 I am setting up a CI workflow with Jenkins declarative pipeline and Docker-for-Windows agents through Dockerfile . Note: It is unfortunately currently not a solution to use a Linux-based docker daemon, since I need to run Windows binaries. Setup: Jenkins master runs on Linux 16.04 through Docker. Jenkins build agent is Windows 10 Enterprise 1709 (16299.551) Docker-for-Windows 17.12.0-ce Docker 18.x gave me headaches when trying to use Windows Containers, so I rolled back to 17.x. I still had

Using Docker for Windows in Jenkins Declarative Pipeline

…衆ロ難τιáo~ 提交于 2021-02-07 21:50:18
问题 I am setting up a CI workflow with Jenkins declarative pipeline and Docker-for-Windows agents through Dockerfile . Note: It is unfortunately currently not a solution to use a Linux-based docker daemon, since I need to run Windows binaries. Setup: Jenkins master runs on Linux 16.04 through Docker. Jenkins build agent is Windows 10 Enterprise 1709 (16299.551) Docker-for-Windows 17.12.0-ce Docker 18.x gave me headaches when trying to use Windows Containers, so I rolled back to 17.x. I still had

Jenkins Triggering of a Build Step/Stage(not the entire job) at a given interval

自古美人都是妖i 提交于 2021-02-05 09:45:34
问题 I am trying to build a pipeline where i would need to chain multiple jobs and some of them has to start at a certain time. Ex: Job1(starts at Midnight) -> Job2 -> Job3 ->Job4(starts at 4 PM) Using Declarative Syntax: pipeline { agent any stages{ stage('Fetch Latest Code-1') { steps{ build job: 'Get Latest - All Nodes', quietPeriod: 60 } } stage('CI Day - 1') { parallel { stage('ANZ CI'){ steps{ build job: 'ANZ - CI', quietPeriod: 120 } } stage('BRZ CI'){ steps{ build job: 'BRZ_CI',

Jenkins: Schedule Particular Stage with single pipeline

六月ゝ 毕业季﹏ 提交于 2021-01-29 15:24:57
问题 I have a single pipeline where it' declarative and I've several stages such as below triggers via webhook. I would like to execute and scheduled Stage B at a certain time which can also run without trigger via webhook. Clearly it needs to run when triggers via webhook and also run when it will be schedule. Can I handle this without creating seperate job or pipeline in Jenkins ? stage('A'){ when{ beforeAgent true expression{return env.GIT_BRANCH == "origin/development"} } steps{ script{ //Do

Use special agent for whole pipeline when a condition is met

浪子不回头ぞ 提交于 2021-01-29 07:44:20
问题 There is declarative pipeline. In the beginning of pipeline block the agent selection is made using agent directive. Label-based selection is being conducted. Agent selected this way is the standard/default agent. How to set for whole pipeline a special agent when certain condition is met? The plan is to do condition check based on pipeline's one parameter >> can that work? What are the points the chosen approach needs to address? Current solution blueprint: Groovy code prior to pipeline

Use special agent for whole pipeline when a condition is met

北城余情 提交于 2021-01-29 07:30:21
问题 There is declarative pipeline. In the beginning of pipeline block the agent selection is made using agent directive. Label-based selection is being conducted. Agent selected this way is the standard/default agent. How to set for whole pipeline a special agent when certain condition is met? The plan is to do condition check based on pipeline's one parameter >> can that work? What are the points the chosen approach needs to address? Current solution blueprint: Groovy code prior to pipeline

jenkins pipeline : How to execute a function on a list of agents in parallel?

本小妞迷上赌 提交于 2021-01-29 05:22:48
问题 I have a bunch of nodes serving labels rhel6 , rhel7 . How do I execute myFunc() on any 2 nodes of rhel6 and any 3 nodes rhel7 - in parallel ? def slaveList = ['rhel6', 'rhel6', 'rhel7', 'rhel7', 'rhel7'] def stageFunc (String slaveLabel) { return { // Run this stage on any available node serving slaveLabel agent { label "${slaveLabel}" } // Error shown here. stage { myFunc() } } } pipeline { agent any stages { stage('Start') { steps { script { def stageMap = [:] def i = 0 slaveList.each { s

How to cleanup pipeline before checkout of repository in Jenkinsfile

末鹿安然 提交于 2020-12-12 11:39:48
问题 I want to make a clean before checkout operation which is described in Jenkins git plugin documentation: Clean before checkout Clean the workspace before every checkout by deleting all untracked files and directories, including those which are specified in .gitignore. ... But how can add this option to default checkout step which is doing as first step? I feel that it should be an option extended by git plugin which can be included to options block of Jenkinsfile as described in docs: The

Condition in Jenkins pipeline on the triggers directive

一笑奈何 提交于 2020-12-12 11:36:33
问题 Jenkins has a nice relatively comprehensive documentation about Jenkinsfile syntax. But I still not find there an answer is it possible to do a flow control on the top level of pipeline? Literally include something if just in pipeline {} section (Declarative) like: pipeline { if (bla == foo) { triggers { ...configuration } } or pipeline { triggers { if (bla == foo) { something... } } } triggers section is a section which can be included only once and only in the pipeline section. But if