From 95c288e6e94581aca9d2bf262d757252460b7244 Mon Sep 17 00:00:00 2001 From: Mitch Harding Date: Tue, 17 Aug 2021 20:24:20 -0500 Subject: [PATCH] Enable dynamic versioning; use cms-meta-tools shared library --- .version | 1 - Jenkinsfile.github | 16 +++++++++++----- README.md | 23 +++++++++++++++++++---- git_info.conf | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 10 deletions(-) delete mode 100644 .version create mode 100644 git_info.conf diff --git a/.version b/.version deleted file mode 100644 index 8dbb0f2..0000000 --- a/.version +++ /dev/null @@ -1 +0,0 @@ -2.1.10 diff --git a/Jenkinsfile.github b/Jenkinsfile.github index 76bf149..cabf49a 100644 --- a/Jenkinsfile.github +++ b/Jenkinsfile.github @@ -1,4 +1,5 @@ -@Library('csm-shared-library') _ +@Library('cms-meta-tools') _ +@Library('csm-shared-library') __ pipeline { agent { @@ -13,16 +14,21 @@ pipeline { environment { NAME = "cf-ca-cert-config-framework" IS_STABLE = getBuildIsStable() - RPM_VERSION = sh(returnStdout: true, script: "head -1 .version").trim() BUILD_METADATA = getRpmRevision(isStable: env.IS_STABLE) } stages { stage("Clone cms_meta_tools repo") { steps { - withCredentials([gitUsernamePassword(credentialsId: 'jenkins-algol60-cray-hpe-github-integration')]) { - sh 'git clone --depth 1 --no-single-branch https://github.com/Cray-HPE/cms-meta-tools.git ./cms_meta_tools' - } + // This function is defined in cms-meta-tools:vars/cloneCMSMetaTools.groovy + cloneCMSMetaTools() + } + } + + stage("Set Versions") { + steps { + // This function is defined in cms-meta-tools:vars/setVersionFiles.groovy + setVersionFiles() } } diff --git a/README.md b/README.md index 66d095b..2f4fc1d 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,30 @@ An Ansible role for installing a CA certificate onto the system. ## Build Helpers -This repo uses some build helper scripts from the +This repo uses some build helpers from the [cms-meta-tools](https://github.com/Cray-HPE/cms-meta-tools) repo. See that repo for more details. ## Local Builds If you wish to perform a local build, you will first need to clone or copy the contents of the -cms-meta-tools repo to `./cms_meta_tools` in the same directory as the `Makefile`. +cms-meta-tools repo to `./cms_meta_tools` in the same directory as the `Makefile`. When building +on github, the cloneCMSMetaTools() function clones the cms-meta-tools repo into that directory. -### Versioning -Use [SemVer](http://semver.org/). The version is located in the [.version](.version) file. +For a local build, you will also need to manually write the .version, .docker_version (if this repo +builds a docker image), and .chart_version (if this repo builds a helm chart) files. When building +on github, this is done by the setVersionFiles() function. + +## Versioning +The version of this repo is generated dynamically at build time by running the version.py script in +cms-meta-tools. The version is included near the very beginning of the github build output. + +In order to make it easier to go from an artifact back to the source code that produced that artifact, +a text file named gitInfo.txt is added to Docker images built from this repo. For Docker images, +it can be found in the / folder. This file contains the branch from which it was built and the most +recent commits to that branch. + +For helm charts, a few annotation metadata fields are appended which contain similar information. + +For RPMs, a changelog entry is added with similar information. ### Copyright and License This project is copyrighted by Hewlett Packard Enterprise Development LP and is under the MIT diff --git a/git_info.conf b/git_info.conf new file mode 100644 index 0000000..58518a2 --- /dev/null +++ b/git_info.conf @@ -0,0 +1,36 @@ +# If this file exists, the git_info.sh tool will create gitInfo.txt, containing +# the git branch and information on the latest commit + +# A file can contain any number of chart, specfile, and/or dockerfile lines + +# For chart: lines, the specified file will have git information +# appended to it as annotation metadata: +# annotations: +# git/branch: "${GIT_BRANCH}" +# git/commit-date: "${GIT_COMMIT_DATE}" +# git/commit-id: "${GIT_COMMIT_ID}" + +#chart: kubernetes/cray-crus/Chart.yaml + +# For specfile lines, the specified specfile will have the following lines inserted +# after the %changelog line: +# * Cray HPE +# - build metadata +# - branch: ${GIT_BRANCH} +# - commit-date: ${GIT_COMMIT_DATE} +# - commit-id: "${GIT_COMMIT_ID} +# +# If no %changelog line is found, one will be appended to the end of the file, followed +# by the above lines + +specfile: cf-ca-cert.spec + +# For specified Dockerfile lines, the first field specifies the filename of the +# Dockerfile. All subsequent lines are the name of the containers where you +# want to copy the gitInfo.txt file. The script looks for lines of the form +# FROM as +# After each line that matches a container name you specified, the tool will +# insert this line: +# COPY gitInfo.txt gitInfo.txt + +#dockerfile: Dockerfile base