我是 Kubernetes 新手,想知道是否有一个kubectl
命令可以找出我当前正在使用的命名空间?
运行该kubectl get ns
命令会打印出所有名称空间,但不会显示我目前所在的名称空间。
我是詹金斯的新手,我正在尝试解决一些问题。
有没有办法通过 Groovy 添加分支源行为。这是使用 Jenkins 分析 SonarQube 中的 GitHub 项目。
我正在创建一个多分支管道,但似乎无法弄清楚如何添加以下行为。
在 UI 中创建作业时,这些行为默认出现,但通过 Groovy 创建作业时不会出现。
我已将其定义为我的管道。知道如何添加这些其他参数吗?
multibranchPipelineJob('Foo') {
displayName('Foo')
description('Jenkins')
branchSources {
branchSource {
source {
github {
id('15')
repoOwner('12345')
repository('foo')
repositoryUrl('https://example.com')
configuredByUrl(true)
credentialsId('foo')
traits {
gitBranchDiscovery()
}
}
}
}
}
orphanedItemStrategy {
discardOldItems {
numToKeep(10)
}
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试添加以下参数,但它会引发错误。
import jenkins.plugins.git.traits.*
def traits = []
traits.add(new TagDiscoveryTrait())
traits.add(new LocalBranchTrait())
gitSCMSource.setTraits(traits)
Run Code Online (Sandbox Code Playgroud)
有没有办法通过 Groovy 创建作业,但使用在 UI 中创建作业时出现的默认设置?
有没有办法找出可能使用哪个版本的 Terraform 来编写多个 terraform 配置文件?
我的 terraform 版本是v1.0.11
. 我刚刚克隆了一个存储库来使用,并且 terraform 配置语法看起来很旧。
我尝试搜索是否required_version
已在任何地方设置,但没有任何结果。
有某种方法可以解决这个问题吗?
有没有办法在使用 sed 找到匹配项后替换以下两行?
我有一个文件
#ABC
oneSize=bar
twoSize=bar
threeSize=foo
Run Code Online (Sandbox Code Playgroud)
但我想在模式#ABC
匹配后替换两行直接的行,以便它变成
#ABC
oneSize=foo
twoSize=foo
threeSize=foo
Run Code Online (Sandbox Code Playgroud)
我能做到
gsed '/^#ABC/{n;s/Size=bar/Size=foo/}' file
但它只是改变了线路twoSize
而不是oneSize
有没有办法让它同时改变 oneSize 和 TwoSize
我有许多 Terraform 数据源和一个这样创建的本地块
data "aws_subnets" "subs" {
for_each = toset(["a", "b", "c"])
filter {
name = "vpc-id"
values = [data.aws_vpc.vpc.id]
}
filter {
name = "availability-zone"
values = ["${data.aws_region.region.name}${each.key}"]
}
}
data "aws_vpc" "vpc" {
default = false
}
data "aws_region" "region" {}
locals {
ids = [for az in data.aws_subnets.subs : az.ids[1]]
}
Run Code Online (Sandbox Code Playgroud)
和一个输出块
output "main" {
value = local.ids
}
Run Code Online (Sandbox Code Playgroud)
但是当我运行 terraform apply 时出现错误
The given key does not identify an element in this collection value: the given …
amazon-web-services terraform terraform-provider-aws terraform0.12+
我是 python 的新手,我正在尝试创建一个以环境变量命名的 json 文件。
的变量称为parent
与值galaxy
这就是我的文件的样子。
import json
import sys
import os
Report = os.environ.get('MainReport')
if Report == "Main":
newFile = os.environ.get('parent')
else:
newFile = os.environ.get('child')
#####Additional Logic Here############
json_output = json.dumps(output,indent=4)
with open(newFile, "w") as outfile:
outfile.write(json_output)
print("Output file is generated in the current directory!")
file.close()
Run Code Online (Sandbox Code Playgroud)
当我运行脚本时,它会galaxy
按预期在我的当前目录中创建文件。
但我需要命名文件 galaxy.json
我试过了
if Report == "Main":
newFile = os.environ.get('parent').json
Run Code Online (Sandbox Code Playgroud)
但它抛出这个错误
AttributeError: 'str' object has no attribute 'json'
有没有办法附加.json
到输出os.environ.get
terraform ×2
bash ×1
jenkins ×1
kubectl ×1
kubernetes ×1
linux ×1
python ×1
python-3.x ×1
sed ×1
shell ×1