jenkins-pipeline

How to use Jenkins Pipeline Folder-Level Shared Library?

十年热恋 提交于 2019-12-09 10:43:30
问题 We have few components which is stored in their own git repositories. Specific combination of those components are built and delivered as solutions for different type of deployments/customers. So, we have a pipeline git repository which has multiple Jenkinsfile (with different names - and so the build names). Obviously, there are many things common between these pipelines. I'm aware of Jenkins shared library and it works when they're given their own git repository. But, since my pipelines are

How to catch manual UI cancel of job in Jenkinsfile

女生的网名这么多〃 提交于 2019-12-09 10:22:26
问题 I've tried to find documentation about how in a Jenkinsfile pipeline catching the error that occurs when a user cancels a job in jenkins web UI. I haven't got the post or try/catch/finally approaches to work, they only work when something fails within the build. This causes resources not to be free'd up when someone cancels a job. What I have today, is a script within a declarative pipeline , like so: pipeline { stage("test") { steps { parallell ( unit: { node("main-builder") { script { try {

Jenkins Declarative Pipeline, run groovy script on slave agent

别说谁变了你拦得住时间么 提交于 2019-12-09 06:31:59
问题 I have a Jenkins declarative pipeline I have been running on the Jenkins master and it works fine. However, now that I have moved to trying to execute this on a slave node, the groovy scripts which are called in the pipeline can not access the files in the workspace. My jenkinsfile looks like this... pipeline { agent { label { label "windows" customWorkspace "WS-${env.BRANCH_NAME}" } } stages { stage('InitialSetup') { steps { "${env.WORKSPACE}/JenkinsScripts/myScript.groovy" } } } I can see

Cant open Blue Ocean visual pipeline editor

有些话、适合烂在心里 提交于 2019-12-09 06:22:21
问题 Recently I installed Blue Ocean plugin, but I can't find out how to edit or create pipeline using plugin's UI. When I create new pipeline in Blue Ocean and connect with GitLab repo, I don't have option to create/edit pipeline (Jenkinsfile file). No matter if repo contains it or not. When Ocean connects to git server creation is over. I cannot open visual pipeline editor via URL ([local-address]/blue/organizations/jenkins/pipeline-editor/[project-name]). I get error alert with message: Error

How to share a Declarative Pipeline across many projects

寵の児 提交于 2019-12-09 06:22:12
问题 I have a lot of projects in different repositories which share the same fundamental CI-workflow, which I can easily express as a Declarative Pipeline: pipeline { agent any options { buildDiscarder(logRotator(numToKeepStr: '20')) } stages { stage('CI') { steps { echo 'Do CI' } } stage('QA') { steps { echo 'Do QA' } } } post { always { junit allowEmptyResults: true, testResults: '**/target/surefire-reports/TEST-*.xml' // etc... } failure { echo 'Failure mail' // etc } } } I would like to use

Can I define multiple agent labels in a declarative Jenkins Pipeline?

一笑奈何 提交于 2019-12-08 22:53:37
问题 I'm using declarative Jenkins pipelines to run some of my build pipelines and was wondering if it is possible to define multiple agent labels. I have a number of build agents hooked up to my Jenkins and would like for this specific pipeline to be able to be built by various agents that have different labels (but not by ALL agents). To be more concrete, let's say I have 2 agents with a label 'small', 4 with label 'medium' and 6 with label 'large'. Now I have a pipeline that is very resource

How to mask a password field in Jenkins Pipeline project?

半腔热情 提交于 2019-12-08 20:38:13
问题 When a password property is defined in a Jenkinsfile : properties([ parameters([ password(name: 'KEY', description: 'Encryption key') ]) ]) Jenkins prompts users to provide its value every time the pipeline is executed: I want this parameter to be masked so that echo ${KEY} does not print the actual value passed by the user. However, at the moment echoing it prints the provided value verbatim: properties([ parameters([ password(name: 'KEY', description: 'Encryption key') ]) ]) node { stage(

Jenkins: how to specify jenkinsfile in multibranch project

老子叫甜甜 提交于 2019-12-08 19:23:16
问题 Using Jenkins for multi-platform mutibranch builds. I have multiple Multibranch Pipeline projects (one for each platform, since each platform requires notably different build steps). I have one code repository with multiple branches (which is why Multibranch Pipeline projects makes sense). I would like to have each Multibranch Pipeline project reference a different Jenkinsfile, rather than all trying to use the one with the filename "Jenkinsfile" that is located in the root of the repository.

How to POST JSON data in body with Jenkins http-request plugin and Pipeline?

ε祈祈猫儿з 提交于 2019-12-08 15:43:13
问题 With v1.8.10 of the http-request plugin for Jenkins (I'm running 1.643), there is now support for POSTing a body in the request -- so this thread does not apply. I am wondering how to use this functionality in a Pipeline (v2.1) Groovy script? The Snippet Generator does not include this new field, so I have no example to build off of. I have tried various ways to get the JSON data into the request body, but my Tomcat server always returns http 400 status code: The request sent by the client

Jenkins Pipeline - Call functions in shared jar

别说谁变了你拦得住时间么 提交于 2019-12-08 15:15:23
问题 So here is my project setup A separate groovy project Multiple pipelines All the pipeline scripts refer to the shared groovy project. I went through the shared libraries and all of the needs to be registered in Jenkins global configuration. Is there any way to do without it? I tried using Grab but ended up with the error java.lang.RuntimeException: No suitable ClassLoader found for grab 回答1: Firstly for Grab to work your Jenkins needs to have access to the internet. Shared Libraries are