如何解决如何在Docker容器开始运行之前执行步骤
我正在使用docker编写一个声明性jenkins文件。我需要做的是克隆一些存储库,对这些存储库做一些工作,然后运行一个docker容器来构建代码。我已经看到的是,运行docker容器之前的步骤可以在一个代理上运行,而docker容器可以在另一个代理上运行。我认为正确的做法是在运行docker容器之前隐藏代码,但我不知道如何在docker容器运行之前将其隐藏在正确的代理上(请参阅下面的“ docker test”阶段)。我的文件如下:
pipeline {
agent { label 'my_docker_jenkins_agent' }
options {
timestamps()
}
stages {
stage('git') {
steps {
<clone repos here>
}
}
stage('do some post clone processing to the files') {
steps {
<do some post processing on the cloned files here>
}
}
post {
success {
/* tar up the source code for use in the docker container */
stash includes: 'foo/',name: foo-${env.BUILD_ID}
}
}
stage('docker test') {
/* how do I unstash the code onto the same agent the docker container will
* run on prior to the docker container starting here?
*/
agent {
docker {
label 'my_docker_jenkins_agent'
image 'docker_registry/test/f32-bld:0.1'
registryUrl 'https://my_internal_registry.foo.com'
registryCredentialsId '<credentials id not shown>'
}
}
steps {
<issue the make command on the unstashed code here>
}
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。