Skip to content

Instantly share code, notes, and snippets.

View matheusvt2's full-sized avatar

Matheus Villela Torres matheusvt2

View GitHub Profile
@matheusvt2
matheusvt2 / stage_example
Last active February 28, 2020 23:26
Stage example
stages {
//------------------------------------------------ESTAGIO 01---------------------------------------------------------------------------
stage('Load Parameters'){
steps{
script {
dir ('Arquivos'){ //Fetch dos arquivos repositório do projeto para a pasta Arquivos, dentro do workspace do Jenkins
checkout([$class: 'GitSCM', branches: [[name: "master"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CleanBeforeCheckout']], gitTool: '${gitInit}', submoduleCfg: [], userRemoteConfigs: [[credentialsId: credentialId, url: "https://github.com/matheusvt2/jenkins-python-full-pipeline.git"]]])
}
tools = load "${WORKSPACE}/Arquivos/Jenkins/jenkins-python-full-pipeline.groovy" //Carrega dados do arquivo de config deste projeto na pasta Jenkins (tem que estar no GIT)
@matheusvt2
matheusvt2 / parallel_example
Created February 28, 2020 22:56
parallel example
stage('Quality Tests'){
parallel{
stage ('Lynt Test'){
steps{
script{
pyLynt("Arquivos",100)
}
}
}
@matheusvt2
matheusvt2 / post_example
Created February 28, 2020 23:05
post example
post {//Apos o build (com ou sem erros) sempre executa esses comandos
always {
script{
if(env.ProjectEnv == "VENV"){
println "Apagando arquivos temporários..."
sh "conda remove --yes -p ${WORKSPACE}/VirtualEnv/${BUILD_TAG} --all"
sh ''' cd ${WORKSPACE}
ls -la
rm -fr *
ls -la
@matheusvt2
matheusvt2 / script_example
Created February 28, 2020 23:17
script example
stage('Exec Program'){
steps {
script {
if(env.ExecutarPrograma == "SIM" && env.ProjectLang == "PYTHON" && env.ProjectEnv == "DOCKER"){
withCredentials([usernamePassword(credentialsId: dockerCredentials, usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
funcSshCommand(sshprofile,"""
docker container rm jenkins-python-full-pipeline_container
docker login -u ${USERNAME} -p ${PASSWORD}
docker pull ${dockerhub}/jenkins-python-full-pipeline:${BUILD_NUMBER}
docker run --name jenkins-python-full-pipeline_container ${dockerhub}/jenkins-python-full-pipeline:${BUILD_NUMBER}
import time
import speedtest
from datetime import datetime
import sqlite3
import logging
from threading import Timer
logging.basicConfig(format='%(levelname)s - %(asctime)s - %(message)s', level=logging.INFO)
@matheusvt2
matheusvt2 / newsite.sh
Created June 5, 2022 18:55
Create a new hugo site
cd ~/Documents
hugo new site myhugosite
cd myhugosite