Last active
February 28, 2020 23:26
-
-
Save matheusvt2/55d0946bde55e78e6fe1e0067ba1c21a to your computer and use it in GitHub Desktop.
Stage example
This file contains 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
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) | |
println "Utilizando informacoes do arquivo jenkins-python-full-pipeline.groovy" | |
println " => Ling Selecionada: ${env.ProjectLang} => Ambiente: ${env.ProjectEnv} => Executar Código: ${env.ExecutarPrograma}" | |
}//Script - Load Parameters | |
}//Steps - Load Parameters | |
}//Fim do Load Parameters | |
//------------------------------------------------FIM ESTAGIO 01 - Load Parameters--------------------------------------------------- | |
//------------------------------------------------ESTAGIO 02--------------------------------------------------------------------------- | |
stage('Environment Build') { | |
steps { | |
script{ | |
if (env.ProjectLang == "PYTHON" && env.ProjectEnv == "DOCKER"){ | |
println "Construindo build nome jenkins-python-full-pipeline:${BUILD_NUMBER}" | |
withCredentials([usernamePassword(credentialsId: "${dockerCredentials}", usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { | |
sh "docker login -u ${USERNAME} -p ${PASSWORD}" | |
sh "docker build -t ${dockerhub}/jenkins-python-full-pipeline:${BUILD_NUMBER} . --no-cache --rm" | |
} | |
}else{ | |
println ("Configurações não suportadas") | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment