jenkins-pipeline

Pipeline to use artifacts from 2 projects associated by the same git branch name

元气小坏坏 提交于 2019-12-13 02:58:18
问题 the company where I work for is evaluating jenkins 2.71, in particular the pipeline and blue ocean plugins. We already tested also GoCD and we need, as in GoCD , a way for a pipeline to automatically fetch the artifacts from 2 other pipelines (taking the last successful result of each one of them), here our case. We have these initial pipelines (build & run tests), which reflect 2 projects: frontend , ~ 15 minutes backend , ~10 minutes I created a pipeline called configure (~1 minute), with e

how to get numeric values after special character in a string in pipeline

核能气质少年 提交于 2019-12-13 02:52:09
问题 In my pipeline I have a variable abd with value " xyz #123 ". I need to get only numeric value after special character # , How do I achieve this in Jenkins Pipeline? 回答1: You can do this in Groovy fairly simply (if your string always matches that pattern): abc.substring(abc.indexOf('#') + 1, abc.length()) That will give you the string 123. 来源: https://stackoverflow.com/questions/49744462/how-to-get-numeric-values-after-special-character-in-a-string-in-pipeline

NonSerializableException inside script block

六月ゝ 毕业季﹏ 提交于 2019-12-13 02:39:30
问题 I get a NonSerializableException when i put my test() call inside a script, when I commented out line A and uncommented out line B , it works just fine. What's the difference from calling test() inside a script and outside of it? The workaround I'm considering for now is to use the when conditions for Jenkinsfile UPDATE I suspect that the error is related to Commands Requiring a “node” Block Jenkinsfile #!/usr/bin/env groovy import groovy.json.JsonSlurper @NonCPS def test() { sh "aws ecs

Common wrapper in Jenkinsfile

核能气质少年 提交于 2019-12-13 00:26:01
问题 I want to add timestamps() and colorizeOutput() features to our pipeline libraries. I find the wrappers {} in Jenkins documentation: job('example') { wrappers { colorizeOutput() timestamps() } } I don`t get how to add wrappers to out library which looks like that: // file ..src/helpers/Builder.groovy package helpers.sw_main def doSomething() { // some Groovy stuff here } def doSomethingElse() { // do something else } Our job pipeline looks like that: #!/usr/bin/env groovy // this is our

Running Jenkins parallel tasks sequentially

一曲冷凌霜 提交于 2019-12-12 23:16:33
问题 I'm writing a new Jenkins pipeline and have a set of steps that I would eventually like to run in parallel. But while I'm developing this pipeline I'd like to force it to run sequentially. I'm not seeing any way to specify the number of threads a parallel step uses or anything like that. Here is the basic code so far: node('x') { stage('cleanup'){ def cleanupScripts = [:] cleanupScripts[1] = { sh(script: "cleanup1.sh") } cleanupScripts[2] = { sh(script: "cleanup2.sh") } cleanupScripts[3] = {

How to get environment parameters in pipeline compitable jenkins SimpleBuildStep plugin?

佐手、 提交于 2019-12-12 23:11:56
问题 I just added pipeline compitability but I can't get any of env parameters. My class have a definition as below: public class JobBuildStep extends Builder implements SimpleBuildStep and perform method: public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath workspace, @Nonnull Launcher launcher, @Nonnull TaskListener listener) throws AbortException Could anyone please tell me what are the options to fix it? I also found an issue with it - https://issues.jenkins-ci.org/browse/JENKINS

Jenkins pipeline share information between jobs

拥有回忆 提交于 2019-12-12 23:01:22
问题 We are trying to define a set of jobs on Jenkins that will do really specific actions. JobA1 will build maven project, while JobA2 will build .NET code, JobB will upload it to Artifactory, JobC will download it from Artifactory and JobD will deploy it. Every job will have a set of parameters so we can reuse the same job for any product (around 100). The idea behind this is to create black boxes, I call a job with some input and I get always some output, whatever happens between is something

How to continue a stage in jenkins pipeline even if the build fails

回眸只為那壹抹淺笑 提交于 2019-12-12 22:29:36
问题 So I have a pipeline with multiple stages and with each stage there are couple of build job processes. When I run the pipeline and there is a failure in any one of the builds the stage fails and doesn't build the other builds in the stage. How can I get around this so it builds the remaining jobs in the stage? 回答1: you can use the convention try { // your build steps } finally { // always run... } 来源: https://stackoverflow.com/questions/40942178/how-to-continue-a-stage-in-jenkins-pipeline

How to automatically change the Quality Gate?

假如想象 提交于 2019-12-12 20:37:20
问题 We are using Jenkins as our CI server, and Sonarqube for code analysis. Currently we are using SonarQube 4.5.7 and we want to upgrade to version 6.5. We have several quality gates, and we can't find an automatic way to assign the quality gate to the project. In previous version we used the sonar.QualityGate property, but this property is now deprecated. How can we let Jenkins setup the quality gate before it starts the analysis? 回答1: Use the sonar.branch property to run branch the analysis. I

Unable to run shell script inside Jenkins pipeline

情到浓时终转凉″ 提交于 2019-12-12 18:25:51
问题 I'm able to run the following shell script but couldn't run from Jenkins pipeline code. Try 1. node('buildnode') { def value = "Myvalue" def key = "Mykey" sh ''' DATA=$(printf "%-50s \"$key\"" "$value") echo "$DATA" ''' } output: ++ printf '%-50s ' '' + DATA=' Try 2: Tried with sh " " " DATA=$(printf "%-50s \"$key\"" "$value") echo "$DATA" " " " output: : illegal string body character after dollar sign; solution: either escape a literal dollar sign "\$5" or bracket the value expression "${5}"