jenkins-groovy

How to Backup Jenkins using Jenkinsfile

久未见 提交于 2021-01-26 03:04:08
问题 How To do Jenkins jobs configuration backup using Jenkinsfile without plugins? things to be backup : system configuration {jenkins} jobs configuration 回答1: We were not happy with the plugins backup solutions, so we have a freestyle shell step job run on master (usually a no-no, so only allow managed special task like backup to run there) with a simple tar cmd, one for system config (xmls, keys, etc), one for jobs (excluding logs 'n stuff). System backup In ${JENKINS_HOME} , you'll want to

How to Backup Jenkins using Jenkinsfile

♀尐吖头ヾ 提交于 2021-01-26 03:04:05
问题 How To do Jenkins jobs configuration backup using Jenkinsfile without plugins? things to be backup : system configuration {jenkins} jobs configuration 回答1: We were not happy with the plugins backup solutions, so we have a freestyle shell step job run on master (usually a no-no, so only allow managed special task like backup to run there) with a simple tar cmd, one for system config (xmls, keys, etc), one for jobs (excluding logs 'n stuff). System backup In ${JENKINS_HOME} , you'll want to

The same shell command behaves differently if it is located in different stages of Jenkins pipeline

怎甘沉沦 提交于 2021-01-07 06:38:15
问题 I'm trying to execute following stage in Jenkins pipeline stage('RUN') { steps{ dir("airflow-dags") { sh "find ./volumes/dags/ -maxdepth 1 -name '*.py' -print0" } } } If this stage is located in the last position (after deploy and other stuff) it returns nothing: 08:56:58 Running in /home/jenkins/workspace/QA_deploy_Docker/airflow-dags [Pipeline] { [Pipeline] sh 08:56:59 + find ./volumes/dags/ -maxdepth 1 -name '*.py' -print0 [Pipeline] } [Pipeline] // dir [Pipeline] } [Pipeline] // stage If

The same shell command behaves differently if it is located in different stages of Jenkins pipeline

有些话、适合烂在心里 提交于 2021-01-07 06:37:33
问题 I'm trying to execute following stage in Jenkins pipeline stage('RUN') { steps{ dir("airflow-dags") { sh "find ./volumes/dags/ -maxdepth 1 -name '*.py' -print0" } } } If this stage is located in the last position (after deploy and other stuff) it returns nothing: 08:56:58 Running in /home/jenkins/workspace/QA_deploy_Docker/airflow-dags [Pipeline] { [Pipeline] sh 08:56:59 + find ./volumes/dags/ -maxdepth 1 -name '*.py' -print0 [Pipeline] } [Pipeline] // dir [Pipeline] } [Pipeline] // stage If

The same shell command behaves differently if it is located in different stages of Jenkins pipeline

浪子不回头ぞ 提交于 2021-01-07 06:37:14
问题 I'm trying to execute following stage in Jenkins pipeline stage('RUN') { steps{ dir("airflow-dags") { sh "find ./volumes/dags/ -maxdepth 1 -name '*.py' -print0" } } } If this stage is located in the last position (after deploy and other stuff) it returns nothing: 08:56:58 Running in /home/jenkins/workspace/QA_deploy_Docker/airflow-dags [Pipeline] { [Pipeline] sh 08:56:59 + find ./volumes/dags/ -maxdepth 1 -name '*.py' -print0 [Pipeline] } [Pipeline] // dir [Pipeline] } [Pipeline] // stage If

How to create dynamic checkbox parameter in Jenkins pipeline?

↘锁芯ラ 提交于 2020-12-15 04:38:07
问题 I found out how to create input parameters dynamically from this SO answer agent any stages { stage("Release scope") { steps { script { // This list is going to come from a file, and is going to be big. // for example purpose, I am creating a file with 3 items in it. sh "echo \"first\nsecond\nthird\" > ${WORKSPACE}/list" // Load the list into a variable env.LIST = readFile (file: "${WORKSPACE}/list") // Show the select input env.RELEASE_SCOPE = input message: 'User input required', ok:

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

Is there any way to list latest Nexus Artifacts in Jenkins?

和自甴很熟 提交于 2020-12-07 08:10:12
问题 I am using Acive Choice Reactive Parameter plugin to list down Nexus Artifacts. This is the groovy script which I'm currently using. import groovy.json.* def targetUrl = "https://nexus.xxxx.lk/service/rest/v1/search?repository=snapshots&format=maven2&group=com.org.pro&name=pro-service" def jsonSlupper = new JsonSlurper().parse(URI.create(targetUrl).toURL()) def list = jsonSlupper["items"]["version"].collect().sort().reverse() I want to display only latest artifact in the list. Does anyone

how to run jenkins declarative pipeline on node selected via parameter and label option

孤人 提交于 2020-11-29 10:29:47
问题 I want to run a pipeline with the node set as parameter via the Node and Label plugin. How do I change the declarative pipeline pipeline { agent { label 'whatever' } ... to use EXECUTION_NODE as agent to execute the pipeline? This seems to be much more complicated than I thought, or I am missing something obvious. 回答1: The issue is this: to present you the "Build with parameters" page, Jenkins needs to run your pipeline and parse its parameters. To run a pipeline, Jenkins needs a node. To