Re: I can't get anything to work with bat in pipeline jenkinsfile

2020-03-27 Thread Daniel Butler
in the code snippet it should have had a second line: echo output On Fri, Mar 27, 2020 at 1:09 PM Daniel Butler wrote: > If you want to see the bat file output, remove the returnStdOut. You only > need that if you want to assign the output to variable and use it later in > the pipel

Re: I can't get anything to work with bat in pipeline jenkinsfile

2020-03-27 Thread Daniel Butler
If you want to see the bat file output, remove the returnStdOut. You only need that if you want to assign the output to variable and use it later in the pipeline. if you still want it in the logging as well as a variable: output = bat returnStdout: true, script: 'echo %PATH%' On Fri, 27 Mar 20

Re: how to define multibranch pipeline with jenkinsfile from another repository (or hardcoded)?

2019-07-04 Thread Daniel Butler
You could use the Pipeline Multibranch Defaults plugin which does the hardcoded in the job approach https://github.com/jenkinsci/pipeline-multibranch-defaults-plugin/blob/master/README.md If a stub file in Repo-A is acceptable you could also use a shared library to store the actual jenkinsfile as

Re: scripted pipeline: bash: date -> MissingPropertyException: No such property: ... for class: groovy.lang.Binding

2019-05-02 Thread Daniel Butler
Replace ${mytime} with \$mytime The mytime variable you've created is a bash one. Regards Daniel On Thu, 2 May 2019, 1:16 pm b o b i, wrote: > Jenkins 2.174, in a scripted pipeline the following > > sh """#!/bin/bash >echo "TTT" >mytime="`date '+%Y_%m_%d__%H_%M_%S'

Re: shell inside a groovy script doesnt resolve variables ?

2019-04-17 Thread Daniel Butler
Strings using single quotes do not do variable expansion; you must use double quotes to have the variables expand. So: '$var' is the literal string $var "$var" expands to the string value of the variable $var and the same is true for multi line strings ''' $var ''' does not expand """

RE: How to Trigger back the Jenkins job from the job who triggered it?

2019-03-18 Thread Daniel Butler
I’m assuming you’re meaning freestyle jobs? Usually you’d have a parameter in Job X with the upstream job name that you can then use in the Parameterized Build Trigger to pass the parameter to Job X. What will be in place however to stop this ending up in a build loop? Otherwise Job B is going

Re: How to prevent concurrent execution of jobs on the same node, but allow a few parallel steps execution?

2019-01-31 Thread Daniel Butler
You could use the lockable resources plugin (v2.2+): Set up a single resource for each node and give them all a common label Then your Jenkinsfile would be: lock(label: "common-label", variable: "LOCKED_NODE"){ node(env.LOCKED_NODE){ //build project } } Regards, Daniel. On Thu,

RE: CLI command to start jenkins job with default and overridenparameters

2019-01-10 Thread Daniel Butler
Hi Vicki, According to https://wiki.jenkins.io/display/JENKINS/Parameterized+Build, for buildWithParameters you should use URL query params to pass the values. To use your example: curl -v https://jenkins/job/JobName/buildWithParameters?targ_env=dev --user userName:userToken Regards, Daniel

Re: [CONCURRENT BUILDS] Run on master, run on slave and then sit in queue

2018-08-25 Thread Daniel Butler
If you set the number of executors on both master and slave to 1 that will restrict the number of builds to one per node put a third into the queue. Regards Daniel On Fri, 24 Aug 2018, 12:58 Nati Mirauta, wrote: > Hello, > > I would like to know if there is a way to run a job on master once and

Re: Can I load a declarative Jenkinsfile via a shared library?

2018-01-10 Thread Daniel Butler
I believe this was added a month or two ago. On 10 Jan 2018 6:33 pm, "Idan Adar" wrote: > Is the following feasible? > > 1. Setup a Shared Library in the Jenkins settings > 2. In every repository requiring the Jenkinsfile (it is the same one used > in multiple repos...), use the following in the

RE: Translation between declaritive pipleline and groovy pipeline

2017-12-05 Thread Daniel Butler
If you use currentBuild.currentResult (was added a few months ago IIRC) you get a value that will never be null. From: jer...@bodycad.com Sent: 04 December 2017 17:06 To: Jenkins Users Subject: Re: Translation between declaritive pipleline and groovy pipeline You need to wrap your groovy code i

RE: How can I inject environment variables into my groovy class?

2017-12-03 Thread Daniel Butler
er 1, 2017 at 9:08:12 AM UTC-5, Daniel Butler wrote: If you’re writing a groovy class that’s run from a library in the pipeline script then you’re not going to be able to use System.getEnv().   There’s a few approaches you can take that do work: • You can pass in the values you need as parameters to th

RE: Define a class inside a groovy pipeline?

2017-12-01 Thread Daniel Butler
This is my preferred as it’s nice and explicit: class MyClass implements Serializable {  def ctx   MyClass(ctx) { this.ctx=ctx   }   def bark(){      ctx.sh 'echo WOOF!'  } } You’d then construct it: def mc = new MyClass(this) If you remove the class definition so you end up with a gr

RE: How can I inject environment variables into my groovy class?

2017-12-01 Thread Daniel Butler
If you’re writing a groovy class that’s run from a library in the pipeline script then you’re not going to be able to use System.getEnv(). There’s a few approaches you can take that do work: - You can pass in the values you need as parameters to the methods/constructors you’re using. - In the pi

RE: Why aren't these injected variables making it to my groovy class?

2017-11-21 Thread Daniel Butler
entVariableCredentialsProvider()) .build() On Monday, November 20, 2017 at 6:57:07 AM UTC-5, Daniel Butler wrote: By doing System.getenv() you're getting the environment of the Jenkins master process. The environment that will be used by any process run in the pipeline is available through t

Re: Why aren't these injected variables making it to my groovy class?

2017-11-20 Thread Daniel Butler
By doing System.getenv() you're getting the environment of the Jenkins master process. The environment that will be used by any process run in the pipeline is available through the built-in variable env. Regards, Daniel On 20 Nov 2017 2:14 am, "red 888" wrote: In my pipeline I'm injecting aws

Re: Trying to set value using powershell, in declarative pipeline

2017-10-31 Thread Daniel Butler
The powershell step in pipeline is provided by the same plugin that provides the bat and sh steps. It's separate to the powershell plugin which is for freestyle jobs. On 31 Oct 2017 12:51 pm, "itchymuzzle" wrote: Doesn’t answer my original question, but is a valid work around. #! /usr/bin/e

RE: Using the same label multiple times in pipeline

2017-10-30 Thread Daniel Butler
Couple of approaches: You could use the External Workspace Manager plugin: https://jenkins.io/doc/pipeline/steps/external-workspace-manager/ Or as Robert suggested use the ws(){} block, this should give a guarantee on the workspace but you’ll need to confirm that you’re not about to fill up you

RE: withCredentials doesn't populate variables

2017-09-17 Thread Daniel Butler
The variables for the withCredentials step are created in the environment map, to use them in the pipeline script you’ll need to refer them as env. So for your case it would be: echo “${env.OD_USER}” That should run but all you’ll see is a bunch of *** as the withCredentials step filters the log

RE: Multiple commands

2017-09-04 Thread Daniel Butler
in my case: I choosed execute windows batch command and typed the following: """ cd c:\ \mysql --username --password -e "DROP DATABASE xyz; CREATE DATABASE xyz;" """ Is there something which am missing ? Regards, Harvey On Monday, September 4,

RE: Send mail from Jenkins with attach conditioned file

2017-09-04 Thread Daniel Butler
Looking at the bracket positions in your log snippet, it looks like there could be a trailing space or two after the file name in the File text box. Make sure there’s no extra spaces around the file name as that could be messing it up. Regards, Daniel. From: Ana MB Sent: 04 September 2017 12:37

RE: Multiple commands

2017-09-04 Thread Daniel Butler
Are you using freestyle jobs or pipeline? With Pipeline: When you use a bat/sh step you’re providing a batch or shell script rather than virtual input into a console. In your case you’d need to do something like: bat """ cd c:\... ...\mysql --user %user% --password %password% -e "DROP DATABASE

