jenkins-pipeline

Triggers on specific stage Jenkins Pipeline

你说的曾经没有我的故事 提交于 2020-01-15 09:43:10
问题 I'm using Jenkins since a little moment now, but I wanted to do something and I can't find how to do it... In deed, I want to trigger my projects with two differents way: every 4 hours and for every commit. But for each case, I don't want that all my Jenkinsfile is executed, only some specific stages. Is it possible to do that with Declarative Pipelines ? Thanks in advance 回答1: Unfortunately this is not available out of the box yet. Cloudbees has a proprietary plugin called "checkpoints"

WorkflowScript.with in Jenkins

岁酱吖の 提交于 2020-01-15 05:13:11
问题 I have a class in a jenkins shared library that stores the instance of a WorkflowScript class from a jenkins pipeline script as shown below. def myTools = new my.org.MyTools(this) the constructore of MyTools just stores the instance of WorkflowScript like this... MyTools(script){ this.script = script } then I have a method that tries to use groovy's .with on script but fails... myMethod(){ script.with{ node{ echo "I want to be able to use pipeline syntax here" sh 'echo "without using script.

How do I pass Jenkins credentials to gradle?

最后都变了- 提交于 2020-01-15 02:53:25
问题 I'm using the jib Gradle plugin to create a docker image and push it to the Azure Container Registry. I've added username/password credentials to Jenkins so far and need to pass them to Gradle. Accessing or passing the credentials to Gradle, they get masked. Hope you can help me. Here're the code snippets: build.gradle (jib configuration): jib { to { image = "myacr.azurecr.io/" + project.name tags = ["latest"] auth { // retrieve from Jenkins username System.properties['ACR_CREDENTIALS_USR']

How can i use 'parallel' option in jenkins pipeline in the 'post' section?

岁酱吖の 提交于 2020-01-14 14:01:22
问题 I looked at many pipeline examples and how to write the post build section in a pipeline script. But never got my answer i was looking for. I have 4 jobs - say Job A,B,C and D. I want job A to run first, and if successful it should trigger Job B,C,D in parallel. If Job A fails, it should trigger only Job B. Something like below: pipeline { agent any stages { stage('Build_1') { steps { sh ''' Build Job A ''' } } post { failure { sh ''' Build Job B ''' } success { sh ''' Build Job B,C,D in

How to pass docker container arguments when running the image in a Jenkinsfile

依然范特西╮ 提交于 2020-01-14 07:41:08
问题 I have a Dockerfile that ends with ENTRYPOINT ["node", "index.js"] CMD ["--help"] The index.js can take a couple different arguments and I also need to expose a port for the container so if I run it manually I do something like: docker run -p 3000:3000 my_container:latest --arg1 somearg --arg2 anotherarg How do I do this in a Jenkinsfile? My test will communicate with this container so it needs to be running before I run the test. I use withRun() get it running before the test runs but I don

Declarative jenkins pipeline, retrieve artifact

十年热恋 提交于 2020-01-14 06:08:09
问题 I'm currently trying to trigger an existing job and take in the generated artifacts in the current job's workspace. The following works fine: pipeline { agent { label 'builder-rpm' } options { timestamps() ansiColor('xterm') } stages { stage('Build Other pipeline') { steps { build job: 'Components/components-rpm-build', parameters: [ string(name: 'Component', value: 'foo'), ] copyArtifacts( filter: 'results/*.rpm', fingerprintArtifacts: true, flatten: true, projectName: 'Components/components

Jenkins - Trigger another pipeline job in same machine - without creating new “Executor”

淺唱寂寞╮ 提交于 2020-01-14 05:23:30
问题 I want to do similar thing - call " some_job_pipeline " from trigger pipeline and that it would be controller by parameter to execute on same or some specific Jenkins node. If it is should be executed on same/master/parent job jenkins node - it should not create new "Executor". That if i set for "Node1" node executors count to 1 - job would run successfully (would not require 2-nd executor). In example I have Trigger_Main_Job which looks something like this: node("${params.JenkinsNode}") {

How do i compare user inputed password to credentials passphrase

空扰寡人 提交于 2020-01-13 19:04:59
问题 I have a scripted pipeline that requests the user's password using the input function and compares it with the user's saved credentials passphrase. If the user input is a type string then it works. However, when I changed the input type to password (so it isn't visible on the screen when the user types it), it fails with an assert error. I made sure to enter the password that matches the one in the credentials file. I am using Jenkins 2.83 with latest Credentials Plugin and Credentials

Jenkins Multibranch Config: How to Filter branches based on variable string?

点点圈 提交于 2020-01-13 11:26:29
问题 We have Jenkins set up with 7 multibranch pipeline projects, each building off the same git repo, but for different target platforms. Each of these multibranch pipelines builds a number of branches. We currently set which branches each multibranch pipeline builds by using the following property in the multibranch project configuration: Branch Sources -> Git -> Behaviors -> Filter by name (with wildcards) Currently, each multibranch pipeline has the same string of branches in this Filter by

Execute a script from jenkins pipeline

允我心安 提交于 2020-01-13 08:58:09
问题 I have a jenkins pipeline that builds a java artifact, copies it to a directory and then attempts to execute a external script. I am using this syntax within the pipeline script to execute the external script dir('/opt/script-directory') { sh './run.sh' } The script is just a simple docker build script, but the build will fail with this exception: java.io.IOException: Failed to mkdirs: /opt/script-directory@tmp/durable-ae56483c The error is confusing because the script does not create any