jenkins-pipeline

Maven lifecycle within jenkins pipeline - how to best separate responsibilities?

◇◆丶佛笑我妖孽 提交于 2020-01-01 05:11:27
问题 When working with jenkins 2 (declarative) pipelines and maven I always have a problem with how to organize things within the pipeline to make it resusable and flexible. On the one side I would like to seperate the pipepline into logical stages like: pipeline { stages { stage('Clean') {} stage('Build') {} stage('Test') {} stage('Sanity check') {} stage('Documentation') {} stage('Deploy - Test') {} stage('Selenium tests') {} stage('Deploy - Production') {} stage('Deliver') {} } } On the other

Make Jenkins pipeline wait until server is up

徘徊边缘 提交于 2020-01-01 04:16:07
问题 I am currently starting to convert our builds into a Jenkins build pipeline. At a certain point it is necessary for us to wait for the startup of a web application within a docker container. My idea was to use something like this: timeout(120) { waitUntil { sh 'wget -q http://server:8080/app/welcome.jsf -O /dev/null' } } Unfortunately this makes the pipeline build fail: ERROR: script returned exit code 4 Is there any simple way to make this work? Edit: I managed to make it work using the

Jenkins Docker Pipeline Exit Code -1

拟墨画扇 提交于 2020-01-01 04:02:12
问题 We have a Jenkinsfile that uses the docker plugin to run a script inside a given container. This works fine for some images, but fails immediately with a -1 exit code on others. We've reduced the error down to a simple sleep . This is the Jenkinsfile: node("docker") { def wheezy_image = docker.image("pyca/cryptography-runner-wheezy") wheezy_image.pull() wheezy_image.inside { sh """sleep 120""" } } And here's the jenkins output + docker pull pyca/cryptography-runner-wheezy Using default tag:

How do pipeline parameters and jenkins GUI parameters work together?

蹲街弑〆低调 提交于 2019-12-31 22:41:46
问题 I am using a pipeline in a jenkinsfile and I am not sure how to properly link the job in Jenkins and the pipeline. I defined parameters in my jenkinsfile (some with default values, some without ) and have them initialized from the parameters coming from jenkins gui. The problem is that it seams the parameters in my pipeline are overiding my job parameters, EVEN when no default value is specified in the pipeline which means the pipeline is overriding my job setup in jenkins. for example, one

How to react on SonarQube Quality Gate within Jenkins Pipeline

一世执手 提交于 2019-12-31 22:39:08
问题 Within my Jenkins Pipeline I need to react on the SonarQube Quality Gate. Is there an easier way to achieve this but looking in the Sonar-Scanner log for the result page (e.g. https://mysonarserver/sonar/api/ce/task?id=xxxx) and parse the JSON Result from there? I use Jenkins 2.30 and SonarQube 5.3 Thanks in advance 回答1: Based on Vincent's answer, and using Pipeline utility steps, here's my updated version that worked for me (using sonarscanner report file) : withSonarQubeEnv('SONAR 6.4') {

Jenkins Pipeline sh display name/label

寵の児 提交于 2019-12-31 08:43:31
问题 With Jenkins 2 Pipeline plugin, there's a useful feature allowing a quick overview of the pipeline stages and status of steps, including logging output. However, if you use the "Shell script" (sh) step, there doesn't seem to be a way to label that script with a useful name, so the display merely shows a long list of "Shell Script" (shown in the image below). How can I assign a useful name, or how can I use some other step to accomplish the same effect? 回答1: Update Feb 2019 : According to

Jenkins Pipeline sh display name/label

扶醉桌前 提交于 2019-12-31 08:42:28
问题 With Jenkins 2 Pipeline plugin, there's a useful feature allowing a quick overview of the pipeline stages and status of steps, including logging output. However, if you use the "Shell script" (sh) step, there doesn't seem to be a way to label that script with a useful name, so the display merely shows a long list of "Shell Script" (shown in the image below). How can I assign a useful name, or how can I use some other step to accomplish the same effect? 回答1: Update Feb 2019 : According to

Jenkins Pipeline sh display name/label

徘徊边缘 提交于 2019-12-31 08:42:24
问题 With Jenkins 2 Pipeline plugin, there's a useful feature allowing a quick overview of the pipeline stages and status of steps, including logging output. However, if you use the "Shell script" (sh) step, there doesn't seem to be a way to label that script with a useful name, so the display merely shows a long list of "Shell Script" (shown in the image below). How can I assign a useful name, or how can I use some other step to accomplish the same effect? 回答1: Update Feb 2019 : According to

Jenkins Pipeline logs braces from ansiColor plugin?

徘徊边缘 提交于 2019-12-31 05:37:10
问题 I do not like that when I output a message using a ansiColor plug-in, it prints a lot of extra braces and words. How to fix it? Jenkins Pipeline Method: def printVariable(String message) { ansiColor('xterm') { echo "\033[34m ${message} \033[0m" } } Call: printVariable("ENVIRONMENT: ${ENVIRONMENT}") printVariable("PROJECT_VERSION: ${PROJECT_VERSION}") printVariable("TAG_NAME: ${TAG_NAME}") Output: [Pipeline] } [Pipeline] // ansiColor [Pipeline] ansiColor [Pipeline] { [Pipeline] echo

Get a list of filenames in a given folder in Jenkinsfile (Groovy)

烂漫一生 提交于 2019-12-30 19:21:55
问题 I cannot create a simple list of filenames in a given directory in a scripted Jenkins Pipeline. I tried many Groovy Script examples posted on SO and other forums but either the feature is blocked or I get method not found or whatever. This seems to be the easiest def DOCKER_FILES_DIR = './dockerfiles' // ... def dir = new File(DOCKER_FILES_DIR); def dockerfiles = []; dir.traverse(type: FILES, maxDepth: 0) { dockerfiles.add(it) } But this resolves the relative path incorrectly, so I get this