Compare commits
18 Commits
complete-p
...
jenkins-jo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1c4f8d935 | ||
|
|
8400daafc4 | ||
|
|
a00620713a | ||
|
|
9ee144a8fe | ||
|
|
91a05d6024 | ||
|
|
727706f03f | ||
|
|
e2d13b9df0 | ||
|
|
2fda2eb1dc | ||
|
|
0f6500fd32 | ||
|
|
51d6d268c8 | ||
|
|
6d2354c4e9 | ||
|
|
ac89590227 | ||
|
|
680723e88d | ||
|
|
ee8acd6d8c | ||
|
|
6f52b6801e | ||
|
|
fd4815724f | ||
|
|
70fb6f1f11 | ||
|
|
8c32984bfa |
28
Jenkinsfile-basic
Normal file
28
Jenkinsfile-basic
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env groovy
|
||||||
|
|
||||||
|
pipeline {
|
||||||
|
agent none
|
||||||
|
stages {
|
||||||
|
stage('build') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
echo "Building the application..."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('test') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
echo "Testing the application..."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('deploy') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
echo "Deploying the application..."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
0
Jenkinsfile-kubernetes/.gitkeep
Normal file
0
Jenkinsfile-kubernetes/.gitkeep
Normal file
11
Jenkinsfile → Jenkinsfile-kubernetes/Jenkinsfile
vendored
11
Jenkinsfile → Jenkinsfile-kubernetes/Jenkinsfile
vendored
@@ -6,8 +6,8 @@ pipeline {
|
|||||||
maven 'Maven'
|
maven 'Maven'
|
||||||
}
|
}
|
||||||
environment {
|
environment {
|
||||||
ECR_REPO_URL = '664574038682.dkr.ecr.eu-west-3.amazonaws.com'
|
DOCKER_REPO_SERVER = '664574038682.dkr.ecr.eu-west-3.amazonaws.com'
|
||||||
IMAGE_REPO = "${ECR_REPO_URL}/java-maven-app"
|
DOCKER_REPO = "${DOCKER_REPO_SERVER}/java-maven-app"
|
||||||
}
|
}
|
||||||
stages {
|
stages {
|
||||||
stage('increment version') {
|
stage('increment version') {
|
||||||
@@ -20,7 +20,6 @@ pipeline {
|
|||||||
def matcher = readFile('pom.xml') =~ '<version>(.+)</version>'
|
def matcher = readFile('pom.xml') =~ '<version>(.+)</version>'
|
||||||
def version = matcher[0][1]
|
def version = matcher[0][1]
|
||||||
env.IMAGE_NAME = "$version-$BUILD_NUMBER"
|
env.IMAGE_NAME = "$version-$BUILD_NUMBER"
|
||||||
echo "############ ${IMAGE_REPO}"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,9 +36,9 @@ pipeline {
|
|||||||
script {
|
script {
|
||||||
echo "building the docker image..."
|
echo "building the docker image..."
|
||||||
withCredentials([usernamePassword(credentialsId: 'ecr-credentials', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
|
withCredentials([usernamePassword(credentialsId: 'ecr-credentials', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
|
||||||
sh "docker build -t ${IMAGE_REPO}:${IMAGE_NAME} ."
|
sh "docker build -t ${DOCKER_REPO}:${IMAGE_NAME} ."
|
||||||
sh "echo $PASS | docker login -u $USER --password-stdin ${ECR_REPO_URL}"
|
sh "echo $PASS | docker login -u $USER --password-stdin ${DOCKER_REPO_SERVER}"
|
||||||
sh "docker push ${IMAGE_REPO}:${IMAGE_NAME}"
|
sh "docker push ${DOCKER_REPO}:${IMAGE_NAME}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
0
Jenkinsfile-simple-pipeline/.gitkeep
Normal file
0
Jenkinsfile-simple-pipeline/.gitkeep
Normal file
40
Jenkinsfile-simple-pipeline/Jenkinsfile
vendored
Normal file
40
Jenkinsfile-simple-pipeline/Jenkinsfile
vendored
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env groovy
|
||||||
|
|
||||||
|
def gv
|
||||||
|
|
||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
tools {
|
||||||
|
maven 'Maven'
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage("init") {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
gv = load "script.groovy"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage("build jar") {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
gv.buildJar()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage("build image") {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
gv.buildImage()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage("deploy") {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
gv.deployApp()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
19
Jenkinsfile-simple-pipeline/script.groovy
Normal file
19
Jenkinsfile-simple-pipeline/script.groovy
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
def buildJar() {
|
||||||
|
echo "building the application..."
|
||||||
|
sh 'mvn package'
|
||||||
|
}
|
||||||
|
|
||||||
|
def buildImage() {
|
||||||
|
echo "building the docker image..."
|
||||||
|
withCredentials([usernamePassword(credentialsId: 'docker-hub-repo', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
|
||||||
|
sh 'docker build -t nanajanashia/demo-app:jma-2.0 .'
|
||||||
|
sh "echo $PASS | docker login -u $USER --password-stdin"
|
||||||
|
sh 'docker push nanajanashia/demo-app:jma-2.0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def deployApp() {
|
||||||
|
echo 'deploying the application...'
|
||||||
|
}
|
||||||
|
|
||||||
|
return this
|
||||||
0
Jenkinsfile-syntax/.gitkeep
Normal file
0
Jenkinsfile-syntax/.gitkeep
Normal file
49
Jenkinsfile-syntax/Jenkinsfile
vendored
Normal file
49
Jenkinsfile-syntax/Jenkinsfile
vendored
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env groovy
|
||||||
|
|
||||||
|
def gv
|
||||||
|
|
||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
parameters {
|
||||||
|
choice(name: 'VERSION', choices: ['1.1.0', '1.2.0', '1.3.0'], description: '')
|
||||||
|
booleanParam(name: 'executeTests', defaultValue: true, description: '')
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage("init") {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
gv = load "script.groovy"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage("build") {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
gv.buildApp()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage("test") {
|
||||||
|
when {
|
||||||
|
expression {
|
||||||
|
params.executeTests
|
||||||
|
}
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
gv.testApp()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage("deploy") {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
env.ENV = input message: "Select the environment to deploy to", ok: "Done", parameters: [choice(name: 'ONE', choices: ['dev', 'staging', 'prod'], description: '')]
|
||||||
|
|
||||||
|
gv.deployApp()
|
||||||
|
echo "Deploying to ${ENV}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
19
Jenkinsfile-syntax/script.groovy
Normal file
19
Jenkinsfile-syntax/script.groovy
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
def buildJar() {
|
||||||
|
echo "building the application..."
|
||||||
|
sh 'mvn package'
|
||||||
|
}
|
||||||
|
|
||||||
|
def buildImage() {
|
||||||
|
echo "building the docker image..."
|
||||||
|
withCredentials([usernamePassword(credentialsId: 'docker-hub-repo', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
|
||||||
|
sh 'docker build -t nanajanashia/demo-app:jma-2.0 .'
|
||||||
|
sh "echo $PASS | docker login -u $USER --password-stdin"
|
||||||
|
sh 'docker push nanajanashia/demo-app:jma-2.0'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def deployApp() {
|
||||||
|
echo 'deploying the application...'
|
||||||
|
}
|
||||||
|
|
||||||
|
return this
|
||||||
0
Jenkinsfile-version-increment/.gitkeep
Normal file
0
Jenkinsfile-version-increment/.gitkeep
Normal file
66
Jenkinsfile-version-increment/Jenkinsfile
vendored
Normal file
66
Jenkinsfile-version-increment/Jenkinsfile
vendored
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
#!/usr/bin/env groovy
|
||||||
|
|
||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
tools {
|
||||||
|
maven 'Maven'
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage('increment version') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
echo 'incrementing app version...'
|
||||||
|
sh 'mvn build-helper:parse-version versions:set \
|
||||||
|
-DnewVersion=\\\${parsedVersion.majorVersion}.\\\${parsedVersion.minorVersion}.\\\${parsedVersion.nextIncrementalVersion} \
|
||||||
|
versions:commit'
|
||||||
|
def matcher = readFile('pom.xml') =~ '<version>(.+)</version>'
|
||||||
|
def version = matcher[0][1]
|
||||||
|
env.IMAGE_NAME = "$version-$BUILD_NUMBER"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('build app') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
echo "building the application..."
|
||||||
|
sh 'mvn clean package'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('build image') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
echo "building the docker image..."
|
||||||
|
withCredentials([usernamePassword(credentialsId: 'docker-hub-repo', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
|
||||||
|
sh "docker build -t nanajanashia/demo-app:${IMAGE_NAME} ."
|
||||||
|
sh "echo $PASS | docker login -u $USER --password-stdin"
|
||||||
|
sh "docker push nanajanashia/demo-app:${IMAGE_NAME}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('deploy') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
echo 'deploying docker image to EC2...'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('commit version update') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
withCredentials([usernamePassword(credentialsId: 'gitlab-credentials', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
|
||||||
|
// git config here for the first time run
|
||||||
|
sh 'git config --global user.email "jenkins@example.com"'
|
||||||
|
sh 'git config --global user.name "jenkins"'
|
||||||
|
|
||||||
|
sh "git remote set-url origin https://${USER}:${PASS}@gitlab.com/nanuchi/java-maven-app.git"
|
||||||
|
sh 'git add .'
|
||||||
|
sh 'git commit -m "ci: version bump"'
|
||||||
|
sh 'git push origin HEAD:jenkins-jobs'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1
freestyle-build.sh
Normal file
1
freestyle-build.sh
Normal file
@@ -0,0 +1 @@
|
|||||||
|
npm --version
|
||||||
@@ -15,10 +15,10 @@ spec:
|
|||||||
app: $APP_NAME
|
app: $APP_NAME
|
||||||
spec:
|
spec:
|
||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
- name: my-registry-key
|
- name: aws-registry-key
|
||||||
containers:
|
containers:
|
||||||
- name: $APP_NAME
|
- name: $APP_NAME
|
||||||
image: $IMAGE_REPO:$IMAGE_NAME
|
image: $DOCKER_REPO:$IMAGE_NAME
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8080
|
- containerPort: 8080
|
||||||
|
|||||||
13
pom.xml
13
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.example</groupId>
|
<groupId>com.example</groupId>
|
||||||
<artifactId>java-maven-app</artifactId>
|
<artifactId>java-maven-app</artifactId>
|
||||||
<version>1.1.5</version>
|
<version>1.1.7</version>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
@@ -22,6 +22,17 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<!-- to handle any Java version mismatch, add the following configuration for maven-compiler-plugin -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.6.0</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>MyApp</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Welcome to Java Maven Application</h1>
|
|
||||||
<!-- add image here <img src="" width="" /> -->
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#Generated by Maven
|
#Generated by Maven
|
||||||
#Sat Dec 05 14:30:39 UTC 2020
|
#Sat Dec 05 15:54:34 UTC 2020
|
||||||
version=1.1.5
|
version=1.1.7
|
||||||
groupId=com.example
|
groupId=com.example
|
||||||
artifactId=java-maven-app
|
artifactId=java-maven-app
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Test set: AppTest
|
Test set: AppTest
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.126 sec
|
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.099 sec
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<testsuite tests="1" failures="0" name="AppTest" time="0.007" errors="0" skipped="0">
|
<testsuite tests="1" failures="0" name="AppTest" time="0.01" errors="0" skipped="0">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
|
<property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
|
||||||
<property name="sun.boot.library.path" value="/usr/local/openjdk-8/jre/lib/amd64"/>
|
<property name="sun.boot.library.path" value="/usr/local/openjdk-8/jre/lib/amd64"/>
|
||||||
@@ -60,5 +60,5 @@
|
|||||||
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
|
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
|
||||||
<property name="sun.cpu.isalist" value=""/>
|
<property name="sun.cpu.isalist" value=""/>
|
||||||
</properties>
|
</properties>
|
||||||
<testcase classname="AppTest" name="testApp" time="0.007"/>
|
<testcase classname="AppTest" name="testApp" time="0.01"/>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
Reference in New Issue
Block a user