2022-01-16 18:22:00 +00:00
|
|
|
properties([
|
|
|
|
parameters([
|
|
|
|
gitParameter(
|
|
|
|
branch: '',
|
|
|
|
branchFilter: 'origin/(.*)',
|
2022-01-16 18:28:21 +00:00
|
|
|
defaultValue: 'origin/main',
|
2022-01-16 18:22:00 +00:00
|
|
|
description: '',
|
2022-01-19 05:04:32 +00:00
|
|
|
name: 'GIT_BRANCH',
|
|
|
|
quickFilterEnabled: true,
|
2022-01-19 05:18:11 +00:00
|
|
|
listSize: 1,
|
2022-01-16 18:28:21 +00:00
|
|
|
selectedValue: 'DEFAULT',
|
2022-01-16 18:22:00 +00:00
|
|
|
sortMode: 'NONE',
|
|
|
|
tagFilter: '*',
|
2022-01-16 18:28:21 +00:00
|
|
|
useRepository: 'git@github.com:DarkflameUniverse/NexusDashboard.git',
|
2022-01-16 18:22:00 +00:00
|
|
|
type: 'PT_BRANCH'
|
|
|
|
)
|
|
|
|
])
|
|
|
|
])
|
|
|
|
|
|
|
|
node('worker'){
|
2022-01-19 05:04:32 +00:00
|
|
|
currentBuild.setDescription(params.GIT_BRANCH)
|
2022-01-19 04:47:17 +00:00
|
|
|
|
2022-01-16 18:22:00 +00:00
|
|
|
stage('Clone Code'){
|
|
|
|
checkout([
|
|
|
|
$class: 'GitSCM',
|
2022-01-19 05:04:32 +00:00
|
|
|
branches: [[name: params.GIT_BRANCH]],
|
2022-01-16 18:22:00 +00:00
|
|
|
extensions: [],
|
|
|
|
userRemoteConfigs: [
|
|
|
|
[
|
|
|
|
credentialsId: 'aronwk',
|
2022-01-16 18:28:21 +00:00
|
|
|
url: 'git@github.com:DarkflameUniverse/NexusDashboard.git'
|
2022-01-16 18:22:00 +00:00
|
|
|
]
|
|
|
|
]
|
|
|
|
])
|
|
|
|
}
|
|
|
|
def tag = ''
|
2022-01-19 04:52:11 +00:00
|
|
|
stage('Build Container'){
|
2022-01-19 05:23:13 +00:00
|
|
|
if (params.GIT_BRANCH.contains('main')){
|
2022-01-16 18:22:00 +00:00
|
|
|
tag = 'latest'
|
|
|
|
} else {
|
2022-01-19 05:23:13 +00:00
|
|
|
tag = params.GIT_BRANCH.replace('\\', '-')
|
2022-01-16 18:22:00 +00:00
|
|
|
}
|
2022-01-19 05:04:32 +00:00
|
|
|
sh "docker build -t aronwk/nexus-dashboard:$tag ."
|
2022-01-16 18:22:00 +00:00
|
|
|
}
|
2022-01-19 04:52:11 +00:00
|
|
|
stage('Push Container'){
|
2022-01-16 18:22:00 +00:00
|
|
|
withCredentials([usernamePassword(credentialsId: 'docker-hub-token', passwordVariable: 'password', usernameVariable: 'username')]) {
|
2022-01-19 05:04:32 +00:00
|
|
|
sh "docker login -u $username -p $password"
|
|
|
|
sh "docker push aronwk/nexus-dashboard:$tag"
|
|
|
|
sh "docker logout"
|
2022-01-16 18:22:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|