Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
[JENKINS-26194] Noting default environment variables and parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Dec 22, 2014
1 parent f6400d5 commit d3e64f6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions TUTORIAL.md
Expand Up @@ -219,6 +219,13 @@ This is convenient because now we can run `mvn` without a fully-qualified path.

We will not use this style again, for reasons that will be explained later in more complex examples.

Some environment variables are defined by Jenkins by default, as for freestyle builds.
For example, `env.BUILD_TAG` can be used to get a tag like `jenkins-projname-1` from Groovy code, or `$BUILD_TAG` can be used from a `sh` script.

## Build parameters

If you have configured your workflow to accept parameters when it is built (_Build with Parameters_), these will be accessible as Groovy variables of the same name.

# Recording test results and artifacts

Rather than failing the build if there are some test failures, we would like Jenkins to record them, but then proceed.
Expand Down

4 comments on commit d3e64f6

@kentoj
Copy link

@kentoj kentoj commented on d3e64f6 Apr 1, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an excellent addition to the tutorial. It would be nice to have a more clear example on how to use the build number in flow.groovy. I posted a question to Jenkins' Google groups on it: post

@perrefe
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And is there a way to access to the list or array of input parameters to iterate over it?

@TG9541
Copy link

@TG9541 TG9541 commented on d3e64f6 Apr 22, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@perrefe has a point here: it's obvious that one can do amazing things with CPS, but especially advanced Jenkins users who know Matrix Build, or other multi configuration techniques, well need some guidance for rewriting their solutions as CPS scripts. As long as there are open collection/list/string handling, or CPS transformation issues, this is of some importance (e.g. JENKINS-26307, JENKINS-27893, JENKINS-27916, JENKINS-27421).

Ah, yes, the question... to access an array of input parameters, make it a delimited string, and spIit it (like in the parallel test execution example) :-)

@perrefe
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice trick!, but in my actual scenario I have a set of boolean parameters (names of servers, and yes, I could enter their names comma separated but it is not practical at all.) where each one represent a server that will be affected by the job if the input checkbox is checked. So it should be easy to iterate all those params searching for the ones with true values.

Thanks!

Please sign in to comment.