UNCLASSIFIED - NO CUI

Skip to content

Parse out the version from a file in the repo

James Petersen requested to merge version-parse into master

The goal of this change is to set up the ability to use the custom CI configuration path for Ironbank Container projects. These changes will attempt to parse out the version from the existing files in the repo. It will look for the version in

  • download.yaml
  • download.json
  • Jenkinsfile

The catch all for the current repo structure is the Jenkinsfile parsing. This allows all of the repos to point to the new pipeline without having to make any changes to their code. The version will be extracted from the Jenkinsfile using a regex.

Switching away from Jenkinsfile

Otherwise an attempt to extract the version from the manifest files is made first so that future iterations can remove the Jenkinsfile and put the version in the download.yaml or download.json with the following structure (example pulled from kubectl)

download.yaml

---
version: "v1.18.8"
resources:
  - url: https://github.com/kubernetes/kubernetes/archive/v1.18.8.tar.gz
    filename: kubernetes.tar.gz
    validation:
      type: sha256
      value: 0efd7ab5f1afc77e65be0f8be137ad11aefad45e856f3f7fe8506804ae48eb12

download.json

{
        "version": "v1.18.8",
	"resources": [{
		"url": "https://github.com/kubernetes/kubernetes/archive/v1.18.8.tar.gz",
		"filename": "kubernetes.tar.gz",
                "validation": {
				"type": "sha256",
				"value": "0efd7ab5f1afc77e65be0f8be137ad11aefad45e856f3f7fe8506804ae48eb12"
			}
	}]
}

The motivation behind keeping the version field inside a file in the repo (rather than moving to a CI variable) is so that Renovate can continue to operate as it previously has with minimal configuration changes.

Pipelines specific info

The IMG_VERSION environment variable is parsed out during the load scripts stage and is set as a dotenv report so that any stage following can just depend on the load scripts stage to retrieve the IMG_VERSION

Merge request reports