diff --git a/Jenkinsfile b/Jenkinsfile index 1d3c974d4..69b9720fd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -490,17 +490,12 @@ lock(resource: "build-${params.STREAM}") { if (!params.MINIMAL && s3_stream_dir && utils.path_exists("\${AWS_FCOS_KOLA_BOT_CONFIG}")) { stage('Kola:AWS') { - // use jnlp container in our pod, which has `oc` in it already - container('jnlp') { - utils.shwrap(""" - # We consider the AWS kola tests to be a followup job - # so we aren't adding a `--wait` here. - oc start-build fedora-coreos-pipeline-kola-aws \ - -e STREAM=${params.STREAM} \ - -e VERSION=${newBuildID} \ - -e S3_STREAM_DIR=${s3_stream_dir} - """) - } + // We consider the AWS kola tests to be a followup job, so we use `wait: false` here. + build job: 'kola-aws', wait: false, parameters: [ + string(name: 'STREAM', value: params.STREAM), + string(name: 'VERSION', value: newBuildID), + string(name: 'S3_STREAM_DIR', value: s3_stream_dir) + ] } } @@ -508,17 +503,12 @@ lock(resource: "build-${params.STREAM}") { if (!params.MINIMAL && s3_stream_dir && utils.path_exists("\${GCP_IMAGE_UPLOAD_CONFIG}")) { stage('Kola:GCP') { - // use jnlp container in our pod, which has `oc` in it already - container('jnlp') { - utils.shwrap(""" - # We consider the GCP kola tests to be a followup job - # so we aren't adding a `--wait` here. - oc start-build fedora-coreos-pipeline-kola-gcp \ - -e STREAM=${params.STREAM} \ - -e VERSION=${newBuildID} \ - -e S3_STREAM_DIR=${s3_stream_dir} - """) - } + // We consider the GCP kola tests to be a followup job, so we use `wait: false` here. + build job: 'kola-gcp', wait: false, parameters: [ + string(name: 'STREAM', value: params.STREAM), + string(name: 'VERSION', value: newBuildID), + string(name: 'S3_STREAM_DIR', value: s3_stream_dir) + ] } } diff --git a/Jenkinsfile.kola.aws b/Jenkinsfile.kola.aws deleted file mode 100644 index e02d09153..000000000 --- a/Jenkinsfile.kola.aws +++ /dev/null @@ -1,105 +0,0 @@ -def utils, streams -node { - checkout scm - utils = load("utils.groovy") - streams = load("streams.groovy") - pod = readFile(file: "manifests/pod.yaml") -} - -properties([ - pipelineTriggers([]), - parameters([ - choice(name: 'STREAM', - // list devel first so that it's the default choice - choices: (streams.development + streams.production + streams.mechanical), - description: 'Fedora CoreOS stream to test'), - string(name: 'VERSION', - description: 'Fedora CoreOS Build ID to test', - defaultValue: '', - trim: true), - string(name: 'S3_STREAM_DIR', - description: 'Fedora CoreOS S3 Stream Directory', - defaultValue: '', - trim: true), - string(name: 'COREOS_ASSEMBLER_IMAGE', - description: 'Override coreos-assembler image to use', - defaultValue: "coreos-assembler:master", - trim: true) - ]) -]) - -currentBuild.description = "[${params.STREAM}] - ${params.VERSION}" - -def s3_stream_dir = params.S3_STREAM_DIR -if (s3_stream_dir == "") { - s3_stream_dir = "fcos-builds/prod/streams/${params.STREAM}" -} - -// substitute the right COSA image into the pod definition before spawning it -pod = pod.replace("COREOS_ASSEMBLER_IMAGE", params.COREOS_ASSEMBLER_IMAGE) - -// shouldn't need more than 256Mi for this job -pod = pod.replace("COREOS_ASSEMBLER_MEMORY_REQUEST", "256Mi") - -// use a unique label to force Kubernetes to provision a separate pod per run -def pod_label = "cosa-${UUID.randomUUID().toString()}" - -podTemplate(cloud: 'openshift', label: pod_label, yaml: pod) { - node(pod_label) { container('coreos-assembler') { - def ami, ami_region - def no_ami = false - - def meta_json - stage('Fetch Metadata') { - utils.shwrap(""" - export AWS_CONFIG_FILE=\${AWS_FCOS_BUILDS_BOT_CONFIG} - cosa init --branch ${params.STREAM} https://github.com/coreos/fedora-coreos-config - cosa buildprep --ostree --build=${params.VERSION} s3://${s3_stream_dir}/builds - """) - - def basearch = utils.shwrap_capture("cosa basearch") - meta_json = "builds/${params.VERSION}/${basearch}/meta.json" - def meta = readJSON file: meta_json - if (meta.amis.size() > 0) { - ami = meta['amis'][0]['hvm'] - ami_region = meta['amis'][0]['name'] - } else { - no_ami = true - } - } - - // fail immediately if the build contained no AMIs - if (no_ami) { - currentBuild.result = 'FAILURE' - return - } - - stage('Kola') { - parallel aws: { - stage('Kola:AWS') { - utils.shwrap(""" - export AWS_CONFIG_FILE=\${AWS_FCOS_KOLA_BOT_CONFIG} - # use `cosa kola` here since it knows about blacklisted tests - cosa kola run --build=${params.VERSION} -p aws --aws-ami ${ami} --aws-region ${ami_region} -b fcos -j 5 --no-test-exit-error - tar -cf - tmp/kola | xz -c9 > kola-run.tar.xz - """) - archiveArtifacts "kola-run.tar.xz" - } - }, - aws_upgrade: { - stage('Kola:AWS upgrade') { - utils.shwrap(""" - export AWS_CONFIG_FILE=\${AWS_FCOS_KOLA_BOT_CONFIG} - cosa kola --build=${params.VERSION} --upgrades -p=aws --aws-region=${ami_region} --no-test-exit-error - tar -cf - tmp/kola-upgrade | xz -c9 > kola-run-upgrade.tar.xz - """) - archiveArtifacts "kola-run-upgrade.tar.xz" - } - } - } - if (!utils.checkKolaSuccess("tmp/kola", currentBuild) || - !utils.checkKolaSuccess("tmp/kola-upgrade", currentBuild)) { - return - } - }} -} diff --git a/Jenkinsfile.kola.gcp b/Jenkinsfile.kola.gcp deleted file mode 100644 index 6cad38d89..000000000 --- a/Jenkinsfile.kola.gcp +++ /dev/null @@ -1,121 +0,0 @@ -def utils, streams -node { - checkout scm - utils = load("utils.groovy") - streams = load("streams.groovy") - pod = readFile(file: "manifests/pod.yaml") -} - -properties([ - pipelineTriggers([]), - parameters([ - choice(name: 'STREAM', - // list devel first so that it's the default choice - choices: (streams.development + streams.production + streams.mechanical), - description: 'Fedora CoreOS stream to test'), - string(name: 'VERSION', - description: 'Fedora CoreOS Build ID to test', - defaultValue: '', - trim: true), - string(name: 'S3_STREAM_DIR', - description: 'Fedora CoreOS S3 Stream Directory', - defaultValue: '', - trim: true), - string(name: 'COREOS_ASSEMBLER_IMAGE', - description: 'Override coreos-assembler image to use', - defaultValue: "coreos-assembler:master", - trim: true) - ]) -]) - -currentBuild.description = "[${params.STREAM}] - ${params.VERSION}" - -def s3_stream_dir = params.S3_STREAM_DIR -if (s3_stream_dir == "") { - s3_stream_dir = "fcos-builds/prod/streams/${params.STREAM}" -} - -// substitute the right COSA image into the pod definition before spawning it -pod = pod.replace("COREOS_ASSEMBLER_IMAGE", params.COREOS_ASSEMBLER_IMAGE) - -// shouldn't need more than 256Mi for this job -pod = pod.replace("COREOS_ASSEMBLER_MEMORY_REQUEST", "256Mi") - -// use a unique label to force Kubernetes to provision a separate pod per run -def pod_label = "cosa-${UUID.randomUUID().toString()}" - -podTemplate(cloud: 'openshift', label: pod_label, yaml: pod) { - node(pod_label) { container('coreos-assembler') { - def gcp_image = "" - // we'll want to get the image project from the meta.json in the - // future, but it's not in there for now. - // def gcp_image_project - def gcp_image_project='fedora-coreos-cloud' - - def meta_json - stage('Fetch Metadata') { - utils.shwrap(""" - export AWS_CONFIG_FILE=\${AWS_FCOS_BUILDS_BOT_CONFIG} - cosa init --branch ${params.STREAM} https://github.com/coreos/fedora-coreos-config - cosa buildprep --ostree --build=${params.VERSION} s3://${s3_stream_dir}/builds - """) - - def basearch = utils.shwrap_capture("cosa basearch") - meta_json = "builds/${params.VERSION}/${basearch}/meta.json" - def meta = readJSON file: meta_json - if (meta.gcp.image) { - gcp_image = meta.gcp.image - } - } - - // fail immediately if the build contained no GCP image - if (gcp_image == "") { - currentBuild.result = 'FAILURE' - return - } - - stage('Kola') { - parallel gcp: { - stage('Kola:GCP') { - utils.shwrap(""" - # pick up the project to use from the config - gcp_project=\$(jq -r .project_id \${GCP_KOLA_TESTS_CONFIG}) - # use `cosa kola` here since it knows about blacklisted tests - cosa kola run \ - -b fcos -j 5 \ - --no-test-exit-error \ - --build=${params.VERSION} \ - --platform=gce \ - --gce-project=\${gcp_project} \ - --gce-image="projects/${gcp_image_project}/global/images/${gcp_image}" \ - --gce-json-key=\${GCP_KOLA_TESTS_CONFIG} - tar -cf - tmp/kola | xz -c9 > kola-run.tar.xz - """) - archiveArtifacts "kola-run.tar.xz" - } - }, - gcp_upgrade: { - stage('Kola:GCP upgrade') { - utils.shwrap(""" - # pick up the project to use from the config - gcp_project=\$(jq -r .project_id \${GCP_KOLA_TESTS_CONFIG}) - # use `cosa kola` here since it knows about blacklisted tests - cosa kola \ - --build=${params.VERSION} \ - --upgrades \ - --no-test-exit-error \ - --platform=gce \ - --gce-project=\${gcp_project} \ - --gce-json-key=\${GCP_KOLA_TESTS_CONFIG} - tar -cf - tmp/kola-upgrade | xz -c9 > kola-run-upgrade.tar.xz - """) - archiveArtifacts "kola-run-upgrade.tar.xz" - } - } - } - if (!utils.checkKolaSuccess("tmp/kola", currentBuild) || - !utils.checkKolaSuccess("tmp/kola-upgrade", currentBuild)) { - return - } - }} -} diff --git a/jobs/kola-aws.Jenkinsfile b/jobs/kola-aws.Jenkinsfile new file mode 100644 index 000000000..bf9906eaf --- /dev/null +++ b/jobs/kola-aws.Jenkinsfile @@ -0,0 +1,64 @@ +@Library('github.com/coreos/coreos-ci-lib') _ + +def streams +node { + checkout scm + streams = load("streams.groovy") +} + +properties([ + pipelineTriggers([]), + parameters([ + choice(name: 'STREAM', + // list devel first so that it's the default choice + choices: (streams.development + streams.production + streams.mechanical), + description: 'Fedora CoreOS stream to test'), + string(name: 'VERSION', + description: 'Fedora CoreOS Build ID to test', + defaultValue: '', + trim: true), + string(name: 'S3_STREAM_DIR', + description: 'Override the Fedora CoreOS S3 stream directory', + defaultValue: '', + trim: true), + string(name: 'COREOS_ASSEMBLER_IMAGE', + description: 'Override the coreos-assembler image to use', + defaultValue: "coreos-assembler:master", + trim: true) + ]) +]) + +currentBuild.description = "[${params.STREAM}] - ${params.VERSION}" + +def s3_stream_dir = params.S3_STREAM_DIR +if (s3_stream_dir == "") { + s3_stream_dir = "fcos-builds/prod/streams/${params.STREAM}" +} + +cosaPod(image: params.COREOS_ASSEMBLER_IMAGE, memory: "256Mi", + secrets: ["aws-fcos-builds-bot-config", "aws-fcos-kola-bot-config"]) { + + def ami, ami_region + stage('Fetch Metadata') { + shwrap(""" + export AWS_CONFIG_FILE=${AWS_FCOS_BUILDS_BOT_CONFIG}/config + cosa init --branch ${params.STREAM} https://github.com/coreos/fedora-coreos-config + cosa buildprep --ostree --build=${params.VERSION} s3://${s3_stream_dir}/builds + """) + + def basearch = shwrapCapture("cosa basearch") + def meta = readJSON file: "builds/${params.VERSION}/${basearch}/meta.json" + if (meta.amis.size() > 0) { + ami = meta['amis'][0]['hvm'] + ami_region = meta['amis'][0]['name'] + } else { + throw new Exception("No AMI found in metadata for ${params.VERSION}") + } + } + + fcosKola(cosaDir: env.WORKSPACE, parallel: 5, build: params.VERSION, + platformArgs: """-p aws \ + --aws-credentials-file ${AWS_FCOS_KOLA_BOT_CONFIG}/config \ + --aws-ami ${ami} \ + --aws-region ${ami_region}""") +} diff --git a/jobs/kola-gcp.Jenkinsfile b/jobs/kola-gcp.Jenkinsfile new file mode 100644 index 000000000..7c2ef89be --- /dev/null +++ b/jobs/kola-gcp.Jenkinsfile @@ -0,0 +1,68 @@ +@Library('github.com/coreos/coreos-ci-lib') _ + +def streams +node { + checkout scm + streams = load("streams.groovy") +} + +properties([ + pipelineTriggers([]), + parameters([ + choice(name: 'STREAM', + // list devel first so that it's the default choice + choices: (streams.development + streams.production + streams.mechanical), + description: 'Fedora CoreOS stream to test'), + string(name: 'VERSION', + description: 'Fedora CoreOS Build ID to test', + defaultValue: '', + trim: true), + string(name: 'S3_STREAM_DIR', + description: 'Override the Fedora CoreOS S3 stream directory', + defaultValue: '', + trim: true), + string(name: 'COREOS_ASSEMBLER_IMAGE', + description: 'Override the coreos-assembler image to use', + defaultValue: "coreos-assembler:master", + trim: true) + ]) +]) + +currentBuild.description = "[${params.STREAM}] - ${params.VERSION}" + +def s3_stream_dir = params.S3_STREAM_DIR +if (s3_stream_dir == "") { + s3_stream_dir = "fcos-builds/prod/streams/${params.STREAM}" +} + +cosaPod(image: params.COREOS_ASSEMBLER_IMAGE, memory: "256Mi", + secrets: ["aws-fcos-builds-bot-config", "gcp-kola-tests-config"]) { + + def gcp_image, gcp_image_project, gcp_project + stage('Fetch Metadata') { + shwrap(""" + export AWS_CONFIG_FILE=${AWS_FCOS_BUILDS_BOT_CONFIG}/config + cosa init --branch ${params.STREAM} https://github.com/coreos/fedora-coreos-config + cosa buildprep --ostree --build=${params.VERSION} s3://${s3_stream_dir}/builds + """) + + def basearch = shwrapCapture("cosa basearch") + def meta = readJSON file: "builds/${params.VERSION}/${basearch}/meta.json" + if (meta.gcp.image) { + gcp_image = meta.gcp.image + gcp_image_project = meta.gcp.project + } else { + throw new Exception("No GCP image found in metadata for ${params.VERSION}") + } + + // pick up the project to use from the config + def config = readJSON file: "/run/kubernetes/secrets/gcp-kola-tests-config/config" + gcp_project = config.project_id + } + + fcosKola(cosaDir: env.WORKSPACE, parallel: 5, build: params.VERSION, + platformArgs: """-p gce \ + --gce-json-key=${GCP_KOLA_TESTS_CONFIG}/config \ + --gce-project ${gcp_project} \ + --gce-image projects/${gcp_image_project}/global/images/${gcp_image}""") +} diff --git a/manifests/pipeline.yaml b/manifests/pipeline.yaml index a167814bb..377ff98ef 100644 --- a/manifests/pipeline.yaml +++ b/manifests/pipeline.yaml @@ -238,41 +238,3 @@ objects: jenkinsPipelineStrategy: type: JenkinsPipeline jenkinsfilePath: Jenkinsfile.stream.metadata.generator - - ### FEDORA COREOS TEST PIPELINES ### - - - kind: BuildConfig - apiVersion: "build.openshift.io/v1" - metadata: - name: fedora-coreos-pipeline-kola-aws - annotations: - coreos.com/deploy-default: "false" - spec: - source: - type: Git - git: - uri: ${JENKINS_JOBS_URL} - ref: ${JENKINS_JOBS_REF} - strategy: - jenkinsPipelineStrategy: - type: JenkinsPipeline - jenkinsfilePath: Jenkinsfile.kola.aws - runPolicy: Parallel - - - kind: BuildConfig - apiVersion: "build.openshift.io/v1" - metadata: - name: fedora-coreos-pipeline-kola-gcp - annotations: - coreos.com/deploy-default: "false" - spec: - source: - type: Git - git: - uri: ${JENKINS_JOBS_URL} - ref: ${JENKINS_JOBS_REF} - strategy: - jenkinsPipelineStrategy: - type: JenkinsPipeline - jenkinsfilePath: Jenkinsfile.kola.gcp - runPolicy: Parallel