Skip to content

Commit

Permalink
Add sample code about pipeline steps into README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
damianszczepanik committed May 2, 2019
1 parent 07bd3da commit dca9029
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,38 @@ As the result you can obtain something like this:

![alt tag](./.README/Screenshot_build_name.png)

# Piepline
This is how the plugin can be used via pipeline approach. Name and the description can be changed like any other steps.

```groovy
pipeline {
agent any
stages {
stage("Initialization") {
steps {
// use name of the patchset as the build name
setBuildName("${GERRIT_CHANGE_SUBJECT}")
setBuildDescription("Executed @ ${NODE_NAME}")
}
}
}
post {
failure {
// in case of failure, we'd like to have simple 'git blame' on build history :)
setBuildDescription("Committer: ${GERRIT_PATCHSET_UPLOADER_NAME}")
}
}
}
```

There is also possibility to use less modern and more scripting approach such as:
```groovy
script {
currentBuild.displayName = "this is name"
currentBuild.description = "and the description"
}
```

# Scripting
The power of this plugin is based on [Macro Token](https://wiki.jenkins.io/display/JENKINS/Token+Macro+Plugin) so take a look what features you can use.

0 comments on commit dca9029

Please sign in to comment.