jenkins-pipeline

Sonar Gerrit plugin not reporting results

ⅰ亾dé卋堺 提交于 2019-12-19 12:05:29
问题 We utilize the pipeline and after the build completes successfully we are running the following: bat "mvn sonar:sonar -B -s ${buildSettings} -Dsonar.analysis.mode=preview -Dsonar.skipDesign=true -Dsonar.report.export.path=sonar-report.json" sonarToGerrit(severity: 'Major', postScore: true, category: 'Code-Review', newIssuesOnly: true, issuesScore: '0', noIssuesScore: '0', changedLinesOnly: true) The below build log shows that it found a good number of issues but yet the issues to be commented

Triggering Jenkins build on both new tags & commits

半腔热情 提交于 2019-12-19 08:00:16
问题 We are using the Git Plugin : https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin Currently, via webhooks we start a Jenkins build whenever a change is pushed to GitHub. Now we want to trigger the same build when a new tag is added. So we have two triggering conditions : A code change is pushed to GitHub A tag is created If we try the fix mention in this thread then the builds start only for tags. jenkins trigger build if new tag is released How can we do it for both scenarios ? Question #

Jenkins EnvInject plugin + Pipeline job

回眸只為那壹抹淺笑 提交于 2019-12-19 07:10:28
问题 I would like to use EnvInject plugin within my pipeline job. So, I have a possibility to set checkbox "Prepare an environment for the run", but there is no action "Inject environment variables", like in freestyle job. I declared my variables in "Properties Content" block: How to inject environment variables in pipeline job using EnvInject? 回答1: If you declared following variables in "Properties Content" block: param1=value1 param2=value2 Then you can get them into pipeline here so: //do

Determine Failed Stage in Jenkins Declarative Pipeline

ⅰ亾dé卋堺 提交于 2019-12-19 05:34:25
问题 How do I report the stage in which a declarative pipeline failed? In the fail block, I want to get failedStage.name and report it (eventually to slack). pipeline { agent { label 'master'} stages { stage('Ok') { steps { echo 'do thing' } } stage('NotOK') { steps { sh 'make fail' } } } post { always { echo 'ok' } failure { echo 'Failed during Which Stage?' } } } 回答1: Instead of adding post section in every stage, I found some solution that shouldn't be working in Declarative Pipeline from my

Jenkins Pipeline Utility Steps - zip zipFile

别等时光非礼了梦想. 提交于 2019-12-19 03:08:22
问题 I am trying to zip the folders which are created as output of my jenkins pipeline job using pipeline script. By googling i came to know the Jenkins Pipeline Utility Steps - zip zipFile https://jenkins.io/doc/pipeline/steps/pipeline-utility-steps/#code-zip-code-create-zip-file to zip folders/files but could not get exact pipeline syntax to zip. In my job workspace, I have a folder by name 'Test' which has 2 sub folders as 'Test1', 'Test2'. Each sub folder will have .dll files. So, I would like

How to restrict the jenkins pipeline docker agent in specific slave?

旧街凉风 提交于 2019-12-18 19:44:19
问题 I have several jenkins slaves configured and only label with dockerserver has docker env, then how can I restrict the jenkins pipeline docker agent in this slave? Below Jenkinsfile doesn't work, the agent inside stage will overwrite the defined slave dockerserver pipeline { agent { label 'dockerserver' } stages { stage('Back-end') { agent { docker { image 'maven:3-alpine' } } steps { sh 'mvn --version' } } stage('Front-end') { agent { docker { image 'node:7-alpine' } } steps { sh 'node -

Getting current timestamp in inline pipeline script using pipeline plugin of hudson

前提是你 提交于 2019-12-18 19:18:37
问题 I want to get Getting current timestamp in inline pipeline script using pipeline plugin of hudson. For setting up build display name. Inline groovy script used: def jobName = env.JOB_NAME + "_" + new Date() currentBuild.displayName = "$jobName" node { echo "job name $jobName" } Error on console : org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use new java.util.Date 回答1: Jenkins scripts are running in a sandbox, by default the Groovy script doesn

why am I not able to run batch file in jenkins pipeline running in windows 10?

时光怂恿深爱的人放手 提交于 2019-12-18 18:29:42
问题 I'm trying to run a batchscript present inside the workspace of jenkins. I have written a groovy script as below to do this stage('batchscript') { steps{ bat 'start cmd.exe /c C:\\Program Files (x86)\\Jenkins\\workspace\\jenkins Project\\batchfile.bat'\ } } when I build the job it should open a new command window and run my batch file in a new command prompt executing all the bat commands. The build is succesful but no command window opens up. Any suggestion will be helpfull 回答1: Jenkins is

how to get repo name in Jenkins pipeline

ⅰ亾dé卋堺 提交于 2019-12-18 13:27:29
问题 I'm using Jenkins Scripted Pipeline that uses Groovy style scripting, and created a Jenkinsfile to describe the pipeline. I need to create the workspace with the folder name same as git repo name, and then checkout the code in the workspace folder. My question is, before doing the checkout scm , is there a way to know the git repo name or the git repo url? 回答1: String determineRepoName() { return scm.getUserRemoteConfigs()[0].getUrl().tokenize('/')[3].split("\\.")[0] } This relatively ugly

Jenkins Pipeline Fails if Step is Unstable

不想你离开。 提交于 2019-12-18 12:54:08
问题 Currently my pipeline fails (red), when a maven-job is unstable (yellow). node { stage 'Unit/SQL-Tests' parallel ( phase1: { build 'Unit-Tests' }, // maven phase2: { build 'SQL-Tests' } // shell ) stage 'Integration-Tests' build 'Integration-Tests' // maven } In this example the job Unit-Test's result is unstable, but is shown as failed in the pipeline. How can I change the jobs/pipeline/jenkins to have the (1) the pipeline step unstable instead of failed and (2) the pipeline's status