jenkins-pipeline

Value returned from a script does not assigned to a variable declared in jenkins declarative pipeline stage

被刻印的时光 ゝ 提交于 2019-12-13 07:48:19
问题 I am working on adding a jenkins Declarative pipeline for automation testing. In the test run stage i want to extract the failed tests from the log. i am using a groovy function for extracting the test result. this function is not a part of the jenkins pipeline. It is another script file. The function works fine and it build a string containing the failure details. Inside a pipeline stage i am calling this function and assinging the returned string to another variable. But when i echo the

Jenkins Multibranch Pipeline workspace configuration

╄→гoц情女王★ 提交于 2019-12-13 05:16:16
问题 I'm bumping up against JENKINS-38706. And since its been open for a while, i'm trying to work around it. My problem is that i'm running a multinode pipeline, with one of the nodes being a windows slave, with the 255 character path limitations. So, i'm trying to change the workspace for my windows slave stages, and instead of using C:\jenkins\workspace\job-branch-randomcharacters that the multibranch pipeline uses, i'm trying to move it to c:\w\job\branch. It immediately fails with: Branch

Jenkins declarative pipeline 1.3 run parallel for all jobs

╄→尐↘猪︶ㄣ 提交于 2019-12-13 05:13:39
问题 I have setup a pipeline project similar to https://jenkins.io/doc/book/pipeline/syntax/#parallel-stages-example and it works fine. But I have created the same project for different jobs, so rather than creating new jobs can I run for loop for all jobs e.g. jobs = [job1, job2, job3] and run above pipeline code for different jobs. Something similar to https://jenkins.io/doc/book/pipeline/syntax/#script-example Can I use a for loop or similar logic to run a declarative pipeline? I found similar

Azure provisioning with Jenkins

家住魔仙堡 提交于 2019-12-13 04:24:43
问题 As part of QA pipeline(in Jenkins), goal is to automate provisioning and configuration of a VM to run the QA tests. Jenkins pipeline can trigger Terraform code to automate provisioning of VM and ansible code for configuration of a VM, but, issues like rollback , error handling is not easy unless we use some vendor specific template like AzureResourceManager template. So, with Jenkins pipeline,What should be the best approach to provision and configure a VM in Azure cloud? we write pipeline

How to trigger a multiple run in a single pipeline job of jenkins?

回眸只為那壹抹淺笑 提交于 2019-12-13 04:06:19
问题 I have a pipeline job which run with below pipeline groovy script, pipeline { parameters{ string(name: 'Unique_Number', defaultValue: '', description: 'Enter Unique Number') } stages { stage('Build') { agent { node { label 'Build' } } steps { script { sh build.sh } } stage('Deploy') { agent { node { label 'Deploy' } } steps { script { sh deploy.sh } } stage('Test') { agent { node { label 'Test' } } steps { script { sh test.sh } } } } I just trigger this job multiple times with different

How to define a Label parameter in a parameterized build using scripted pipeline approach

六月ゝ 毕业季﹏ 提交于 2019-12-13 03:49:50
问题 I'm trying to solve the same problem as this SO question: How to trigger a jenkins build on specific node using pipeline plugin? The only difference in my case is that the job I'm triggering is another scripted pipeline job. So the second step in the proposed solution does not apply in my case: Install Node and Label parameter plugin In test_job's configuration, select 'This build is parameterized' and add a Label parameter and set the parameter name to 'node' In pipeline script, use code

Jenkins array variable in environment tag/body

我怕爱的太早我们不能终老 提交于 2019-12-13 03:47:39
问题 I would like to define an array of strings within the environment tag/body of the Jenkins pipeline. This doesn't seem to work; jenkins doesn't recognize the array. Environment variable values must either be single quoted, double quoted, or function calls. @ line x, column y. myArray= [ pipeline { agent { label 'Test' } environment { myArray = [ "Item1", "Item2", "Item3" ] } } The next code seems to work, but I would like to have all fields/ settings in the environment tag. def myArray = [

How to run multi stages at the same time using multi parallel blocks?

僤鯓⒐⒋嵵緔 提交于 2019-12-13 03:45:00
问题 Here, I need to execute both Parallel test 1 and Parallel test 2 at the same time. When I tried to put a parallel block on top of these, it throws an error since it mentioned like this in the official site Note: that a stage must have one and only one of steps, stages, or parallel . pipeline { agent any stages { stage('Parallel Test 1') { parallel { stage('Block 1 - Stage 1') { steps { echo "Block 1 - Stage 1" build(job: 'jenkins_job_1') } } stage('Block 1 - Stage 2') { steps { echo "Block 1

Sending a Mail on Jenkins Pipeline

不羁岁月 提交于 2019-12-13 03:19:49
问题 hi I have a simple pipeline job that should send a mail, I configured on Manage jenkins -> Configure System with port 465 and the appropriated SMTP server , when I test the configuration by sending a e-mail , it sends and I can see the test mail on my inbox , but from the pipeline job , it fails: node { stage("test") { def message = "hello there!" mail bcc: '', body: message, cc: '', from: 'jenkinsuser@mycom.com', replyTo: 'jenkinsuser@mycom.com', subject: "Develop: build generated ", to:

Jenkins pipeline not honoring agent specification

久未见 提交于 2019-12-13 03:18:34
问题 At the pipeline level I specify the agent and node (with both the label and custom workspace). When the pipeline kicks off it runs on the specified node, but when it hits the 'build job' picks the first available node. I tried playing with the NodeLabel plugin, but that didn't work either. This is my Jenkinsfile : pipeline { agent { node { label "Make Build Server" customWorkspace "$Workspace" } } options { skipDefaultCheckout() } stages { stage('PreBuild'){ steps{ input 'Did you authenticate