dun*_*mus 2 maven jenkins docker windows-10 jenkins-pipeline
我正在按照本教程在docker中使用jenkins构建一个hello-world Maven Java应用程序:https ://jenkins.io/doc/tutorials/building-a-java-app-with-maven/#fork-and-clone- github上的sample-repository
这是我的应用程序(只是本教程的分支):simple-java-maven-app
与我在管道选项(存储库URL)中使用远程存储库(Github)而不是本地存储库(或主机存储库)相比,存在一个小的差异。我推送了Jenkinsfile进行回购,然后使用Pipeline构建了hello-world应用。
// Jenkinsfile for Pipeline
pipeline {
agent {
docker {
image 'maven:3-alpine'
args '-v /root/.m2:/root/.m2'
}
}
stages {
stage('Build') {
steps {
sh 'mvn -B -DskipTests clean package'
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我在下面收到此错误,找不到任何解决方案。我正在使用Windows 10。
docker pull maven:3-alpine
Warning: failed to get default registry endpoint from daemon (Cannot connect to the Docker daemon. Is the docker daemon running on this host?). Using system default: https://index.docker.io/v1/
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
Run Code Online (Sandbox Code Playgroud)
感谢大家。
您不建议在CI中使用Docker(DinD)中的Docker。您应该将主机的Docker守护进程套接字作为卷挂载到Jenkins容器中,如下所示:
docker container run -v /var/run/docker.sock:/var/run/docker.sock ...
因此,您可以在主机上而不是在Jenkins容器中使用图像和容器。单击此处了解更多信息。
| 归档时间: |
|
| 查看次数: |
1698 次 |
| 最近记录: |