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

BITGRIP - Build on jenkins #7

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ FROM node:16-alpine as development

WORKDIR /usr/src/app

COPY package*.json .
COPY package*.json ./

RUN npm install

COPY . .
COPY . ./

RUN npm run build

Expand All @@ -17,7 +17,7 @@ ENV NODE_ENV=${NODE_ENV}

WORKDIR /usr/src/app

COPY package*.json .
COPY package*.json ./

RUN npm ci --only=production

Expand Down
61 changes: 61 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/* groovylint-disable-next-line LineLength */
/* groovylint-disable CompileStatic, DuplicateStringLiteral, NoDef, UnusedVariable, VariableName, VariableTypeRequired */
@Library('[email protected]') _
pipeline {
agent {
label 'docker'
}
options {
ansiColor('xterm')
buildDiscarder(
logRotator(
artifactDaysToKeepStr: '',
artifactNumToKeepStr: '',
daysToKeepStr: '1',
numToKeepStr: '10'
)
)
disableConcurrentBuilds()
}
environment {
// https://bitbucket.org/bitgrip/bitgrip-pipeline-global/src/master/#markdown-header-bitgripgetuserid
DOCKER_USER = bitgripGetUserId(this)
// https://bitbucket.org/bitgrip/bitgrip-pipeline-global/src/master/#markdown-header-bitgripgetgroupid
DOCKER_GROUP = bitgripGetGroupId(this, [groupname: 'docker'])
SELECTOR_BACKEND_IMAGE = 'bitgrip/selector-backend'
SELECTOR_BACKEND_VERSION = '1.0.0'
ANSIBLE_FORCE_COLOR = true
DOCKER_IMAGE_BUILD_NAME = 'docker:20.10.17-cli-alpine3.16'
}
stages {
stage('Build image') {
agent {
docker {
image DOCKER_IMAGE_BUILD_NAME
args "-u ${DOCKER_USER}:${DOCKER_GROUP} -v /var/run/docker.sock:/var/run/docker.sock"
reuseNode true
}
}
steps {
script {
bitgripBuildDockerImage(this, [
imageName: "${env.SELECTOR_BACKEND_IMAGE}",
imageVersion: "${env.SELECTOR_BACKEND_VERSION}"
])
}
}
}
stage('Deploy') {
steps {
build(
quietPeriod: 0,
job: 'bitgrip/bitgrip-operations/main',
parameters: [
string(name: 'PLAYBOOK', value: 'deploy-selector'),
string(name: 'EXTRA_VARS', value: '')
]
)
}
}
}
}