Skip to content

Commit

Permalink
feat: add CI/CD Jenkins Groovy pipeline and semver releaserc
Browse files Browse the repository at this point in the history
- Introduced `Jenkinsfile` for a simple CD pipeline
- Added semver using `semantic-release` (`.releaserc`)

Fixes issue #4
  • Loading branch information
sydrawat01 authored and rishabNeu committed Nov 16, 2023
1 parent 0480210 commit 781475e
Show file tree
Hide file tree
Showing 4 changed files with 7,864 additions and 1,457 deletions.
61 changes: 61 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"branches": [
"master"
],
"repositoryUrl": "https://github.com/csye7125-fall2023-group05/webapp.git",
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/npm",
{
"npmPublish": false
}
],
[
"@semantic-release/git",
{
"assets": [
"package.json",
"package-lock.json",
"CHANGELOG.md"
]
}
],
"@semantic-release/github"
],
"release": {
"verifyConditions": {
"path": [
"@semantic-release/changelog",
"@semantic-release/github",
"@semantic-release/git"
]
},
"analyzeCommits": [
"@semantic-release/commit-analyzer"
],
"generateNotes": [
"@semantic-release/release-notes-generator",
{
"preset": "angular",
"writerOpts": {
"commitsSort": [
"header"
]
}
}
],
"prepare": [
"@semantic-release/git",
{
"path": "@semantic-release/changelog",
"changelogFile": "CHANGELOG.md"
}
],
"publish": "@semantic-release/github",
"success": "@semantic-release/github",
"fail": "@semantic-release/github"
}
}
54 changes: 54 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
pipeline {
agent any
tools { nodejs "node" }
environment {
GH_TOKEN = credentials('jenkins-pat')
}
stages {
stage('Clone repository') {
when {
branch 'master'
}
steps {
cleanWs()
checkout scm
}
}
stage('Release with semantic-release') {
when {
branch 'master'
}
steps {
sh '''
npm ci
npx semantic-release
'''
}
}
stage('Build Image') {
when {
branch 'master'
}
steps {
sh 'docker build --no-cache -t quay.io/pwncorp/producer:$(npm pkg get version | xargs) -t quay.io/pwncorp/producer:latest -f Dockerfile .'
}
}
stage('Push Image') {
when {
branch 'master'
}
steps {
withCredentials([usernamePassword(credentialsId: 'dockerHub', passwordVariable: 'DOCKERHUB_PASSWORD', usernameVariable: 'DOCKERHUB_USERNAME')]) {
sh 'docker login quay.io -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD'
sh 'docker image push --all-tags quay.io/pwncorp/producer'
}
}
}
}
post {
always {
sh 'docker logout'
sh 'docker system prune -a -f'
}
}
}
Loading

0 comments on commit 781475e

Please sign in to comment.