Skip to content

Commit

Permalink
feat: Add documents and examples in the snippet (#134)
Browse files Browse the repository at this point in the history
* feat: Add documents and examples in the snippet

* Add document to fields
  • Loading branch information
yuezhuangshi authored Oct 22, 2021
1 parent f62a6c8 commit 728bd41
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<p>
An optional parameter can be added as follows:
<code>
<pre>
pipeline {
agent any
environment {
NEXT_VERSION = nextVersion(buildMetadata: "$env.BUILD_NUMBER")
}
stages {
stage('Hello') {
steps {
echo "next version = ${NEXT_VERSION}"
}
}
}
}
</pre>
</code>
Assuming next version is 1.1.0. The pipeline will output: next version = 1.1.0+001
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<p>
There are three options to manipulate the prerelease option:
<ul>
<li>the name of the prerelease ➡️ <code>preRelease</code></li>
<li>keep the existing prerelease (default false) ➡️ <code>preservePrelease</code></li>
<li>increment the existing prerelease (default false) ➡️ <code>incrementPreRelease</code></li>
</ul>
The table described in <a href="https://github.com/jenkinsci/conventional-commits-plugin#prerelease-possible-combinations">here</a> are the combined use of these options and the result.
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>
If false use only annotated tags, if true use all tags to determine next version
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>

</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<p>
For a <code>1.0.0</code> existing version the following code:
<code>
<pre>
pipeline {
agent any

environment {
NEXT_VERSION = nextVersion(preRelease: 'alpha')
}

stages {
stage('Hello') {
steps {
echo "next version = ${NEXT_VERSION}"
}
}
}
}
</pre>
</code>
Will display: next version = 1.1.0-alpha
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<p>
There are three options to manipulate the prerelease option:
<ul>
<li>the name of the prerelease ➡️ <code>preRelease</code></li>
<li>keep the existing prerelease (default false) ➡️ <code>preservePrelease</code></li>
<li>increment the existing prerelease (default false) ➡️ <code>incrementPreRelease</code></li>
</ul>
The table described in <a href="https://github.com/jenkinsci/conventional-commits-plugin#prerelease-possible-combinations">here</a> are the combined use of these options and the result.
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>

</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>
Allow writing back to the file the next calculated version.
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<p>
Determine the next release version based on previous tags and the commit messages used.
It calculates the version number based on the format of the commit message.
The commit message format used is <a href="https://www.conventionalcommits.org/en/v1.0.0/" target="_blank">conventional commits.</a>
</p>
<p>
This plugin can be used in a pipeline in a stage or the environment block. Some examples of this in use are:<br/>
<strong>In the environment block:</strong><br/>
<code>
<pre>
pipeline {
agent any

environment {
NEXT_VERSION = nextVersion()
}

stages {
stage('Hello') {
steps {
echo "next version = ${NEXT_VERSION}"
}
}
}
}
</pre>
</code>
<strong>In a scripted Pipeline:</strong><br/>
<code>
<pre>
def NEXT_VERSION
node {
stage('Get next version ...') {
NEXT_VERSION=nextVersion()
echo "Next version : $NEXT_VERSION"
}
stage ('Release') {
sh "mvn release:prepare -DreleaseVersion=$NEXT_VERSION"
sh 'mvn release:perform'
}
}
</pre>
</code>
</p>

0 comments on commit 728bd41

Please sign in to comment.