Jenkinsfile test
This commit is contained in:
parent
fa27ac0bb2
commit
cb0cc370b0
55
Jenkinsfile
vendored
55
Jenkinsfile
vendored
@ -4,52 +4,67 @@ pipeline {
|
|||||||
def app
|
def app
|
||||||
stage('Clone') { // for display purposes
|
stage('Clone') { // for display purposes
|
||||||
// Get some code from a GitHub repository
|
// Get some code from a GitHub repository
|
||||||
echo env.BRANCH_NAME
|
steps {
|
||||||
script {
|
echo env.BRANCH_NAME
|
||||||
if (env.BRANCH_NAME == 'master') {
|
script {
|
||||||
git url: 'https://github.com/BrokenFire/BrokenDiscordBot.git', branch: 'master'
|
if (env.BRANCH_NAME == 'master') {
|
||||||
} else {
|
git url: 'https://github.com/BrokenFire/BrokenDiscordBot.git', branch: 'master'
|
||||||
git url: 'https://github.com/BrokenFire/BrokenDiscordBot.git', branch: 'devel'
|
} else {
|
||||||
|
git url: 'https://github.com/BrokenFire/BrokenDiscordBot.git', branch: 'devel'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
stage('Gradle Build'){
|
stage('Gradle Build'){
|
||||||
script {
|
steps{
|
||||||
if (env.BRANCH_NAME == 'master') {
|
script {
|
||||||
build job: 'Bot Discord Gradle', wait: true
|
if (env.BRANCH_NAME == 'master') {
|
||||||
} else {
|
build job: 'Bot Discord Gradle', wait: true
|
||||||
build job: 'Bot Discord Gradle devel', wait: true
|
} else {
|
||||||
|
build job: 'Bot Discord Gradle devel', wait: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
stage('Build Docker image') {
|
stage('Build Docker image') {
|
||||||
/* This builds the actual image; synonymous to
|
/* This builds the actual image; synonymous to
|
||||||
* docker build on the command line */
|
* docker build on the command line */
|
||||||
|
steps{
|
||||||
|
app = docker.build("brokenfire/brokendiscordbot",'--build-arg BUILD_NBR=${BUILD_NUMBER} --build-arg BRANCH_NAME=${BRANCH_NAME} --rm=true .')
|
||||||
|
}
|
||||||
|
|
||||||
app = docker.build("brokenfire/brokendiscordbot",'--build-arg BUILD_NBR=${BUILD_NUMBER} --build-arg BRANCH_NAME=${BRANCH_NAME} --rm=true .')
|
|
||||||
}
|
}
|
||||||
stage('Push Docker image') {
|
stage('Push Docker image') {
|
||||||
/* Finally, we'll push the image with two tags:
|
/* Finally, we'll push the image with two tags:
|
||||||
* First, the incremental build number from Jenkins
|
* First, the incremental build number from Jenkins
|
||||||
* Second, the 'latest' tag.
|
* Second, the 'latest' tag.
|
||||||
* Pushing multiple tags is cheap, as all the layers are reused. */
|
* Pushing multiple tags is cheap, as all the layers are reused. */
|
||||||
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'docker-hub-credentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
|
steps{
|
||||||
sh 'docker login -u $USERNAME -p $PASSWORD'
|
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'docker-hub-credentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
|
||||||
script {
|
sh 'docker login -u $USERNAME -p $PASSWORD'
|
||||||
if (env.BRANCH_NAME == 'master') {
|
script {
|
||||||
app.push()
|
if (env.BRANCH_NAME == 'master') {
|
||||||
} else {
|
app.push()
|
||||||
app.push("devel")
|
} else {
|
||||||
|
app.push("devel")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
stage('Cleaning'){
|
stage('Cleaning'){
|
||||||
sh "docker image prune -f"
|
steps{
|
||||||
|
sh "docker image prune -f"
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user