我正在尝试使用 groovy 创建一个 Jenkins 管道脚本。但是,该import语句给了我一个编译错误 - 未知类型:导入。不知道为什么。

我有这个错误:
错误:服务 'db' 依赖于未定义的服务 'apache'。
为什么说 apache 是未定义的?我检查缩进。应该是对的。
version: '3.5'
services:
apache:
build: ./Docker
image: apache:latest
ports:
- "80:80"
restart: always
networks:
default:
name: frontend-network
services:
db:
image: mariadb:latest
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
depends_on:
- "apache"
adminer:
image: adminer
restart: always
ports:
- "8080:8080"
depends_on:
- "db"
networks:
default:
name: frontend-network
Run Code Online (Sandbox Code Playgroud) 我有一个大约 20 个阶段的发布管道。根据我们正在执行的发布类型,我们决定运行这些阶段的一些子集。
运行每个阶段都很昂贵,除非绝对必要,否则我们不想运行它。
有没有一种直接的方法可以在开始发布时禁用某些阶段,以便我们只执行发布中绝对必要的阶段?
如果不是,那么实现这种行为的最佳编程方式是什么?
我有以下管道,但我不知道为什么它在第一行代码中失败:
pipeline {
agent any
environment {
def mypods = []
}
stages {
stage('Getting pods') {
steps {
script {
withKubeConfig(caCertificate: '.....', credentialsId: '.....', serverUrl: '.....') {
env.mypods = sh "kubectl get pod | grep Running | awk '{print \$1}'"
}
}
}
}
stage('Print pods') {
steps {
script {
mypods.each {
println "Item: $it"
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我需要使用一个列表,因为 kubectl get pods 命令返回一个 pod 列表,所以我必须在阶段中保存和使用它们。如何在声明性管道上创建列表?提前致谢。
这是错误:
Running in Durability level: MAX_SURVIVABILITY
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: …Run Code Online (Sandbox Code Playgroud) 不幸的是我失去了我的本地
~/.kube/config
我的命名空间配置在哪里。
如果我可以访问主节点,有没有办法获得这个配置?
提前致谢
我在 azure 上有两个环境。它们之间的区别之一只是来自变量组的环境变量。是否可以为一个管道动态设置组名,而不是设置两个可以映射自己的组变量的管道?这是我的构建管道的一个例子
trigger:
- master
- develop
jobs:
- job: DefineVariableGroups
steps:
- script: |
if [ $(Build.SourceBranch) = 'refs/heads/master' ]; then
echo "##vso[task.setvariable variable=group_name_variable;isOutput=true]beta_group"
elif [ $(Build.SourceBranch) = 'refs/heads/develop' ]; then
echo "##vso[task.setvariable variable=group_name_variable;isOutput=true]alpha_group"
fi
name: 'DefineVariableGroupsTask'
- script: echo $(DefineVariableGroupsTask.group_name_variable)
name: echovar # that works.
- job: Test
dependsOn: DefineVariableGroups
pool:
vmImage: 'Ubuntu-16.04'
variables:
- group: $[ dependencies.DefineVariableGroups.outputs['DefineVariableGroupsTask.group_name_variable'] ]
# that doesn't work. Error here
steps:
- script: echo $(mode)
displayName: 'test'
Run Code Online (Sandbox Code Playgroud) 我有一个 Python+MySQL webservice 在生产中的 Digital Ocean 液滴上运行。当我在本地机器上更新项目中的代码时,我希望更改也发生在 Droplet(生产中)中。因此,我执行以下操作进行部署:
$ ssh root@12.34.56.78
# cd project
# git pull
# docker-compose down
# docker-compose build
# docker-compose up -d
Run Code Online (Sandbox Code Playgroud)
在此之后,我的数据库是空的。它里面没有我的桌子。如何更新正在运行的代码但不丢失数据?
.
??? db
??? docker-compose.yml
??? web
??? Dockerfile
??? project
? ??? app.py
? ??? __init__.py
? ??? blueprint1
? ??? blueprint2
? ??? models.py
? ??? static
? ??? templates
? ??? _version.py
??? Makefile
??? migrations
??? README.md
??? setup.cfg
??? setup.py
??? start.sh
??? tests
??? …Run Code Online (Sandbox Code Playgroud) 我有一个用于分配 AWS Lambda 的 Terraform 配置。我希望它在检测到更改时自动更新代码。为此,我正在使用该source_code_hash属性,如下所示。作为构建过程的一部分,我将所有代码压缩,然后用于openssl获取 zip 文件的 SHA256 哈希值,将其粘贴到文本文件中,然后将两者上传到 S3 存储桶。
这是我的 Terraform 配置:
data "aws_s3_bucket_object" "mylambdacode_sha256" {
bucket = "myapp-builds"
key = "build.zip.sha256"
}
resource "aws_lambda_function" "my_lambda" {
function_name = "${var.lambda_function_name}"
role = "${aws_iam_role.iam_for_lambda.arn}"
handler = "index.handler"
runtime = "nodejs10.x"
s3_bucket = "myapp-builds"
s3_key = "build.zip"
source_code_hash = "${data.aws_s3_bucket_object.mylambdacode_sha256.body}"
timeout = 900
}
Run Code Online (Sandbox Code Playgroud)
我跑了terraform apply,它告诉我source_code_hash已经改变了:
~ source_code_hash = <<~EOT
- c9Nl4RRfuh/Z5fJvEOT69GDTJqY9n/QTB5cBGtOniYc=
+ 73d365e1145fba1fd9e5f26f10e4faf460d326a63d9ff4130797011ad3a78987
Run Code Online (Sandbox Code Playgroud)
该73d365e1145fba1fd9e5f26f10e4faf460d326a63d9ff4130797011ad3a78987部分确实是 S3 上文件中的内容。所以,这一切看起来都是正确的。但是当我terraform apply …
hash amazon-web-services terraform devops terraform-provider-aws
我正在将 ubuntu 18 与 minikube 和虚拟框一起使用,并尝试挂载主机的目录以获取我的 pod 需要的输入数据。
我发现minikube挂载主机目录有问题,但默认情况下根据你的操作系统和vm驱动程序,有默认挂载的目录
我在我的豆荚上找不到那些。他们根本不在那里。
我尝试创建一个持久卷,它有效,我可以在仪表板上看到它,但是我无法将它挂载到 pod,我使用这个 yaml 创建了卷
{
"kind": "PersistentVolume",
"apiVersion": "v1",
"metadata": {
"name": "pv0003",
"selfLink": "/api/v1/persistentvolumes/pv0001",
"uid": "28038976-9ee4-414d-8478-b312a24a6b94",
"resourceVersion": "2030",
"creationTimestamp": "2019-08-08T10:48:23Z",
"annotations": {
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"PersistentVolume\",\"metadata\":{\"annotations\":{},\"name\":\"pv0001\"},\"spec\":{\"accessModes\":[\"ReadWriteOnce\"],\"capacity\":{\"storage\":\"5Gi\"},\"hostPath\":{\"path\":\"/data/pv0001/\"}}}\n"
},
"finalizers": [
"kubernetes.io/pv-protection"
]
},
"spec": {
"capacity": {
"storage": "6Gi"
},
"hostPath": {
"path": "/user/data",
"type": ""
},
"accessModes": [
"ReadWriteOnce"
],
"persistentVolumeReclaimPolicy": "Retain",
"volumeMode": "Filesystem"
},
"status": {
"phase": "Available"
}
}
Run Code Online (Sandbox Code Playgroud)
这个 yaml 来创建工作。
apiVersion: batch/v1
kind: Job
metadata: …Run Code Online (Sandbox Code Playgroud) 我为我的项目创建了一个 build-pipeline.yml 文件,以便我的应用程序可以在 azure devops 中自动构建。
我首先创建了一个带有 devops UI 的管道,效果很好。
所以我从我用 UI 创建的作业中复制了所有 yml。
然后我用这个 yml 文件创建了一个新的管道并运行这个管道,但是一开始我遇到了一些问题:
##[warning]There was a failure in sending the provision message: Unexpected response code from remote provider InternalServerError
,##[warning]There was a failure in sending the provision message: Unexpected response code from remote provider InternalServerError
,##[warning]There was a failure in sending the provision message: Unexpected response code from remote provider InternalServerError
,##[error]Provisioning request delayed or failed to send 3 time(s). This is over the limit of …Run Code Online (Sandbox Code Playgroud)