Skip to content

Commit

Permalink
Support pipecfg living in a separate repo
Browse files Browse the repository at this point in the history
As part of #618,
we need to move to a model where the pipeline config is stored outside
of this repo.

Add support for this via a new `./deploy --pipecfg` option which takes a
git repo containing a `config.yaml` in the root of the repo.
  • Loading branch information
jlebon authored and dustymabe committed Sep 14, 2022
1 parent e66dec6 commit 8a2fe58
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 15 deletions.
4 changes: 4 additions & 0 deletions deploy
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def parse_args():
help="Repo and ref to use for pipeline code")
parser.add_argument("--config", metavar='<URL>[@REF]',
help="Repo and ref to use for FCOS config")
parser.add_argument("--pipecfg", metavar='<URL>[@REF]',
help="Repo and ref to use for pipeline config")
parser.add_argument("--cosa-img", metavar='FQIN',
help="Pullspec to use for COSA image")
parser.add_argument("--oc-cmd", default='oc',
Expand All @@ -92,6 +94,8 @@ def process_template(args):
if args.pipeline:
params.update(params_from_git_refspec(args.pipeline, 'JENKINS_S2I'))
params.update(params_from_git_refspec(args.pipeline, 'JENKINS_JOBS'))
if args.pipecfg:
params.update(params_from_git_refspec(args.pipecfg, 'PIPECFG'))
if args.config:
params.update(params_from_git_refspec(args.config, 'FCOS_CONFIG'))
if args.cosa_img:
Expand Down
2 changes: 1 addition & 1 deletion jobs/build-arch.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def src_config_url, src_config_ref, s3_bucket
node {
checkout scm
pipeutils = load("utils.groovy")
pipecfg = readYaml file: "config.yaml"
pipecfg = pipeutils.load_pipecfg()
pod = readFile(file: "manifests/pod.yaml")


Expand Down
2 changes: 1 addition & 1 deletion jobs/build-cosa.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def containername = 'coreos-assembler'
node {
checkout scm
pipeutils = load("utils.groovy")
pipecfg = readYaml file: "config.yaml"
pipecfg = pipeutils.load_pipecfg()
official = pipeutils.isOfficial()
}

Expand Down
2 changes: 1 addition & 1 deletion jobs/build-development.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ def pipecfg, pipeutils
node {
checkout scm
pipeutils = load("utils.groovy")
pipecfg = readYaml file: "config.yaml"
pipecfg = pipeutils.load_pipecfg()
}

properties([
Expand Down
2 changes: 1 addition & 1 deletion jobs/build-mechanical.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ def pipecfg, pipeutils
node {
checkout scm
pipeutils = load("utils.groovy")
pipecfg = readYaml file: "config.yaml"
pipecfg = pipeutils.load_pipecfg()
}

properties([
Expand Down
2 changes: 1 addition & 1 deletion jobs/build.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def gcp_gs_bucket
node {
checkout scm
pipeutils = load("utils.groovy")
pipecfg = readYaml file: "config.yaml"
pipecfg = pipeutils.load_pipecfg()
pod = readFile(file: "manifests/pod.yaml")

def jenkinscfg = pipeutils.load_jenkins_config()
Expand Down
2 changes: 1 addition & 1 deletion jobs/bump-lockfile.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ def pipeutils, pipecfg, official, arches
node {
checkout scm
pipeutils = load("utils.groovy")
pipecfg = readYaml file: "config.yaml"
pipecfg = pipeutils.load_pipecfg()
arches = pipecfg.additional_arches.plus("x86_64")
official = pipeutils.isOfficial()
}
Expand Down
3 changes: 2 additions & 1 deletion jobs/bump-lockfiles.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ properties([

node {
checkout scm
def pipecfg = readYaml file: "config.yaml"
def pipeutils = load("utils.groovy")
def pipecfg = pipeutils.load_pipecfg()
def development_streams = pipeutils.streams_of_type(pipecfg, 'development')

parallel development_streams.collectEntries { stream -> [stream, {
Expand Down
2 changes: 1 addition & 1 deletion jobs/kola-aws.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ def pipeutils, pipecfg, official
node {
checkout scm
pipeutils = load("utils.groovy")
pipecfg = readYaml file: "config.yaml"
pipecfg = pipeutils.load_pipecfg()
official = pipeutils.isOfficial()
}

Expand Down
2 changes: 1 addition & 1 deletion jobs/kola-azure.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def azure_testing_storage_container
node {
checkout scm
pipeutils = load("utils.groovy")
pipecfg = readYaml file: "config.yaml"
pipecfg = pipeutils.load_pipecfg()
def jenkinscfg = pipeutils.load_jenkins_config()
azure_testing_resource_group = pipecfg.azure?.test_resource_group
azure_testing_storage_account = pipecfg.azure?.test_storage_account
Expand Down
2 changes: 1 addition & 1 deletion jobs/kola-gcp.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ def pipeutils, pipecfg, official
node {
checkout scm
pipeutils = load("utils.groovy")
pipecfg = readYaml file: "config.yaml"
pipecfg = pipeutils.load_pipecfg()
official = pipeutils.isOfficial()
}

Expand Down
2 changes: 1 addition & 1 deletion jobs/kola-kubernetes.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ def pipeutils, pipecfg, official
node {
checkout scm
pipeutils = load("utils.groovy")
pipecfg = readYaml file: "config.yaml"
pipecfg = pipeutils.load_pipecfg()
official = pipeutils.isOfficial()
}

Expand Down
2 changes: 1 addition & 1 deletion jobs/kola-openstack.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ def pipeutils, pipecfg, official
node {
checkout scm
pipeutils = load("utils.groovy")
pipecfg = readYaml file: "config.yaml"
pipecfg = pipeutils.load_pipecfg()
official = pipeutils.isOfficial()
}

Expand Down
2 changes: 1 addition & 1 deletion jobs/release.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ def pipeutils, pipecfg, official, s3_bucket, jenkins_agent_image_tag
node {
checkout scm
pipeutils = load("utils.groovy")
pipecfg = readYaml file: "config.yaml"
pipecfg = pipeutils.load_pipecfg()
pod = readFile(file: "manifests/pod.yaml")
def jenkinscfg = pipeutils.load_jenkins_config()
s3_bucket = pipecfg.s3_bucket
Expand Down
2 changes: 1 addition & 1 deletion jobs/sync-stream-metadata.Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
def pipecfg, pipeutils
node {
checkout scm
pipecfg = readYaml file: "config.yaml"
pipeutils = load("utils.groovy")
pipecfg = pipeutils.load_pipecfg()
}

properties([
Expand Down
10 changes: 9 additions & 1 deletion manifests/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ parameters:
- description: Git branch/tag reference for Jenkins jobs
name: JENKINS_JOBS_REF
value: main
- description: Git source URI for pipeline configuration
name: PIPECFG_URL
value: in-tree
- description: Git branch/tag reference for pipeline configuration
name: PIPECFG_REF
value: main
- description: Jenkins agent image to use
name: JENKINS_AGENT_IMAGE_TAG
value: base
Expand Down Expand Up @@ -55,7 +61,7 @@ objects:
### JENKINS CONFIG ###

# Only keep here base Jenkins configuration knobs. Higher-level "variant"
# configuration should live in the `config.yaml` instead. A litmus test to identify
# configuration should live in the pipecfg instead. A litmus test to identify
# such knobs is: would this knob still be needed if the pipeline were not
# Jenkins-based?

Expand All @@ -67,3 +73,5 @@ objects:
jenkins-jobs-url: ${JENKINS_JOBS_URL}
jenkins-jobs-ref: ${JENKINS_JOBS_REF}
jenkins-agent-image-tag: ${JENKINS_AGENT_IMAGE_TAG}
pipecfg-url: ${PIPECFG_URL}
pipecfg-ref: ${PIPECFG_REF}
20 changes: 20 additions & 0 deletions utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,26 @@ def load_jenkins_config() {
"""))
}

def load_pipecfg() {
def jenkinscfg = load_jenkins_config()
def url = jenkinscfg['pipecfg-url']
def ref = jenkinscfg['pipecfg-ref']

if (url == 'in-tree') {
return readYaml file: "config.yaml"
}

// this uses the `checkout` workflow step instead of just manually cloning so
// that changes show up in the Jenkins UI
checkout([
$class: 'GitSCM',
branches: [[name: "origin/${ref}"]],
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'pipecfg']],
userRemoteConfigs: [[url: url]]
])
return readYaml file: "pipecfg/config.yaml"
}

// Tells us if we're running if the official Jenkins for the FCOS pipeline
boolean isOfficial() {
return (env.JENKINS_URL in ['https://jenkins-fedora-coreos-pipeline.apps.ocp.fedoraproject.org/'])
Expand Down

0 comments on commit 8a2fe58

Please sign in to comment.