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

Debug jenkinsfile #2598

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
de4e83d
Jenkinsfile POC for build deploy
maknop Jul 26, 2023
21b706c
Fixing docker commands, run stages
maknop Jul 27, 2023
6de0823
Make scripts executable
maknop Jul 27, 2023
4750e66
Run stages in parallel
maknop Jul 27, 2023
ae69382
Fix indentation of stages
maknop Jul 27, 2023
d67c5c3
Fixed container names for each stage
maknop Jul 27, 2023
55574f4
Runner for each stage
maknop Jul 27, 2023
487a5dc
Adding cypress test stage
maknop Jul 27, 2023
787208a
Running different cypress command
maknop Jul 27, 2023
37fd0ff
Adding additional cypress command
maknop Jul 27, 2023
fcb7134
Install deps
maknop Jul 27, 2023
85a6cdc
Adding cypress image for e2e testing
maknop Jul 27, 2023
97bdae6
Updating image with tag for cypress test
maknop Jul 27, 2023
32fa0f4
Removing working dir from exec for cypress
maknop Jul 27, 2023
8ff5fcd
Fixing path for copying files to container
maknop Jul 27, 2023
2d6976c
Adding directory path for install
maknop Jul 27, 2023
6dee5b3
Removing command
maknop Jul 27, 2023
e16f98f
Checking file in dir
maknop Jul 27, 2023
ccb01bd
Run e2e tests
maknop Jul 27, 2023
204194c
change directory for npm run command
maknop Jul 28, 2023
957c461
Updates to cypress file
maknop Jul 28, 2023
3fd77a1
Fix
maknop Jul 28, 2023
6569746
Changing cypress test command
maknop Jul 28, 2023
489e102
Attempting with cypress base img
maknop Jul 28, 2023
837c844
Removing base cypress img
maknop Jul 28, 2023
fcc81c2
Removing cypress base img
maknop Jul 28, 2023
dd00497
Removing command
maknop Jul 28, 2023
2164064
Attempting different cypress image
maknop Jul 28, 2023
f1afe40
Reverting back to previous image
maknop Jul 28, 2023
1f27ccd
Install cypress in container
maknop Jul 28, 2023
e41e8d6
Removing package-lock in docker
maknop Jul 28, 2023
6421673
Removed command
maknop Jul 28, 2023
4545e9d
Comment out build, unit tests, lint
maknop Jul 31, 2023
c76a166
Adding testing commands
maknop Jul 31, 2023
bf41d34
Fixing syntax issue
maknop Jul 31, 2023
23d908c
Changing ownership of files
maknop Jul 31, 2023
a0b56b9
Testing podman
maknop Jul 31, 2023
448a790
Testing podman
maknop Jul 31, 2023
a075cf4
Revert to docker
maknop Jul 31, 2023
adcb973
Changing perms before cp to container
maknop Jul 31, 2023
8ffe03a
Change user/group contents of dir
maknop Jul 31, 2023
7f09883
Change user, not group
maknop Jul 31, 2023
3ce9480
-a flag
maknop Jul 31, 2023
bc42af0
Fixing parameter issue
maknop Jul 31, 2023
f143209
Running all stages in parallel.
maknop Jul 31, 2023
7c6eecb
Removing test code
maknop Jul 31, 2023
fe7b41e
Creating install step
maknop Jul 31, 2023
86fc61c
Fix docker cp
maknop Jul 31, 2023
e0bcefb
Removing added project var
maknop Jul 31, 2023
984df29
debug
Victoremepunto Aug 1, 2023
e9ebeed
refactor, add TTY
Victoremepunto Aug 1, 2023
c9f5aa0
test non interactive
Victoremepunto Aug 1, 2023
d847773
Refactor
Victoremepunto Aug 1, 2023
915c29d
debug
Victoremepunto Aug 1, 2023
01aed11
refactor
Victoremepunto Aug 1, 2023
8be7bb2
set -e
Victoremepunto Aug 1, 2023
1cbe18e
remove podman only flag
Victoremepunto Aug 1, 2023
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
71 changes: 69 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,86 @@ def secrets = [
[envVar: 'RH_REGISTRY_TOKEN', vaultKey: 'token']]],
]

def configuration = [vaultUrl: params.VAULT_ADDRESS, vaultCredentialId: params.VAULT_CREDS_ID, engineVersion: 1]

