NexusDashboard/Jenkinsfile

53 lines
1.4 KiB
Plaintext
Raw Normal View History

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: '',
name: 'BRANCH',
quickFilterEnabled: false,
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 04:47:17 +00:00
currentBuild.setDescription(params.BRANCH)
2022-01-16 18:22:00 +00:00
stage('Clone Code'){
checkout([
$class: 'GitSCM',
branches: [[name: params.BRANCH]],
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 = ''
stage("Build Container"){
2022-01-16 18:28:21 +00:00
if (params.BRANCH.contains('main')){
2022-01-16 18:22:00 +00:00
tag = 'latest'
} else {
tag = params.BRANCH.replace('\\', '-')
}
2022-01-16 18:36:55 +00:00
sh "docker build -t aronwk/nexus-dashboard:${tag} ."
2022-01-16 18:22:00 +00:00
}
stage("Push Container"){
withCredentials([usernamePassword(credentialsId: 'docker-hub-token', passwordVariable: 'password', usernameVariable: 'username')]) {
sh "docker login -u ${username} -p ${password}"
2022-01-16 18:36:55 +00:00
sh "docker push aronwk/nexus-dashboard:${tag}"
2022-01-16 18:22:00 +00:00
sh 'docker logout'
}
}
}