jenkins-pipeline

Multi-branch configuration with externally-defined Jenkinsfile

时光毁灭记忆、已成空白 提交于 2019-12-23 22:04:04
问题 I have an open-source project, that resides in GitHub and is built using a build farm, controlled by Jenkins. I want to build it branch-wise using a pipeline, but I don't want to store Jenkinsfile inside the code. Is there a way to accomplish this? 回答1: First of all, why do you not want a Jenkinsfile in your code? The pipeline is just as much part of the code as would be your build file. Other then that, you can load groovy files to be evaluated as a pipeline script. You can do this either

jenkins pipeline: can't pass build parameters to shared library vars

白昼怎懂夜的黑 提交于 2019-12-23 20:00:55
问题 Basically I can't pass build properties to Library var call without extra nonsense. jenkinsfile relevant chunk: tc_test{ repo = 'test1' folder = 'test2' submodules = true refs = params.GitCheckout } That results in error java.lang.NullPointerException: Cannot get property 'GitCheckout' on null object This, however, works: def a1 = params.GitCheckout tc_test{ repo = 'test1' folder = 'test2' submodules = true refs = a1 } The contents of the vars/tc_test.groovy in shared library : def call (

cucumber-js parse error when run on Jenkins

不问归期 提交于 2019-12-23 18:50:53
问题 I am trying to setup a jenkins pipeline step to runs some test scenarios using cucumber-js but I am getting an error back from the build as follows: Error: Parse error in 'e2e/definitions/login.js': (1:1): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'const { Given, When, Then } = require('cucumber');' The command being run in the pipeline step is as follows: cucumber-js e2e/features/**/*.feature --require e2e/**/*.js The opening lines of the login.js file the

Iterating a groovy list in Jenkins Pipeline DSL

人走茶凉 提交于 2019-12-23 18:30:03
问题 I have a simple groovy list in my Pipeline that adds some maps: def componentList = [] def componentMapEntry1 = [:] componentMapEntry1['componentName']="Dashboard_Core" componentList << componentMapEntry1 def componentMapEntry2 = [:] componentMapEntry2['componentName']="Dashboard_Equities" componentList << componentMapEntry2 def cme3 = [:] cme3["componentName"] = "home" componentList << cme3 When job is executed, I validate size echo "size of list "+componentList.size() ... [Pipeline] echo

Get information about other branches from within a Jenkinsfile

做~自己de王妃 提交于 2019-12-23 17:11:24
问题 Jenkins Blue Ocean is running on the same local network as a linked Bitbucket Server instance. A multibranch project in Jenkins is able to create a branch for each branch of a linked Bitbucket repository on the local Bitbucket Server. But within the Jenkinsfile, I am not able to get information about the other branches. What specific syntax needs to be added to the simplified Jenkinsfile below in order for the resulting console log to: 1. Print a complete list of all the branches in the

How to avoid Jenkins multibranch pipeline job triggering itself

匆匆过客 提交于 2019-12-23 10:19:11
问题 I would like my Jenkins multibranch pipeline job to avoid triggering itself. The job makes a commit because it increments the version file and checks it into source control which causes an endless loop. In a regular job I can follow these instructions to avoid this loop (although it's not the cleanest way). The instructions do not work for a multibranch pipeline (there is no 'ignore commits from certain users' option). Is there any way in a Jenkins mulitbranch pipeline to prevent a self

Get error reason in Jenkinsfile failure

Deadly 提交于 2019-12-23 10:00:01
问题 I have the following post failure section: post { failure { mail subject: "\u2639 ${env.JOB_NAME} (${env.BUILD_NUMBER}) has failed", body: """Build ${env.BUILD_URL} is failing! |Somebody should do something about that""", to: "devel@example.com", replyTo: "devel@example.com", from: 'jenkins@example.com' } } I would like to include the reasons why the build failed in the body of the error message. How can I do that? If not, is there a way to attach the build log file to the email? 回答1: I don't

How do I assure that a Jenkins pipeline stage is always executed, even if a previous one failed?

天涯浪子 提交于 2019-12-23 08:26:39
问题 I am looking for a Jenkinsfile example of having a step that is always executed, even if a previous step failed. I want to assure that I archive some builds results in case of failure and I need to be able to have an always-running step at the end. How can I achieve this? 回答1: try { sh "false" } finally { stage 'finalize' echo "I will always run!" } 回答2: We switched to using Jenkinsfile Declarative Pipelines, which lets us do things like this: pipeline { agent any stages { stage('Test') {

Pass variables between Jenkins stages

一世执手 提交于 2019-12-23 07:45:50
问题 I want to pass a variable which I read in stage A towards stage B somehow. I see in some examples that people write it to a file, but I guess that is not really a nice solution. I tried writing it to an environment variable, but I'm not really successful on that. How can I set it up properly? To get it working I tried a lot of things and read that I should use the """ instead of ''' to start a shell and escape those variables to \${foo} for example. Below is what I have as a pipeline: #!/usr

Linux machine failed to connect slave from mac machine connection in Jenkins?

本秂侑毒 提交于 2019-12-23 05:00:49
问题 Installed Jenkins on Linux machine and jenkins hosted on name say jiort04:8080. Created slave name it as mac-slave in Jenkins and launch method used it as Launch agent via Java Web Start Method and necessary configurations are added. However, it failed to connect to slave said logs and error attached below screen-shot. Log ` java.net.UnknownHostException: jiort04 at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184) at java.net.SocksSocketImpl.connect(SocksSocketImpl