1
resposta

Não estou conseguindo buildar

Boa tarde pessoa!

Não estou conseguindo buildar, segui exatamente os passos da vídeo aula. Segue abaixo o log.

Started by user Aluno alura Running in Durability level: MAX_SURVIVABILITY [Pipeline] Start of Pipeline [Pipeline] node Running on Jenkins in /var/lib/jenkins/workspace/todo-list-desenvolvimento [Pipeline] { [Pipeline] withEnv [Pipeline] { [Pipeline] stage [Pipeline] { (Carregando o ENV de desenvolvimento) [Pipeline] configFileProvider provisioning config files... not able to provide the file [ManagedFile: id=, targetLocation=null, variable=env], can't be resolved by any provider - maybe it got deleted by an administrator? [Pipeline] // configFileProvider [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Derrubando o container antigo) Stage "Derrubando o container antigo" skipped due to earlier failure(s) [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Subindo o container novo) Stage "Subindo o container novo" skipped due to earlier failure(s) [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Notificando o usuario) (hide) Stage "Notificando o usuario" skipped due to earlier failure(s) [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: not able to provide the file [ManagedFile: id=, targetLocation=null, variable=env], can't be resolved by any provider - maybe it got deleted by an administrator? Finished: FAILURE

1 resposta

Olá Rodrigo, tudo bem? Bem, o erro parece ser sobre a questão do arquivo "env", ele não consegue encontrar o arquivo "env", no seguinte codígo que está presente na descrição da aula:

pipeline {
        environment {
            dockerImage = "${image}"
        }
        agent any

        stages {
            stage('Carregando o ENV de desenvolvimento') {
                steps {
                    configFileProvider([configFile(fileId: '<id do seu arquivo de desenvolvimento>', variable: 'env')]) {
                        sh 'cat $env > .env'
                    }
                }
            }
            stage('Derrubando o container antigo') {
                steps {
                    script {
                        try {
                            sh 'docker rm -f django-todolist-dev1'
                        } catch (Exception e) {
                            sh "echo $e"
                        }
                    }
                }
            }        
            stage('Subindo o container novo') {
                steps {
                    script {
                        try {
                            sh 'docker run -d -p 81:8000 -v /var/run/mysqld/mysqld.sock:/var/run/mysqld/mysqld.sock -v /var/lib/jenkins/workspace/jenkins-todo-list-desenvolvimento/.env:/usr/src/app/to_do/.env --name=django-todolist-dev ' + dockerImage + ':latest'
                        } catch (Exception e) {
                            slackSend (color: 'error', message: "[ FALHA ] Não foi possivel subir o container - ${BUILD_URL} em ${currentBuild.duration}s", tokenCredentialId: 'slack-token')
                            sh "echo $e"
                            currentBuild.result = 'ABORTED'
                            error('Erro')
                        }
                    }
                }
            }
            stage('Notificando o usuario') {
                steps {
                    slackSend (color: 'good', message: '[ Sucesso ] O novo build esta disponivel em: http://192.168.33.10:81/ ', tokenCredentialId: 'slack-token')
                }
            }
        }
    }

Você deve troca essa parte <id do seu arquivo de desenvolvimento> pelo ID do seu arquivo .env-dev, verifica se isso resolve o seu problema!

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software