NexusDash-izebra/Jenkinsfile

52 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: 'GIT_BRANCH',
quickFilterEnabled: true,
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'){
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',
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 = ''
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('\\', '-')
}
sh "docker build -t aronwk/nexus-dashboard:$tag ."
2022-01-16 18:22:00 +00:00
}
stage('Push Container'){
2022-01-16 18:22:00 +00:00
withCredentials([usernamePassword(credentialsId: 'docker-hub-token', passwordVariable: 'password', usernameVariable: 'username')]) {
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
}
}
}