Skip to content

Commit

Permalink
Merge pull request #292 from cgwalters/ootpa-crio
Browse files Browse the repository at this point in the history
jenkins: Create a prepare_configuration() helper
  • Loading branch information
openshift-merge-robot authored Sep 17, 2018
2 parents 9d78aae + 681f057 commit d6c0cfc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
13 changes: 4 additions & 9 deletions Jenkinsfile.treecompose
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ node(NODE) {
def treecompose_workdir = "${WORKSPACE}/treecompose";
def repo = "${treecompose_workdir}/repo";

stage("Prepare configuration") {
utils.prepare_configuration();
}

stage("Pull and run oscontainer") {
withCredentials([
usernameColonPassword(credentialsId: params.REGISTRY_CREDENTIALS, variable: 'CREDS'),
Expand All @@ -37,17 +41,8 @@ node(NODE) {
}
}

stage("Pull in creds for cri-o-tested repo") {
withCredentials([
file(credentialsId: params.OPENSHIFT_MIRROR_CREDENTIALS_FILE, variable: 'OPENSHIFT_MIRROR_CREDENTIALS_FILE'),
]) {
sh """cp ${OPENSHIFT_MIRROR_CREDENTIALS_FILE} ${WORKSPACE}/ops-mirror.pem && sed -i -e "s~WORKSPACE~$WORKSPACE~g" ${WORKSPACE}/cri-o-tested.repo"""
}
}

def last_build_version, force_nocache
stage("Check for Changes") { sh """
make repo-refresh
rpm-ostree compose tree --dry-run --repo=${repo} --touch-if-changed=$WORKSPACE/build.stamp ${manifest}
"""
last_build_version = utils.get_rev_version(repo, ref)
Expand Down
15 changes: 4 additions & 11 deletions Jenkinsfile.treecompose-ootpa
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ node(NODE) {
def treecompose_workdir = "${WORKSPACE}/treecompose";
def repo = "${treecompose_workdir}/repo";

stage("Prepare configuration") {
utils.prepare_configuration();
}

stage("Pull and run oscontainer") {
withCredentials([
usernameColonPassword(credentialsId: params.REGISTRY_CREDENTIALS, variable: 'CREDS'),
Expand All @@ -32,19 +36,8 @@ node(NODE) {
}
}

// NOTE - this differs from the base treecompose job
withCredentials([
string(credentialsId: params.OOTPA_COMPOSE, variable: 'OOTPA_COMPOSE'),
string(credentialsId: params.OOTPA_BUILDROOT_COMPOSE, variable: 'OOTPA_BUILDROOT_COMPOSE'),
]) {
sh """
sed -e 's,@OOTPA_COMPOSE@,${OOTPA_COMPOSE},' -e 's,@OOTPA_BUILDROOT_COMPOSE@,${OOTPA_BUILDROOT_COMPOSE},' < ootpa.repo.in > ootpa.repo
"""
}

def last_build_version, force_nocache
stage("Check for Changes") { sh """
make repo-refresh
rpm-ostree compose tree --dry-run --repo=${repo} --touch-if-changed=$WORKSPACE/build.stamp ${manifest}
"""
last_build_version = utils.get_rev_version(repo, ref)
Expand Down
15 changes: 15 additions & 0 deletions pipeline-utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,21 @@ def sh_capture(cmd) {
return sh(returnStdout: true, script: cmd).trim()
}

// Substitute secrets from credentials into files in the git repo
def prepare_configuration() {
withCredentials([
string(credentialsId: params.OOTPA_COMPOSE, variable: 'OOTPA_COMPOSE'),
string(credentialsId: params.OOTPA_BUILDROOT_COMPOSE, variable: 'OOTPA_BUILDROOT_COMPOSE'),
file(credentialsId: params.OPENSHIFT_MIRROR_CREDENTIALS_FILE, variable: 'OPENSHIFT_MIRROR_CREDENTIALS_FILE'),
]) {
sh """
make repo-refresh
sed -e 's,@OOTPA_COMPOSE@,${OOTPA_COMPOSE},' -e 's,@OOTPA_BUILDROOT_COMPOSE@,${OOTPA_BUILDROOT_COMPOSE},' < ootpa.repo.in > ootpa.repo
cp ${OPENSHIFT_MIRROR_CREDENTIALS_FILE} ${WORKSPACE}/ops-mirror.pem && sed -i -e "s~WORKSPACE~$WORKSPACE~g" ${WORKSPACE}/cri-o-tested.repo
"""
}
}

// Helper function to run code inside our assembler container.
// Takes args (string) of extra args for docker, and `fn` to execute.
def inside_assembler_container(args, fn) {
Expand Down

0 comments on commit d6c0cfc

Please sign in to comment.