jenkins-pipeline

Jenkins: How to skip a specific stage in a multibranch pipeline?

岁酱吖の 提交于 2019-12-11 18:15:03
问题 We have "stage (build)" on all our branches. Temporarily how can we skip this stage to run on all our branches in multibranch pipeline. I know one solution is use when condition on stage and ask all developers to pull that branch into their branch. But thats lot of work and coordination. Instead I am looking for a global configuration where we can simply skip the stage by name on any branch. 回答1: It sounds like you keep the Jenkinsfile alongside the code, but want to change how the

How to access pipeline DSL in groovy classes(and not in Jenkinsfile)?

六月ゝ 毕业季﹏ 提交于 2019-12-11 17:52:50
问题 I want to access pipeline steps like 'bat' or 'echo' in my groovy classes but I am not really aware of how the 'script' variable usage works. This is very small repository with only this class and I am calling this class in groovy test(spock test). Can somebody please enlighten me on correct usage of 'script' variable and how the call should look like ? SoftwareInstallation.groovy class SoftwareInstallation implements Serializable { Script script def runInstallationJar(repoDir){ def

Jenkins Declarative pipeline docker: command not found

断了今生、忘了曾经 提交于 2019-12-11 17:34:59
问题 I have installed Jenkins locally on my machine. I pulling some source code from my github repository which has a Docker file in the root directory. I want to build and docker image and push it to docker hub but my build fails with the following message... docker build -f myapp-web:latest . \n /Users/Shared/Jenkins/Home/workspace/MyApp@tmp/durable-ee9851e9/script.sh: line 1: docker: command not found pipeline { agent any tools { maven 'maven_3.6.1' jdk 'jdk8' } stages { stage('Build') { steps

how do i get a variable out of powershell in jenkins declarative pipeline?

孤街醉人 提交于 2019-12-11 17:19:10
问题 steps { script{ env.StorysTested = '' try{ powershell(''' //some code here foreach ( $item in $Comments ) { //some code here //assigning a new value to StoryTested env variable $env:StorysTested = "some value" } //below line works fine and displays the value Write-Output "Stories tested : $env:StorysTested" ''') //below null value is displayed for StorysTested`` echo " From Grrovy : ${env.StorysTested}" } catch(err) { throw err } } I am using a jenkins declarative pipeline. In the above code

Jenkins Pipeline gcloud problems in docker

我的梦境 提交于 2019-12-11 16:57:35
问题 I'm trying to set up jenkins pipeline according to this article but instead use google container registry to push the docker images to. The Problem: The part which fails me is this jenkinsfile stage block stage ('Push Docker Image To Container Registry') { docker.image('google/cloud-sdk:alpine').inside { sh "echo ${env.GOOGLE_AUTH} > gcp-key.json" sh 'gcloud auth activate-service-account --key-file ./service-account-creds.json' } } The Error: Please verify that you have permissions to write

Define Jenkins pipeline on an external file

点点圈 提交于 2019-12-11 16:49:29
问题 We have several pipeline jobs with the same structure and behavior: update an ansible repository, execute a playbook with some parameters whose value depends on the environment and test with inspec the execution. We've tried to abstract the general behavior in an external file. JenkinsfileAnsible: #!/usr/bin/env groovy import groovy.json.JsonOutput node { } def executePlaybook(environment){ pipeline{ agent any stages{ stage('Update repository'){ ... } stage('Esecute playbook'){ ... } stage(

How to disable Branch Indexing?

隐身守侯 提交于 2019-12-11 15:39:47
问题 I have tests that can only run in serial. This is because they're rspec tests that use a database. If multiple jobs are running at the same time, they'll all be using the same database and creating a conflict. However, sometimes when I commit to my Github pull request Jenkins will correctly kick off a test job. However, it will also kick off another duplicate job with the message "Branch Indexing". These jobs can't run at the same time or the tests will break. Additionally, these jobs take 20

Sonar-Gerrit Plugin Not reporting Issues in Gerrit

被刻印的时光 ゝ 提交于 2019-12-11 15:38:57
问题 I am also facing the same issue with Sonar-Gerrit jenkins plugin. Downloaded it from Jenkins plugins site.Using Sonar-Gerrit plugin 2.2.1, and analysing sonar scan against jenkins workspace. For a sample,have changed just one file and provided the project base directory to the path of that file, and ran the sonar analysis in issues mode. Issues are not loaded in Gerrit and jenkins logs say Report has loaded and contains 759 issues Issues to be commented: 0 Issues to be involved in score

Delete video files from old builds' archives in Jenkins pipeline steps

泪湿孤枕 提交于 2019-12-11 15:35:46
问题 I need to loop over Jenkins builds folders, find folders where .zip report archives are stored and delete video files from those archives (setting the count of builds to keep is not enough in my case). I came up with this solutions which actually works but looks ugly: def buildFolders = sh(returnStdout: true, script: "find [0-9]* -maxdepth 0 -type d").split("\\s+") for (def folder in buildFolders) { if (folder.trim().toInteger() < (env.BUILD_NUMBER.toInteger() - recentBuildsWithVideoCount)) {

Jenkins scripted pipeline does not fetch the test result if unit test fails

自古美人都是妖i 提交于 2019-12-11 15:17:36
问题 I have gradle based java projects with junit tests which I'm building CI jobs for. I was successfully able to integrate slack with Jenkins using slack Slack Notification plugin. Jenkins Version : 2.173 Slack Notification version : 2.20 The jenkins CI is a scripted pipeline, which has the below code: stage('Test') { def slackHelper = new com.xyz.jenkins.libraries.SlackNotifier(env) try { sh "./gradlew test" junit 'build/test-results/test/*.xml' } finally { AbstractTestResultAction