jenkins-pipeline

How to trigger Multibranch Pipeline build with github webhook

半腔热情 提交于 2019-12-21 03:32:42
问题 In freestyle job there is an option named "GitHub hook trigger for GITScm polling" on stage Build Trigger. screen capture here: . Together with webhook in gitlab config "http://myjenkins/gitlab/notify_commit" it works fine, meaning that the build will be triggered automatically when something is pushed to the repository. But why in Multibranch Pipeline there is only one option named "Periodically if not otherwise run"? Is there some plug-in not installed? How to trigger Multibranch Pipeline

Access Stage results in Workflow/ Pipeline plugin

徘徊边缘 提交于 2019-12-21 01:56:41
问题 I have a pipeline with different stages. I want the current job to check how many stages have passed in the previous build and log it in the console? Consider this is my current pipeline node(){ stage "1" do something stage "2" do something else } I want a groovy script to give my something like this println currentBuild.previousBuild.getStage("1").result The purpose of my code is track successes & failures in different stages across my builds. Are there any alternatives to this approach? 回答1

Executing code when a branch is removed in Jenkins' multi branch pipeline

我是研究僧i 提交于 2019-12-20 12:36:52
问题 I have a Jenkins that uses multi branch project. That is, when a new branch is created to repository, Jenkins automatically will automatically create a new job for the branch, and remove that job when the branch is removed. Now, I'd like to run some code when the branch is removed, to clear testing environments that were created when the branch was created. It there a way to do this? 回答1: Not without writing plugin code I think. If you are interested, the relevant extension point would be

Jenkinsfile - get all changes between builds

丶灬走出姿态 提交于 2019-12-20 12:36:20
问题 With reference to this question is there a way to get the equivalent information from when using the mult-branch pipeline? Specifically - the list of commits since the last successful build. Currently we use the following def scmAction = build?.actions.find { action -> action instanceof jenkins.scm.api.SCMRevisionAction } return scmAction?.revision?.hash but this only returns the last commit that triggered the build if multiple commits were pushed. I accept that the very first build of a new

How to continue past a failing stage in Jenkins declarative pipeline syntax

我是研究僧i 提交于 2019-12-20 10:01:12
问题 I want to define multiple stages in Jenkins declarative pipeline syntax which can continue past any one of them failing. I cannot find any existing questions which are true duplicates, because they all assume or allow scripted syntax. pipeline { agent any stages { stage('stage 1') { steps { echo "I need to run every time" } } stage('stage 2') { steps { echo "I need to run every time, even if stage 1 fails" } } stage('stage 3') { steps { echo "Bonus points if the solution is robust enough to

Environment variable in Jenkins Pipeline

自作多情 提交于 2019-12-20 09:29:04
问题 Is there any environment variable available for getting the Jenkins Pipeline Title? I know we can use $JOB_NAME to get title for a freestyle job, but is there anything that can be used for getting Pipeline name? 回答1: You can access the same environment variables from groovy using the same names (e.g. JOB_NAME or env.JOB_NAME ). From the documentation: Environment variables are accessible from Groovy code as env.VARNAME or simply as VARNAME. You can write to such properties as well (only using

Jenkins scripted pipeline or declarative pipeline

纵然是瞬间 提交于 2019-12-20 08:09:18
问题 I'm trying to convert my old style project base workflow to a pipeline based on Jenkins. While going through docs I found there are two different syntaxes named scripted and declarative . Such as the Jenkins web declarative syntax release recently (end of 2016). Although there is a new syntax release Jenkins still supports scripted syntax as well. Now, I'm not sure in which situation each of these two types would be a best match. scripted syntax will be deprecated soon? So will declarative be

Jenkins scripted pipeline or declarative pipeline

那年仲夏 提交于 2019-12-20 08:08:06
问题 I'm trying to convert my old style project base workflow to a pipeline based on Jenkins. While going through docs I found there are two different syntaxes named scripted and declarative . Such as the Jenkins web declarative syntax release recently (end of 2016). Although there is a new syntax release Jenkins still supports scripted syntax as well. Now, I'm not sure in which situation each of these two types would be a best match. scripted syntax will be deprecated soon? So will declarative be

GIT SCM configuration for bitbucket pull requests checkout using generic Webhook parameters

拈花ヽ惹草 提交于 2019-12-20 07:46:43
问题 This stackoverflow page can help you checkout bitbucket pull requests in Jenkins with Generic webhook trigger. Pre-requisites: Jenkins: 1) Installing Generic Webhook Trigger Plugin and Bitbucket plugin in Jenkins 2) Configuring 'Bitbucket Endpoints' in Jenkins configuration. 3) Creating sample 'Pipeline' job in Jenkins (can configure Generic webhook plugin / configure bitbucket repo / include custom Jenkins file path) Bitbucket: 4) Configuring Webhook in bitbucket repo to connect to Jenkins

Sonar Gerrit plugin not reporting results

和自甴很熟 提交于 2019-12-19 12:05:53
问题 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