Skip to content

Commit

Permalink
ART-10563 Create build-microshift-bootc job (#4270)
Browse files Browse the repository at this point in the history
  • Loading branch information
thegreyd authored Nov 12, 2024
1 parent 5ec6a22 commit 243f041
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 7 deletions.
128 changes: 128 additions & 0 deletions jobs/build/build-microshift-bootc/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
node() {
wrap([$class: "BuildUser"]) {
// gomod created files have filemode 444. It will lead to a permission denied error in the next build.
sh "chmod u+w -R ."
checkout scm
def buildlib = load("pipeline-scripts/buildlib.groovy")
def commonlib = buildlib.commonlib

commonlib.describeJob("build-microshift-bootc", """
<h2>Build and release microshift-bootc image for an assembly.</h2>
""")

properties(
[
disableResume(),
buildDiscarder(
logRotator(
artifactDaysToKeepStr: "30",
artifactNumToKeepStr: "",
daysToKeepStr: "30",
numToKeepStr: "")),
[
$class: "ParametersDefinitionProperty",
parameterDefinitions: [
commonlib.ocpVersionParam('BUILD_VERSION', '4'),
commonlib.artToolsParam(),
string(
name: "ASSEMBLY",
description: "The name of an assembly to rebase & build for. e.g. 4.9.1",
defaultValue: "test",
trim: true
),
booleanParam(
name: "FORCE_REBUILD",
description: "Rebuild even if a build already exists",
defaultValue: false
),
booleanParam(
name: "FORCE_PLASHET_SYNC",
description: "Force plashet sync needed for the build",
defaultValue: false
),
string(
name: 'DOOZER_DATA_PATH',
description: 'ocp-build-data fork to use (e.g. assembly definition in your own fork)',
defaultValue: "https://github.com/openshift-eng/ocp-build-data",
trim: true,
),
booleanParam(
name: 'IGNORE_LOCKS',
description: 'Do not wait for other builds in this version to complete (use only if you know they will not conflict)',
defaultValue: false
),
booleanParam(
name: "DRY_RUN",
description: "Take no action, just echo what the job would have done.",
defaultValue: false
),
commonlib.mockParam(),
]
],
]
)

commonlib.checkMock()
stage("initialize") {
currentBuild.displayName += " $params.BUILD_VERSION - $params.ASSEMBLY"
if (params.DRY_RUN) {
currentBuild.displayName = "[DRY RUN] " + currentBuild.displayName
}
}
try {
stage("build") {
buildlib.cleanWorkdir("./artcd_working")
sh "mkdir -p ./artcd_working"
def cmd = [
"artcd",
"-vv",
"--working-dir=./artcd_working",
"--config", "./config/artcd.toml",
]

if (params.DRY_RUN) {
cmd << "--dry-run"
}
cmd += [
"build-microshift-bootc",
"--data-path", params.DOOZER_DATA_PATH,
"-g", "openshift-$params.BUILD_VERSION",
"--assembly", params.ASSEMBLY,
]
if (params.FORCE_REBUILD) {
cmd << "--force"
}
if (params.FORCE_PLASHET_SYNC) {
cmd << "--force-plashet-sync"
}
withCredentials([
string(credentialsId: 'art-bot-slack-token', variable: 'SLACK_BOT_TOKEN'),
string(credentialsId: 'openshift-bot-token', variable: 'GITHUB_TOKEN'),
file(credentialsId: 'konflux-gcp-app-creds-prod', variable: 'GOOGLE_APPLICATION_CREDENTIALS'),
file(credentialsId: 'openshift-bot-konflux-service-account', variable: 'KONFLUX_SA_KUBECONFIG'),
file(credentialsId: 'aws-credentials-file', variable: 'AWS_SHARED_CREDENTIALS_FILE'),
string(credentialsId: 's3-art-srv-enterprise-cloudflare-endpoint', variable: 'CLOUDFLARE_ENDPOINT'),
]) {
echo "Will run ${cmd}"
buildlib.withAppCiAsArtPublish() {
if (params.IGNORE_LOCKS) {
commonlib.shell(script: cmd.join(' '))
} else {
lock("build-microshift-bootc-lock-${params.BUILD_VERSION}") {
commonlib.shell(script: cmd.join(' '))
}
}
}
}
}
} finally {
stage("save artifacts") {
commonlib.safeArchiveArtifacts([
"artcd_working/email/**",
"artcd_working/**/*.json",
"artcd_working/**/*.log",
])
}
}
}
}
16 changes: 9 additions & 7 deletions jobs/build/build-microshift/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ node() {
stage("initialize") {
currentBuild.displayName += " $params.BUILD_VERSION - $params.ASSEMBLY"
if (params.DRY_RUN) {
currentBuild.displayName += "[DRY RUN] " + currentBuild.displayName
currentBuild.displayName = "[DRY RUN] " + currentBuild.displayName
}
}
try {
Expand Down Expand Up @@ -106,12 +106,14 @@ node() {
if (params.NO_REBASE) {
cmd << "--no-rebase"
}
withCredentials([string(credentialsId: 'art-bot-slack-token', variable: 'SLACK_BOT_TOKEN'),
string(credentialsId: 'jboss-jira-token', variable: 'JIRA_TOKEN'),
string(credentialsId: 'openshift-bot-token', variable: 'GITHUB_TOKEN'),
string(credentialsId: 'jenkins-service-account', variable: 'JENKINS_SERVICE_ACCOUNT'),
string(credentialsId: 'jenkins-service-account-token', variable: 'JENKINS_SERVICE_ACCOUNT_TOKEN'),
file(credentialsId: 'konflux-gcp-app-creds-prod', variable: 'GOOGLE_APPLICATION_CREDENTIALS')]) {
withCredentials([
string(credentialsId: 'art-bot-slack-token', variable: 'SLACK_BOT_TOKEN'),
string(credentialsId: 'jboss-jira-token', variable: 'JIRA_TOKEN'),
string(credentialsId: 'openshift-bot-token', variable: 'GITHUB_TOKEN'),
string(credentialsId: 'jenkins-service-account', variable: 'JENKINS_SERVICE_ACCOUNT'),
string(credentialsId: 'jenkins-service-account-token', variable: 'JENKINS_SERVICE_ACCOUNT_TOKEN'),
file(credentialsId: 'konflux-gcp-app-creds-prod', variable: 'GOOGLE_APPLICATION_CREDENTIALS'),
]) {
echo "Will run ${cmd}"
buildlib.withAppCiAsArtPublish() {
if (params.IGNORE_LOCKS) {
Expand Down

0 comments on commit 243f041

Please sign in to comment.