jenkins-pipeline

Jenkins pipeline: in stage1, read number from file, in stage2, **within** node name, use that number

对着背影说爱祢 提交于 2019-12-25 07:49:28
问题 To continue this: Jenkins pipeline stages - passing whole file I'm now stuck with having to set a number as part of a node name, where this number is contained within a file on another node. E.g, if a properties file contains the number 6, I have to run a job on a node named DEV-SME-6. Is there a way for me to: in stage1, read the number from a file on the master node, something like this: Env_number = readFile 'file_containing_an_integer_between_2_and_7.txt' then in stage2, within the node

How to obtain the folder where the Pipeline Jenkinsfile is checked out (Jenkins)

て烟熏妆下的殇ゞ 提交于 2019-12-25 07:13:39
问题 We're having a big project (in terms of size), that we're trying to build using a Jenkinsfile that is checked inside the project itself. In order to conserve disk space and build times we try to minimize the number of copies, so what we would want is to use the folder where the Jenkinsfile is checked out, since that is already a repo fully cloned. Manually investigating, I've seen that there is a workspace@script folder created inside the job's folder. That is folder path that I would like to

Can I restrict poll SCM job to be run only once in a day?

北战南征 提交于 2019-12-25 06:49:58
问题 I have a poll SCM job , which polls every 5 minutes for a change in Perforce. But I need the job to be triggered only when first edit happens for the files in perforce in a day. Can I restrict poll SCM job to be run only once in a day? 回答1: Jenkins itself does not provide this kind of behaviour ("run only for the very first change every day"). You need to split this down into two parts; the first one polling SCM, the second taking care that the job will not run more than once per day.

Jenkins Pipeline CPS global lib resource file for shell script purpose

我是研究僧i 提交于 2019-12-25 04:14:16
问题 I have a shell script that is common for many projects in side Jenkins, is it correct to put it into the resources folder and load it as below: def script = libraryResource 'build/package_indexes/build_push.sh' while this works: sh script but once I start making the build_push.sh script to accept arguments, it won't work since script is not a file... Second question is that is it correct to output that script variable into a temp file such as writeFile script '/tmp/tmp.sh' sh "/tmp/tmp.sh

invoke one Jenkinsfile of different repo to another jenkinsfile

那年仲夏 提交于 2019-12-25 03:35:32
问题 I have a Jenkinsfile-A like below, In this file,I need to invoke another Jenkinsfile-B after execution of all the stages. Jenkinsfile-A #!groovy​ pipeline { agent { label "" } triggers { pollSCM('*/5 * * * *') } stages { stage('Build Artifact') { steps { } } stage('Publish Artifact') { steps { } } }//stages post { always { deleteDir() /* clean up our workspace */ } } }//pipeline def jenkinsFile stage('Loading Jenkinsfile'){ jenkinsFile = fileLoader.fromGit('Jenkinsfile', 'git@bitbucket.org

BlueOcean - Jenkins not able to pull Docker Image for environment

南笙酒味 提交于 2019-12-25 02:22:53
问题 I am trying to use python image to build and test a very simple python project. But when I give Docker Image name in Jenkinsfile, it fails to pull the image. [drone-python_test-jenk-NVHH77CLU5PUMV6UVRK62EARJB3DUVF5FWILYVRZDXOE54RACN2Q] Running shell script + docker pull python Using default tag: latest Warning: failed to get default registry endpoint from daemon (Cannot connect to the Docker daemon. Is the docker daemon running on this host?). Using system default: https://index.docker.io/v1/

Get Global Variables in jenkins pipeline

删除回忆录丶 提交于 2019-12-25 02:22:30
问题 I'm creating a jenkins pipeline which is used on different environments / builds. Each Build has different parameters: deploy destination, passwords, usernames etc. I have some common settings all these builds share, which i have added in the "Jenkins" -> "Configuration" -> "Global properties" as a key value. Lets say i have added a key value par with : Name : CommonName Value : Money I now want to be able to, in my pipeline, to access this CommonName variable. I've tried everything. println

Trouble reading Secrets from Jenkins Credential Manager in Multi Branch Pipeline job using Credential Parameter

北城以北 提交于 2019-12-25 02:15:48
问题 I have a Jenkins multi branch pipeline job that uses a secret value in Jenkinsfile : pipeline { agent any stages { stage('Test') { steps { echo "DOCKER_REGISTRY_USER is ${env.DOCKER_REGISTRY_USER_NSV}" } } } } The secret value is stored in Credentials Manager as secret text with the ID DOCKER_REGISTRY_USER_NSV : I'm trying to read this value in Jenkinsfile as shown above but I get the following output that prints out the value null for my secret: [Pipeline] } [Pipeline] // stage [Pipeline]

Jenkins Blue Ocean with TFS 2013 & GIT - Saving Pipelines is unsupported using http/https repositories. Please use SSH instead

孤街浪徒 提交于 2019-12-25 02:09:25
问题 I recently set up Jenkins with the Blue Ocean plugin and have it building off a number of Git repos hosted on our TFS 2013. I updated the plugins and Jenkins so they are running the latest version. When I went to add a new pipeline for a new Git repo it is now saying: "Warning - Saving Pipelines is unsupported using http/https repositories. Please use SSH instead." When I try to add the pipeline it tells me "Repository URL - Please enter a valid URL.". This is the URL that TFS is giving me to

Groovy jenkins pipeline @NonCPSreturn not expected results

假装没事ソ 提交于 2019-12-25 01:45:11
问题 In my code I have a method that parse log file and return list of results. Without NonCPS it works perfect and return correct values. This method is called from pipeline stages and I got java.io.NotSerializableException: java.util.regex.Matcher that's why I put @NonCPS annotation. Exception is not thrown anymore but log_parser method doesnt work well. Now it always return whole file - even if remove return result_list. The result of calling this method is always file. @NonCPS def log_parser