jenkins-pipeline

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

主宰稳场 提交于 2019-12-30 19:21:12
问题 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

How to invoke bash functions defined in a resource file from a Jenkins pipeline Groovy script?

依然范特西╮ 提交于 2019-12-30 18:31:29
问题 We are using the Pipeline Shared Libraries plugin to factorize the code common to our different Jenkins pipelines. From its documentation, it offers a resources top-level folder for non-Groovy files. As we rely on different bash functions, we would like to host them in a separate .sh file (thus they could also be used by other processes than Jenkins). The same documentation tells us about using libraryResource step to load those resource files. We can successfully call this method within our

Jenkins Pipeline Plugin: execute shell and parse output

亡梦爱人 提交于 2019-12-30 17:04:39
问题 I am using the Jenkins Pipeline plugin to execute an iOS Checkout-Build-Test-Deploy pipeline. One step involves checking whether an iDevice is actually connected (otherwise the rest of the steps will not be executed). I want to execute a shell command idevice_id -l (from libimobiledevice) which will print out the device ID of the connected device, or fail if nothing connected. So the steps as I envision them, would be: Execute command sh "/usr/local/bin/idevice_id -l" parse the output somehow

Jenkins trigger on-demand slaves in dockers

怎甘沉沦 提交于 2019-12-30 10:29:59
问题 I'm looking for a way to run Jenkins jobs/build inside Jenkins slaves, dynamically (on-demand) started docker. Attaching schema for visual understanding. What I'm actually looking for and my flow looks like: 1) Triggering Jenkins job (manually/git/gerrit) 2) Jenkins master (running in docker) starts slave machine docker (and pass script/instructions of the build) 3) Build is running on Jenkins slave (or slaves if parallel/pipeline) 4) Result returned to Jenkins master 5) Jenkins slave docker

Docker in Docker - volumes not working: Full of files in 1st level container, empty in 2nd tier

廉价感情. 提交于 2019-12-30 06:49:40
问题 I am running Docker in Docker (specifically to run Jenkins which then runs Docker builder containers to build a project images and then runs these and then the test containers). This is how the jenkins image is built and started: docker build --tag bb/ci-jenkins . mkdir $PWD/volumes/ docker run -d --network=host \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /usr/bin/docker:/usr/bin/docker \ -v $PWD/volumes/jenkins_home:/var/jenkins_home \ --name ci-jenkins bb/ci-jenkins Jenkins works

Jenkins multi-branch pipeline and specifying upstream projects

你离开我真会死。 提交于 2019-12-30 06:38:31
问题 We currently generate a lot of Jenkins jobs on a per Git branch basis using Jenkins job DSL; the multi-branch pipeline plugin looks like an interesting way to potentially get first-class job generation support using Jenkinsfiles and reduce the amount of Job DSL we maintain. For example we have libwidget-server and widget-server develop branch projects. When the libwidget-server build finishes then the widget-server job is triggered (for the develop branch). This applies to other branches too.

How do I use SSH in a Jenkins pipeline?

时光毁灭记忆、已成空白 提交于 2019-12-30 06:10:10
问题 I have some Jenkins jobs defined using a Jenkins Pipeline Model Definition, which builds NPM projects. I use Docker containers to build these projects (using a common image with just Node.js + npm + yarn). The results of the builds are contained in the dist/ folder that I zipped using a zip pipeline command. I want to copy this ZIP file to another server using SSH/SCP (with private key authentication). My private key is added to the Jenkins environment (credentials manager), but when I use

How to attach files to Jenkins Pipeline notification

丶灬走出姿态 提交于 2019-12-30 04:44:09
问题 I am trying in a pipeline to attach files to my notification mails. How can I do that? An example would be nice. 回答1: email-ext uses Ant File Syntax As for example usage: emailext attachmentsPattern: '**/report.html', body: 'Find attachments', subject: 'test', to: 'test@me.org' 来源: https://stackoverflow.com/questions/41422526/how-to-attach-files-to-jenkins-pipeline-notification

Easiest way to do docker build command within Jenkinsfile running on Jenkins slave node?

主宰稳场 提交于 2019-12-30 04:40:14
问题 Basic example of what I want my Jenkinsfile to do: node { sh 'docker build -t foo/bar .' } It seems like I need to install docker onto the Jenkins slave image that's executing my Jenkinsfile. Is there an easy way of doing this? (That Jenkins slave image is itself a docker container) Are my assumptions correct? When running with Jenkins master/slaves, the Jenkinsfile is executed by a Jenkins slave Jenkins plugins installed via the Manage Plugins section (e.g. the Docker Plugin, or Gcloud SDK

Jenkins multibranch pipeline with Jenkinsfile from different repository

走远了吗. 提交于 2019-12-30 03:43:09
问题 I have a Git repository with code I'd like to build but I'm not "allowed" to add a Jenkinsfile in its root (it is a Debian package so I can't add files to upstream source). Is there a way to store the Jenkinsfile in one repository and have it build code from another repository? Since my code repository has several branches to build (one for each Debian release) this should be a multibranch pipeline. Commits in either the code or Jenkinsfile repositories should trigger a build. Bonus