* fix Markdown issue 'Headers should be surrounded by blank lines' * fix MD012 * fix MD022 * fix MD026 * fix MD007 * fix MD032 * fix MD038 * fix MD040 * fix MD031 * fix MD034 * fix MD004 * fix new findings * fix MD036 * fix MD038 * fix MD032 * fix MD006
5.2 KiB
artifactSetVersion
Description
The continuous delivery process requires that each build is done with a unique version number.
The version generated using this step will contain:
- Version (major.minor.patch) from descriptor file in master repository is preserved. Developers should be able to autonomously decide on increasing either part of this version number.
- Timestamp
- CommitId (by default the long version of the hash)
Optionally, but enabled by default, the new version is pushed as a new tag into the source code repository (e.g. GitHub).
If this option is chosen, git credentials and the repository URL needs to be provided.
Since you might not want to configure the git credentials in Jenkins, committing and pushing can be disabled using the commitVersion parameter as described below.
If you require strict reproducibility of your builds, this should be used.
Prerequsites
none
Parameters
| parameter | mandatory | default | possible values |
|---|---|---|---|
| script | yes | ||
| artifactType | no | 'appContainer' | |
| buildTool | no | maven | docker, dlang, golang, maven, mta, npm, pip, sbt |
| commitVersion | no | true |
true, false |
| dockerVersionSource | no | '' |
FROM, (ENV name),appVersion |
| filePath | no | buildTool=docker: Dockerfile buildTool= dlang: dub.json buildTool= golang: VERSION buildTool= maven: pom.xml buildTool= mta: mta.yaml buildTool= npm: package.json buildTool= pip: version.txt buildTool= sbt: sbtDescriptor.json |
|
| gitCommitId | no | GitUtils.getGitCommitId() |
|
| gitSshCredentialsId | If commitVersion is true |
as defined in custom configuration | |
| gitUserEMail | no | ||
| gitUserName | no | ||
| gitSshUrl | If commitVersion is true |
||
| tagPrefix | no | 'build_' | |
| timestamp | no | current time in format according to timestampTemplate |
|
| timestampTemplate | no | %Y%m%d%H%M%S |
|
| versioningTemplate | no | buildTool=docker: ${version}-${timestamp}${commitId?"_"+commitId:""}/>buildTool= dlang: ${version}-${timestamp}${commitId?"+"+commitId:""}buildTool= golang:${version}-${timestamp}${commitId?"+"+commitId:""}buildTool= maven: ${version}-${timestamp}${commitId?"_"+commitId:""}buildTool= mta: ${version}-${timestamp}${commitId?"+"+commitId:""}buildTool= npm: ${version}-${timestamp}${commitId?"+"+commitId:""}buildTool= pip: ${version}.${timestamp}${commitId?"."+commitId:""}buildTool= sbt: ${version}-${timestamp}${commitId?"+"+commitId:""} |
-
scriptdefines the global script environment of the Jenkinsfile run. Typicallythisis passed to this parameter. This allows the function to access thecommonPipelineEnvironmentfor retrieving e.g. configuration parameters. -
artifactTypedefines the type of the artifact. -
buildTooldefines the tool which is used for building the artifact. -
commitVersioncontrols if the changed version is committed and pushed to the git repository. If this is enabled (which is the default), you need to providegitCredentialsIdandgitSshUrl. -
dockerVersionSourcespecifies the source to be used for the main version which is used for generating the automatic version.- This can either be the version of the base image - as retrieved from the
FROMstatement within the Dockerfile, e.g.FROM jenkins:2.46.2 - Alternatively the name of an environment variable defined in the Docker image can be used which contains the version number, e.g.
ENV MY_VERSION 1.2.3 - The third option
appVersionapplies only to the artifactTypeappContainer. Here the version of the app which is packaged into the container will be used as version for the container itself.
- This can either be the version of the base image - as retrieved from the
-
Using
filePathyou could define a custom path to the descriptor file. -
gitCommitIddefines the version prefix of the automatically generated version. By default it will take the long commitId hash. You could pass any other string (e.g. the short commitId hash) to be used. In case you don't want to have the gitCommitId added to the automatic versioning string you could set the value to an empty string:''. -
gitSshCredentialsIddefines the ssh git credentials to be used for writing the tag. -
The parameters
gitUserNameandgitUserEMailallow to overwrite the global git settings available on your Jenkins server -
gitSshUrldefines the git ssh url to the source code repository. -
tagPrefixdefines the prefix wich is used for the git tag which is written during the versioning run. -
timestampdefines the timestamp to be used in the automatic version string. You could overwrite the default behavior by explicitly setting this string.
Step configuration
The following parameters can also be specified as step parameters using the global configuration file:
artifactTypebuildToolcommitVersiondockerVersionSourcefilePathgitCredentialsIdgitUserEMailgitUserNamegitSshUrltagPrefixtimestamptimestampTemplateversioningTemplate
Example
artifactSetVersion script: this, buildTool: 'maven'