pipeline {
agent { label 'insights' }
options {
timestamps()
}

environment {
PROJECT_NAME="insights-chrome"
MASTER_BRANCH="master"
MASTER_STABLE_BRANCH="master-stable"
NODE_BASE_IMAGE="registry.access.redhat.com/ubi9/nodejs-18:1-53"
CYPRESS_TEST_IMAGE="quay.io/cloudservices/cypress-e2e-image:06b70f3"
}

stages {
stage('Placeholder') {
stage('Install') {
steps {
sh 'echo Placeholder Jenkinsfile'
sh '''
./ci/install.sh
'''
}
}

stage('Tests/Build for Frontends') {
parallel {
stage('Unit Testing') {
steps {
script {
TEST_CONT="${PROJECT_NAME}-unit-tests"

withVault([configuration: configuration, vaultSecrets: secrets]) {
sh '''
ls -lrt
echo "outside"
./ci/unit_tests.sh
'''
}
}
}
}

stage('Lint') {
steps {
sh "echo 'Lint'"

script {
withVault([configuration: configuration, vaultSecrets: secrets]) {
sh '''
./ci/lint.sh
'''
}
}
}
}

stage('Cypress Component Testing') {
steps {
script {
withVault([configuration: configuration, vaultSecrets: secrets]) {
sh '''
./ci/cypress.sh
'''
}
}
}
}

stage('Build') {
steps {
script {
withVault([configuration: configuration, vaultSecrets: secrets]) {
sh '''
./ci/build.sh
'''
}
}
}
}
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions ci/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

TEST_CONT="${PROJECT_NAME}-build"
IMG_TAG=$(git rev-parse --short=8 HEAD)

docker run --name "${TEST_CONT}-${IMG_TAG}" -d -i --rm "${NODE_BASE_IMAGE}" /bin/sh

docker cp . "${TEST_CONT}-${IMG_TAG}:/opt/app-root/src/"

docker exec -i -w "/opt/app-root/src/" "${TEST_CONT}-${IMG_TAG}" sh -c "npm install"

docker exec -i -w "/opt/app-root/src/" "${TEST_CONT}-${IMG_TAG}" sh -c "npm run build"
17 changes: 17 additions & 0 deletions ci/cypress.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

TEST_CONT="${PROJECT_NAME}-cypress"
IMG_TAG=$(git rev-parse --short=8 HEAD)
CONTAINER_NAME="${TEST_CONT}-${IMG_TAG}"
CONTAINER_WORKDIR="/e2e"

docker login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io

docker run --name "$CONTAINER_NAME" -d --rm -t --entrypoint bash \
-v "node_modules:${CONTAINER_WORKDIR}/node_modules" "${NODE_BASE_IMAGE}"

docker cp ./. "${CONTAINER_NAME}:${CONTAINER_WORKDIR}"

docker exec -it "$CONTAINER_NAME" "npm install"
docker exec -it "$CONTAINER_NAME" "npm run test:ct"
docker stop "$CONTAINER_NAME"
19 changes: 19 additions & 0 deletions ci/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -e


TEST_CONT="${PROJECT_NAME}-install"
IMG_TAG=$(git rev-parse --short=8 HEAD)
CONTAINER_NAME="${TEST_CONT}-${IMG_TAG}"
CONTAINER_WORKDIR="/opt/app-root/src"

# --ignore : ignore volume creation if already exists - DEBUG purposes only.
docker volume create node_modules
docker run --name "$CONTAINER_NAME" -d --rm -t --entrypoint bash \
-v "node_modules:${CONTAINER_WORKDIR}/node_modules" "${NODE_BASE_IMAGE}"

docker cp ./. "${CONTAINER_NAME}:${CONTAINER_WORKDIR}"

docker exec -it "$CONTAINER_NAME" "npm install"
docker stop "$CONTAINER_NAME"
15 changes: 15 additions & 0 deletions ci/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

TEST_CONT="${PROJECT_NAME}-lint"
IMG_TAG=$(git rev-parse --short=8 HEAD)
CONTAINER_NAME="${TEST_CONT}-${IMG_TAG}"
CONTAINER_WORKDIR="/opt/app-root/src"

docker run --name "$CONTAINER_NAME" -d --rm -t --entrypoint bash \
-v "node_modules:${CONTAINER_WORKDIR}/node_modules" "${NODE_BASE_IMAGE}"

docker cp ./. "${CONTAINER_NAME}:${CONTAINER_WORKDIR}"

docker exec -it "$CONTAINER_NAME" "npm install"
docker exec -it "$CONTAINER_NAME" "npm run lint"
docker stop "$CONTAINER_NAME"
18 changes: 18 additions & 0 deletions ci/unit_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

TEST_CONT="${PROJECT_NAME}-unit-tests"
IMG_TAG=$(git rev-parse --short=8 HEAD)
CONTAINER_NAME="${TEST_CONT}-${IMG_TAG}"
CONTAINER_WORKDIR="/opt/app-root/src"

docker run --name "$CONTAINER_NAME" -d --rm -t --entrypoint bash \
-v "node_modules:${CONTAINER_WORKDIR}/node_modules" "${NODE_BASE_IMAGE}"

echo "copying..."
time docker cp ./. "${CONTAINER_NAME}:${CONTAINER_WORKDIR}"
echo "installing ..."
time docker exec -it "$CONTAINER_NAME" "npm install"
echo "running tests..."
time docker exec -it "$CONTAINER_NAME" "npm run test -- --coverage"

docker stop "$CONTAINER_NAME"
Loading