jenkins-pipeline

Implement matrix config in Jenkins pipeline

六眼飞鱼酱① 提交于 2019-12-06 14:54:51
I've recently moved to the Pipeline plugin in Jenkins. I've successfully used freestyle jobs before for my project, but now would like to test something new. My project builds for Windows and Linux, in release and in debug mode, and uses a parameter, called device , to configure some C preprocessor macros: globally #define d frame_width and frame_height differ, depending on device value. Here is my Jenkinsfile: def device_config(device) { def device_config = ""; switch(device) { case ~/^dev_[Aa]$/: device_config="""-DGLOBAL_FRAME_WIDTH=640\ -DGLOBAL_FRAME_HEIGHT=480""" break; case ~/^dev_[Ss]$

Jenkinsfile - How to pass parameters for all the stages

北城以北 提交于 2019-12-06 14:11:42
To explain the issue, consider that I have 2 jenkins jobs. Job1 : PARAM_TEST1 it accepts a parameterized value called 'MYPARAM' Job2: PARAM_TEST2 it also accepts a parameterized value called 'MYPARAM' Sometimes I am in need of running these 2 jobs in sequence - so i created a separate pipeline job as shown below. It works just fine. it also accepts a parameterized value called 'MYPARAM' to simply pass it to the build job steps. pipeline { agent any stages { stage("PARAM 1") { steps { build job: 'PARAM_TEST1', parameters: [string(name: 'MYPARAM', value: "${params.MYPARAM}")] } } stage("PARAM 2"

Upload Local File by Using CURL Command in Shared Library Jenkins Pipeline

穿精又带淫゛_ 提交于 2019-12-06 13:17:09
问题 I am trying to upload a file from a local directory to a remote directory. I have a Groovy library that I have written to do this. def file = "$WORKPLACE/**/*-${BUILD_NUMBER}-*/file.txt" pulic uploadArtifct (String user, String password, String file, String location) { def cred = "${user}:${password}" def cmd = ["curl", "-v", "-u", cred, "-F", "files=@${file}", ${location}] try { def sout = new StringBuffer(), serr = new StringBuffer() def proc = cmd.execute() proc.consumeProcessOutput(sout,

capture build number of downstream job in Jenkins code as pipeline

ぃ、小莉子 提交于 2019-12-06 11:34:13
Is there an environment variable that captures the downstream job's build number ? I am using build step in pipeline as code. Not an environment variable, but an object property: downstreamBuild = build 'myDownstreamJob' downstreamBuildNumber = downstreamBuild.rawBuild.id Note that you will either need to disable the Groovy sandbox or get script approvals in order to use rawBuild . Also, you cannot use wait: false with your build step, since build() returns null when called with wait: false . 来源: https://stackoverflow.com/questions/46352379/capture-build-number-of-downstream-job-in-jenkins

Jenkins Pipeline job isn't triggered on GitHub push

谁说我不能喝 提交于 2019-12-06 11:08:57
I've created Jenkins Pipline job and want it to be triggered on my GitHub repo push event. I've added repo url to job config and checked "trigger on push option": I've also added GitHub token with needed rights to jenkins configure Github section: In Github repo I've enabled webhook for my Jenkins server: And after all steps still nothing is triggered after push to my GitHub repo. Does anyone have any idea what's going on and why Jenkins doesn't trigger configured pipeline job? Solution mentioned by OP in a comment is correct. Assuming you have a Github webhook for your Jenkins set up

Jenkins Pipeline - SVN polling

别说谁变了你拦得住时间么 提交于 2019-12-06 10:51:06
I have a Jenkins pipeline template which uses a Jenkins file in Subversion. The Jenkins file has the svn checkout method to check out the real application. (The svn url of real application is passed from jenkins env variables) I need to do the svn polling of the real application and trigger the job when there is a change in real application. When I use the polling option in jenkins template , it always do the polling of JenkinsFile in Subversion. Is there any way that I can poll the real application? Use a freestyle job to poll (with depth empty) your real application via svn. In this

Jenkins builds being triggered despite “Don't trigger a build on commit notifications”

…衆ロ難τιáo~ 提交于 2019-12-06 10:43:44
I have a Pipeline job that checkouts a git repository (let's call is "repoA") and passes it to some other downstream jobs for further processing. The upstream job's script is stored in a different git repo (let's call it "repoB"). This job is configured with the "Poll SCM" option so that any changes to repoA will trigger it. In the pipeline section, I have selected the "Pipeline script from SCM" option and configured it to get the pipeline script from the master branch of repoB. I have also added the option "Don't trigger a build on commit notifications". The behavior that I'm expecting is

Jenkins Multibranch Pipelines - Configuring properties in branches?

此生再无相见时 提交于 2019-12-06 10:27:37
We have successfully set up a build pipeline using the Jenkins Multibranch Pipeline Plugin, which works great most of the time, but we have this problem which nags us: The Jenkinsfile contains a set of properties, and these also show up in the UI, but how can I set up default values for individual branches? This is how the properties definitions look like in our Jenkinsfile : properties([ parameters([ string(defaultValue: 'somevalue', description: 'Some description', name: 'SOME_VALUE'), string(defaultValue: 'asdfasdfasdfasdfdasdasdasdasd...', description: 'Client ID', name: 'TEST_CLIENT_ID'),

How to build docker image using Jenkins pipeline?

末鹿安然 提交于 2019-12-06 10:22:17
By using jenkins, I create an item of "Pipeline" type. And I set "Pipeline from SCM" to get Jenkinsfile . You can check my GitHub repository : I want use Jenkins pipeline to build a docker image. Here is the Jenkinsfile: node { sh "docker build -t 192.168.59.224:5000/ubuntu-test ." } The Dockerfile is also very simple: FROM ubuntu:14.04 RUN sudo apt-get update && sudo apt-get install -y wget When I run the project. I got following error: unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /var/jenkins_home/workspace/test/Dockerfile: no such file or directory Here

Run Jenkins stage on different nodes

被刻印的时光 ゝ 提交于 2019-12-06 10:18:39
问题 I have the following Jenkinsfile of a multibranch pipeline architecture #!/usr/bin/groovy pipeline { agent { node { label 'ubuntu' customWorkspace "/src/$BUILD_NUMBER" } } environment { SRC_DIR = "$WORKSPACE" BUILD_DIR="/build/$BUILD_NUMBER" } stages { stage('Build') { steps { dir(BUILD_DIR) { sh '$SRC_DIR/build.sh' } } } stage('Test') { steps { dir(BUILD_DIR) { sh '$SRC_DIR/test.sh' } } } } } I am trying to run the 'Build' stage on Ubuntu and Red Hat nodes in parallel, and the 'Test' stage