Skip to content

Commit 6a1d3ee

Browse files
committed
jenkinsfile
1 parent 3059b2b commit 6a1d3ee

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

‎Jenkinsfile‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
pipeline {
2+
agent any
3+
4+
environment {
5+
DOCKER_REGISTRY = 'git.janpeterdhalle.com'
6+
IMAGE_NAME = 'jp-transfer-service'
7+
GIT_USERNAME = 'jp'
8+
}
9+
10+
tools {
11+
jdk 'java21'
12+
maven 'maven3'
13+
}
14+
15+
stages {
16+
stage('Checkout') {
17+
steps {
18+
checkout scm
19+
}
20+
}
21+
22+
stage('Build with Maven') {
23+
steps {
24+
sh 'mvn -B clean package'
25+
}
26+
}
27+
28+
stage('Docker Build & Push') {
29+
steps {
30+
script {
31+
// Default tag
32+
def imageTag = "latest"
33+
34+
// If current branch is 'develop', append _dev
35+
if (env.BRANCH_NAME == "develop") {
36+
imageTag = "latest_dev"
37+
}
38+
39+
def fullImage = "${DOCKER_REGISTRY}/${GIT_USERNAME}/${IMAGE_NAME}:${imageTag}"
40+
41+
withCredentials([usernamePassword(credentialsId: 'forgejo', usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASS')]) {
42+
sh """
43+
echo "\$DOCKER_PASS" | docker login \$DOCKER_REGISTRY -u "\$DOCKER_USER" --password-stdin
44+
docker build -t ${fullImage} .
45+
docker push ${fullImage}
46+
"""
47+
}
48+
}
49+
}
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)