RE: Does anyone know if the MSTest plugin supports pipelines and howto use it in a pipeline (jenkinsfile)?

2017-08-16 Thread Daniel Butler
The XUnit plugin has support for MSTest output and is pipeline compatible. You’d still need to run MSTest from a bat/powershell command but the Xunit plugin will publish the test output. From: jer...@bodycad.com Sent: 16 August 2017 13:24 To: Jenkins Users Subject: Re: Does anyone know if the MS

RE: How to setup multibranch project with external triggers

2017-08-15 Thread Daniel Butler
I’ve got triggering of Multibranches working using a user API token (from the users config page) and curl. You can’t set job specific tokens on multibranch. e.g. Curl -x POST http://jenkins:8080/test-multibranch/job/master/build -u user:0123456789abcedf0123456789abcdef From: Rainer Hörbe Sent:

RE: Multiple multibranch pipeline builds from a single repo

2017-07-12 Thread Daniel Butler
The multibranch plugin from version 2.15 does support custom names for the pipeline script so you can now have multiple multibranch projects on the same repo. As for only building on changes applicable to the respective folders I’m not able to answer that. If each of these projects are changing

RE: finding git repo url

2017-07-01 Thread Daniel Butler
In a multibranch project you simply do: checkout scm And that clones/checks out the current branch. Cheers, Daniel Butler From: R Srinivasan Sent: 01 July 2017 12:45 To: Jenkins Users Subject: finding git repo url For Multibranch pipeline jobs, how do I clone the git Repo? I can find what the

RE: Accessing workspace from WebUI in a multi-branch pipeline project

2017-05-11 Thread Daniel Butler
Hello, If you have a look in the Pipeline Steps each instance of “Allocate Node : Start” will have a link to the workspace used for that node block. Cheers, Daniel. From: Ewgenij Gawrilow Sent: 11 May 2017 14:32 To: Jenkins Users Subject: Accessing workspace from WebUI in a multi-branch pipeli