jenkins-pipeline

Jenkins Copy Artifact unable to find folder/multiProjectPipeline/branchWithSlash

爷,独闯天下 提交于 2019-12-10 21:14:46
问题 I have Jenkins LTS 2.60.2 on Windows Server 2016 and using these plugins: Folders plugin (6.1.0) Copy Artifact plugin (1.38.1) Pipeline plugin (2.5) + all dependent pipeline sub-plugins Various other dependent plugins... See Pipeline to use artifacts from 2 projects associated by the same git branch name for more details about my setup, but to sum it up I have these items: playground (a folder created with the Folders plugin to group all these following items) frontend (multibranch pipeline)

Run nightly jobs on multibranch pipeline with declarative Jenkinsfile

落花浮王杯 提交于 2019-12-10 21:03:49
问题 Jenkins version 2.121.2 I have a multi-branch pipeline set up. I am using a declarative Jenkinsfile. I have a set of tests which take a long time to run. I want these to run over night for any branches which have changes. I have tried a few things but my current failing attempt is: Under the job > configure, I have enabled 'Suppress automatic SCM triggering' Have 'Scan Multibranch Pipeline Triggers' > 'Periodically if not otherwise run' set to 1 minute (just for testing, I will increase this

should I use Jenkins heavyweight or flyweight executors for notifications?

China☆狼群 提交于 2019-12-10 19:16:58
问题 I have few steps in my Jenkins pipeline that notify users, in my case using Slack integration. is it a good practice to write the notification code inside a node block to use a heavyweight executor or just leave it outside to make use of a flyweight executor? According to the documentation: Every Pipeline build itself runs on the master, using a flyweight executor — an uncounted slot that is assumed to not take any significant computational power. This executor represents the actual Groovy

Jenkins groovy regex match string : Error: java.io.NotSerializableException: java.util.regex.Matcher

烈酒焚心 提交于 2019-12-10 18:55:14
问题 I'm trying to get the matched string from a regex in groovy. The matched string prints to the console without problems, but when I try use the matched string in a git command I get the following error: Err: Incremental Build failed with Error: java.io.NotSerializableException: java.util.regex.Matcher Here is the code: def binaryName = "298_application_V2_00_Build_07.hex" def matches = (binaryName =~ /(V)(\d+)(_)(\d+)(_)(Build)(_)(\d+)/) versionTag = ""+matches[0].getAt(0) echo "${matches}"

Jenkins ssh-agent starts and then stops immediately in pipeline build

拈花ヽ惹草 提交于 2019-12-10 18:45:37
问题 I have a simple jenkins pipeline build, this is my jenkinsfile: pipeline { agent any stages { stage('deploy-staging') { when { branch 'staging' } steps { sshagent(['my-credentials-id']) { sh('git push joe@repo:project') } } } } } I am using sshagent to push to a git repo on a remote server. I have created credentials that point to a private key file in Jenkins master ~/.ssh. When I run the build, I get this output (I replaced some sensitive info with *'s): [ssh-agent] Using credentials *** (*

Job based security per branch - Jenkins Multibranch pipeline

依然范特西╮ 提交于 2019-12-10 18:44:21
问题 I have a Jenkins multi-branch pipeline for building artifacts and there are branches for master , *-dev etc. I want to enable project based security on a per branch basis, ie only allow devs to run the *-dev branch jobs of the build not any other ones because doing so would have undesirable effects. I know there is project based security, but I didn't see any per branch. Does this exist? We are behind in updating Jenkins and are currently running Jenkins 2.46.1 . Otherwise I am thinking I

Determine Failed Stage in Jenkins Scripted Pipeline

柔情痞子 提交于 2019-12-10 18:29:35
问题 I am looking for a generic way to determine the name of the failed stage at the end of a Jenkins scripted Pipeline. Please note that this is different than Determine Failed Stage in Jenkins Declaritive Pipeline which is about declarative pipeline. Also note that use of try/catch inside each stage is out of question because it would make the pipeline script impossible to read. This is because we have like 10-15 stages which are stored in multiple files and they are compiled using JJB to create

Checkout a tag in Jenkins pipeline

♀尐吖头ヾ 提交于 2019-12-10 18:12:47
问题 Tried using checkout scm: [$class: 'GitSCM', userRemoteConfigs: [[url: '${repoURL}']], branches: [[name: 'refs/tags/${tag-version}']]],poll: false This fails with an Authentication error. Is there any way other than using withCredentials to checkout tag in a Jenkinsfile 回答1: After spending, hours got here Correct way to use GitSCM in declarative pipeline is checkout scm: [$class: 'GitSCM', userRemoteConfigs: [[url: repoURL, credentialsId: credential]], branches: [[name: tag-version]]],poll:

Using Jenkins Shared Libraries as classes

徘徊边缘 提交于 2019-12-10 18:06:12
问题 I have a Jenkins file, and i'm trying to instantiate a groovy class from my shared library. I get "unable to resolve class Test " I have a src/com/org/foo.groovy file in a shared library : package com.org class Test implements Serializable{ String val Test(val) { this.val = val } } and I'm trying to instantiate it in my jenkinsfile @Library('Shared-Library@master') import com.org //also tried to use with .foo with no success def t = new Test("a") //doesnt work def t = new foo.Test("a")/

How do I get the build number from where I executed a rebuild?

北慕城南 提交于 2019-12-10 17:37:31
问题 When I click "rebuild" from the page of a build jenkins rebuilds and runs a new job- a new job with a new jenkins build number. How do I get the build number of the job where I executed the rebuild? Im not talking about the previous build number. Say Im on build 10. I go to build 5 and click rebuild. How do I that build number (5) from inside the pipeline like I can with env.BUILD_NUMBER ? 回答1: I assume that you are using Groovy Pipeline and already know the Global Variable (see Global