Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci): RHINENG-1883 add Pulp client certificate to Jenkinsfile #2000

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 27 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ARG extras=""
ARG prod="true"
ARG pgRepo="http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/centos-stream-repos-8-4.el8.noarch.rpm"
ARG pgRepoKey="http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/centos-gpg-keys-8-4.el8.noarch.rpm"
ARG gemMirror=""
ARG httpProxy=""

FROM registry.access.redhat.com/ubi8/ubi-minimal AS build

Expand All @@ -14,6 +16,8 @@ ARG prod
ARG pgRepo
ARG pgRepoKey
ARG IMAGE_TAG
ARG gemMirror
ARG httpProxy

USER 0

Expand All @@ -22,26 +26,29 @@ WORKDIR /opt/app-root/src
COPY ./.gemrc.prod /etc/gemrc
COPY ./Gemfile.lock ./Gemfile /opt/app-root/src/

RUN FULL_RHEL=$(microdnf repolist --enabled | grep rhel-8); \
if [ -z "$FULL_RHEL" ] ; then \
rpm -Uvh $pgRepo $pgRepoKey && \
sed -i 's/^\(enabled.*\)/\1\npriority=200/;' /etc/yum.repos.d/CentOS*.repo; \
fi; \
rpm -e --nodeps tzdata &>/dev/null && \
microdnf module enable ruby:3.1 && \
microdnf module enable postgresql:13 && \
microdnf install --nodocs -y $deps $devDeps $extras && \
chmod +t /tmp && \
gem update --system -N --install-dir=/usr/share/gems --bindir /usr/bin && \
gem install bundler && \
( [[ $prod != "true" ]] || bundle config set --local --without 'development:test' ) && \
( [[ $prod != "true" ]] || bundle config set --local deployment 'true' ) && \
( [[ $prod != "true" ]] || bundle config set --local path './.bundle' ) && \
bundle config set --local retry '2' && \
bundle config set --local force_ruby_platform true && \
( [[ $prod != "true" ]] || bundle install --without development test ) && \
( [[ $prod == "true" ]] || bundle install ) && \
microdnf clean all -y && \
ENV http_proxy="$httpProxy"

RUN FULL_RHEL=$(microdnf repolist --enabled | grep rhel-8); \
if [ -z "$FULL_RHEL" ] ; then \
rpm -Uvh $pgRepo $pgRepoKey && \
sed -i 's/^\(enabled.*\)/\1\npriority=200/;' /etc/yum.repos.d/CentOS*.repo; \
fi; \
rpm -e --nodeps tzdata &>/dev/null && \
microdnf module enable ruby:3.1 && \
microdnf module enable postgresql:13 && \
microdnf install --nodocs -y $deps $devDeps $extras && \
chmod +t /tmp && \
( [[ $prod != "true" ]] || sed -i "s,https://rubygems.org/,$gemMirror," /etc/gemrc ) && \
gem update --system -N --install-dir=/usr/share/gems --bindir /usr/bin && \
gem install bundler && \
( [[ $prod != "true" ]] || bundle config set --local --without 'development:test' ) && \
( [[ $prod != "true" ]] || bundle config set --local deployment 'true' ) && \
( [[ $prod != "true" ]] || bundle config set --local path './.bundle' ) && \
bundle config set --local retry '2' && \
bundle config set --local force_ruby_platform true && \
( [[ $prod != "true" ]] || bundle install --without development test ) && \
( [[ $prod == "true" ]] || bundle install ) && \
microdnf clean all -y && \
( [[ $prod != "true" ]] || bundle clean -V )

LABEL BUILD_STAGE_OF=$IMAGE_TAG
Expand Down
11 changes: 6 additions & 5 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ def secrets = [
[envVar: 'QUAY_TOKEN', vaultKey: 'token']]],
[path: params.VAULT_PATH_INSIGHTSDROID_GITHUB, secretValues: [
[envVar: 'GITHUB_TOKEN', vaultKey: 'token'],
[envVar: 'GITHUB_API_URL', vaultKey: 'mirror_url']]],
[path: params.VAULT_PATH_RHR_PULL, secretValues: [
[envVar: 'RH_REGISTRY_USER', vaultKey: 'user'],
[envVar: 'RH_REGISTRY_TOKEN', vaultKey: 'token']]]
[envVar: 'GITHUB_API_URL', vaultKey: 'mirror_url']]]
]

def configuration = [vaultUrl: params.VAULT_ADDRESS, vaultCredentialId: params.VAULT_CREDS_ID]
Expand All @@ -35,14 +32,18 @@ pipeline {
IQE_MARKER_EXPRESSION="compliance_smoke"
IQE_PLUGINS="compliance"
REF_ENV="insights-stage"
GEM_MIRROR="https://internal.console.stage.redhat.com/api/pulp-content/compliance/rubygems/"
HTTP_PROXY="http://squid.corp.redhat.com:3128"
}

stages {

stage('Build the PR commit image') {
steps {
withVault([configuration: configuration, vaultSecrets: secrets]) {
sh 'bash -x build_deploy.sh'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preferring singleline version

sh '''
bash -x build_deploy.sh
'''
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion build_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CICD_TOOLS_URL="https://raw.githubusercontent.com/RedHatInsights/cicd-tools/main
source <(curl -sSL "$CICD_TOOLS_URL") image_builder

export CICD_IMAGE_BUILDER_IMAGE_NAME='quay.io/cloudservices/compliance-backend'
export CICD_IMAGE_BUILDER_BUILD_ARGS=("IMAGE_TAG=$(cicd::image_builder::get_image_tag)")
export CICD_IMAGE_BUILDER_BUILD_ARGS=("IMAGE_TAG=$(cicd::image_builder::get_image_tag)" "gemMirror=$GEM_MIRROR" "httpProxy=$HTTP_PROXY")
# Check if the current Git branch is 'origin/security-compliance'.
if [[ "$GIT_BRANCH" == "origin/security-compliance" ]]; then
# Generate a tag for the Docker image based on the current date and Git commit short hash.
Expand Down
1 change: 1 addition & 0 deletions scripts/deploy/build-deploy-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ build_image() {
#shellcheck disable=SC2086
container_engine_cmd build --pull -f "$DOCKERFILE" $BUILD_ARGS_CMD $LABEL_PARAMETER \
$DISABLE_CACHE_PARAMETER \
--build-arg gemMirror=$GEM_MIRROR --build-arg httpProxy=$HTTP_PROXY \
-t "${IMAGE_NAME}:${IMAGE_TAG}" .

#shellcheck disable=SC2181
Expand Down
Loading