jenkins-pipeline

Run Powershell script from file in Jenkins pipeline

≯℡__Kan透↙ 提交于 2019-12-03 16:18:17
I am trying to run a Powershell script from a file in a Jenkins pipeline. I have read this which shows how to run powershell scripts that are entered into the pipeline, but I can't get a script to run from a file. I have tried: powershell returnStatus: true, script: '-File build.ps1' and various combinations but can't figure out how to do this. Figured it out soon after, the line should have read powershell returnStatus: true, script: '.\\build.ps1' 来源: https://stackoverflow.com/questions/46726756/run-powershell-script-from-file-in-jenkins-pipeline

Jenkins does not recognize command sh?

大城市里の小女人 提交于 2019-12-03 16:06:42
问题 I've been having a lot of trouble trying to get a Jenkinsfile to work. I've been trying to run this test script: #!/usr/bin/env groovy node { stage('Build') { echo 'Building....' // Create virtualenv sh 'echo "hi"' } stage('Test') { echo 'Building....' } stage('Deploy') { echo 'Deploying....' } } But I keep getting this error when trying to build: Warning: JENKINS-41339 probably bogus PATH=/usr/lib64/ccache:/usr/lib64/ccache:$PATH; perhaps you meant to use ‘PATH+EXTRA=/something/bin’? [test

Ideas to implement dynamic parallel build using jenkins pipeline plugin

心已入冬 提交于 2019-12-03 15:50:12
I have a requirement to run a set of tasks for a build in parallel, The tasks for the build are dynamic it may change. I need some help in the implementation of that below are the details of it. I tasks details for a build will be generated dynamically in an xml which will have information of which tasks has to be executed in parallel/serial example: say there is a build A. Which had below task and the order of execution , first task 1 has to be executed next task2 and task3 will be executed in parallel and next is task 4 task1 task2,task3 task4 These details will be in an xml dynamically

Gitlab webhook does not trigger a build on jenkins

时间秒杀一切 提交于 2019-12-03 15:33:39
问题 I've a group of multibranch pipeline jobs generated with the following piece groovy script: [ 'repo1', 'repo2', ].each { service -> multibranchPipelineJob(service) { displayName(service) branchSources { git { remote("git@gitlab.com:whatever/${service}.git") credentialsId('gitlab-ssh-key') } } orphanedItemStrategy { discardOldItems { daysToKeep(0) numToKeep(30) } } triggers { periodic(5) } } } and in each repo a Jenkinsfile that looks as follows: #!/usr/bin/env groovy properties([

Jenkins Declarative Pipeline with extended choice parameter

本小妞迷上赌 提交于 2019-12-03 15:29:12
I tried out to implement my first Declarative Pipeline with Jenkins to be able to put also the parameter definitions of a job under SCM. I wanted to transfer an existing job that has an extended choice paraemter. Unfortunately I was not able to add it to the parameters{...} section of my script. On the plugin page: https://wiki.jenkins-ci.org/display/JENKINS/Extended+Choice+Parameter+plugin I found a comment that stated it should be possible by: import com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition def type = "PT_JSON" def groovyScript = null def

How to wait for user input in a Declarative Pipeline without blocking a heavyweight executor

雨燕双飞 提交于 2019-12-03 15:14:00
问题 I'm rebuilding an existing build pipeline as a jenkins declarative pipeline (multi-branch-pipeline) and have a problem handling build propagation. After packaging and stashing all relevant files the pipeline is supposed to wait for user input to trigger deployment. If i just add an input step the current build-node is blocked. As this executor is pretty heavy i would like to move this step to a more lightweight machine. Initially i did the job as a scripted pipeline and just created two

Parsing an XML file within a Jenkins pipeline

折月煮酒 提交于 2019-12-03 15:11:10
I have an XML file which I'd like to use as input for a pipeline script. Problem is the XMLParser isn't serializable so I put it in a NonCPS function, but I lost the Node object because of that. This is the pipeline script: def buildPlanPath = 'C:\\buildPlan_test.xml' @NonCPS groovy.util.Node getBuildPlan(path) { new XmlParser().parseText(readFile(path)) } node { //def buildPlan = new XmlParser().parseText(readFile(buildPlanPath)) groovy.util.Node buildPlan = getBuildPlan(buildPlanPath) println buildPlan.getClass() println buildPlan println buildPlan.branch } This is an input sample: <branch

Jenkins Pipeline Builds: Viewing Workspace in the UI

主宰稳场 提交于 2019-12-03 14:56:43
问题 We are now experimenting with multi-branch Pipeline builds. The main advantage of the feature is that it allows us to automatically create new Jenkins jobs whenever a new branch is created. However, it also is a bit more difficult to implement than the old way of selecting how to do the build using the UI. Plus, certain features seem to be missing. For example, in Jenkins Freestyle jobs, we are able to use the Jenkins UI to browse through the workspace, download individual files, and even

How to disable command output in jenkins pipeline build logs

穿精又带淫゛_ 提交于 2019-12-03 14:45:18
问题 I am using Jenkinsfile for scripting of a pipeline. Is there any way to disable printing of executed shell commands in build logs? Here is just a simple example of a jenkins pipeline: node{ stage ("Example") { sh('echo shellscript.sh arg1 arg2') sh('echo shellscript.sh arg3 arg4') } } which produces the following output in console log: [Pipeline] node Running on master in /var/lib/jenkins/workspace/testpipeline [Pipeline] { [Pipeline] stage [Pipeline] { (Test) [Pipeline] sh [testpipeline]

How to set and reference a variable in a Jenkinsfile

孤街醉人 提交于 2019-12-03 14:38:38
问题 I have a declarative pipeline script for my multibranch project in which I would like to read a text file and store the result as a string variable to be accessed by a later step in the pipeline. Using the snippet generator I tried to do something like this: filename = readFile 'output.txt' For which filename would be my string. I get an error in the Jenkins console output: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: 30: Expected a step @