Last active
May 12, 2019 04:36
-
-
Save matthewoestreich/3f0f96cc33c2ca9d9a92ebfd46ff19ac to your computer and use it in GitHub Desktop.
Misc Jenkins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node { | |
def app | |
stage('Clone repository') { | |
checkout scm | |
} | |
stage('Build image') { | |
app = docker.build("oze4/vue-router-poc") | |
} | |
stage('Test image') { | |
app.inside { | |
sh 'echo "Tests passed"' | |
} | |
} | |
stage('Push image') { | |
docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-credentials') { | |
app.push("${env.BUILD_NUMBER}") | |
app.push("latest") | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline { | |
agent { dockerfile true } | |
stages { | |
stage('Build') { | |
steps { | |
sh "docker build -t oze4/vue-router-poc ." | |
} | |
} | |
stage('Publish') { | |
when { | |
branch 'master' | |
} | |
steps { | |
withDockerRegistry([credentialsId: 'docker-hub-creds', url: 'https://registry.hub.docker.com']) { | |
sh "docker push oze4/vue-router-poc:${env.BUILD_NUMBER}" | |
sh "docker push oze4/vue-router-poc:latest" | |
} | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node { | |
def app | |
stage('Clone repository') { | |
checkout scm | |
} | |
stage('Build image') { | |
app = docker.build("oze4/vue-router-poc") | |
} | |
stage('Test image') { | |
app.inside { | |
sh 'echo "Tests passed"' | |
} | |
} | |
stage('Push image') { | |
docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-credentials') { | |
app.push("${env.BUILD_NUMBER}") | |
app.push("latest") | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node { | |
def app | |
def dockerhub_container = "oze4/node-api" | |
def local_container_name = "node-api" | |
stage('Clone Repository') { | |
checkout scm | |
} | |
stage('Build Image') { | |
app = docker.build("${dockerhub_container}") | |
} | |
stage('Test Image') { | |
app.inside { | |
sh 'echo "Volkswagen Tests passed"' | |
} | |
} | |
stage('Push Image To Docker Hub') { | |
docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-credentials') { | |
app.push("${env.BUILD_NUMBER}") | |
app.push("latest") | |
} | |
} | |
stage ('SSH To Docker Host and Deploy') { | |
sshagent(credentials : ['ost-sf-dckr-00']) { | |
sh ''' | |
ssh -v root@ost-sf-dckr-00 <<EOF | |
echo "--------------------------------" | |
echo "---- pulling latest image ------" | |
echo "--------------------------------" | |
docker pull '''+dockerhub_container+''':latest | |
echo "--------------------------------" | |
echo "--------------------------------" | |
echo "--- stopping existing image ----" | |
echo "--------------------------------" | |
docker stop '''+local_container_name+''' | |
echo "--------------------------------" | |
echo "--------------------------------" | |
echo "--- removing existing image ----" | |
echo "--------------------------------" | |
docker rm '''+local_container_name+''' | |
echo "--------------------------------" | |
echo "--------------------------------" | |
echo "------ starting new image ------" | |
echo "--------------------------------" | |
cd "/srv/nginx-proxy/" | |
docker-compose up -d '''+local_container_name+''' | |
echo "--------------------------------" | |
echo "--------------------------------" | |
echo "----------- DONE ---------------" | |
echo "--------------------------------" | |
echo "--------------------------------" | |
EOF | |
''' | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Change time zone | |
System.setProperty('org.apache.commons.jelly.tags.fmt.timeZone', 'America/Chicago') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment