我一直在github上玩Spring Cloud项目:https://github.com/spring-cloud/spring-cloud-config
但是我遇到了一些问题,让它读取本地属性文件而不是从github中提取属性.即使我删除了对github的所有引用,spring似乎忽略了本地文件.此处发布了类似的问题:Spring-Cloud配置服务器忽略配置属性文件
但我还没有看到任何好的答案.我想知道是否有人能指出我的一个例子?我想在本地设置我的属性,而不是使用任何类型的git repo.我假设有人之前遇到过这种情况,如果有某个例子,我真的很想看到它,这样我才能朝着正确的方向前进.
我有一个管道作业,它使用两个独立的节点(一个用于构建,一个用于测试),我想在我的两个代码块之间共享一个变量Jenkinsfile.我认为这是可能的,但我对groovy和Jenkinsfile概念很新.以下是目前的相关代码:
node('build') {
stage('Checkout') {
checkout scm
}
stage('Build') {
bat(script: 'build')
def rev = readFile('result')
}
}
node('test') {
stage('Test') {
def SDK_VERSION = "5.0.0001.${rev}"
bat "test.cmd ${env.BUILD_URL} ${SDK_VERSION}"
archiveArtifacts artifacts: 'artifacts/**/*.xml'
junit 'artifacts/**/*.xml'
}
}
Run Code Online (Sandbox Code Playgroud)
我想在构建阶段分配"rev"变量,但是然后将它连接到Test阶段的SDK_VERSION变量.我的错误是:
groovy.lang.MissingPropertyException: No such property: rev for class: groovy.lang.Binding
Run Code Online (Sandbox Code Playgroud) 我正试图在我的Windows笔记本电脑上启动Cassandra,我看到以下错误:
WARNING! Powershell script execution unavailable
Please use 'powershell Set-ExecutionPolicy Unrestricted'
on this user-account to run cassandra with fully featured
functionality on this platform.
Starting with legacy startup options
Starting Cassandra Server
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
Run Code Online (Sandbox Code Playgroud)
所以我打开Powershell尝试将ExecutionPolicy设置为Unrestricted,我得到以下内容:

所以我按照错误中描述的注册表项进行操作,似乎密钥已经正确设置.我只是缺少一些明显的东西吗?以前版本的Cassandra在我的机器上完美运行,但自从我更新以来,这给了我各种各样的问题.
我已经了解了如何在 ansible 剧本中的任务中注册变量,然后在同一剧本中的其他地方使用这些变量,但是您可以在包含的剧本中注册变量,然后在原始剧本中访问这些变量吗?
这是我想要实现的目标:
这是我的主要剧本:
- include: sub-playbook.yml job_url="http://some-jenkins-job"
- hosts: localhost
roles:
- some_role
Run Code Online (Sandbox Code Playgroud)
sub-playbook.yml:
---
- hosts: localhost
tasks:
- name: Collect info from Jenkins Job
script: whatever.py --url "{{ job_url }}"
register: jenkins_artifacts
Run Code Online (Sandbox Code Playgroud)
如果可能的话,我希望能够在 main_playbook 中访问 jenkins_artifacts 结果。我知道您可以从同一剧本中的其他主机访问它,如下所示:"{{ hostvars['localhost']['jenkins_artifacts'].stdout_lines }}"
跨剧本共享的想法是否相同?
我有一个在端口8761(localhost:8761/eureka)上运行的Eureka服务器,我有一个Zuul应用程序,我想在eureka注册,但我一直得到同样的错误:
Can't get a response from http://localhost:8761/eurekaapps/ZUULSERVER
Can't contact any eureka nodes - possibly a security group issue?
java.lang.RuntimeException: Bad status: 404
at com.netflix.discovery.DiscoveryClient.makeRemoteCall(DiscoveryClient.java:1155)
at com.netflix.discovery.DiscoveryClient.makeRemoteCall(DiscoveryClient.java:1060)
at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:606)
at com.netflix.discovery.DiscoveryClient$HeartbeatThread.run(DiscoveryClient.java:1596)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Run Code Online (Sandbox Code Playgroud)
这是zuul应用程序的application.yml:
info:
component: Zuul Server
eureka:
server:
enabled: true
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka
registerWithEureka: true
fetchRegistry: false
endpoints:
restart:
enabled: true
shutdown:
enabled: true
health:
sensitive: false
zuul:
route:
discovery:
url: http://localhost:9000/polaris/discovery
path: /polaris/discovery/**
sla:
url: http://localhost:9000/polaris/sla
path: /polaris/sla/**
stores: …Run Code Online (Sandbox Code Playgroud) 我有一个Jenkins管道,它负责大约5个阶段(构建和几个不同的测试).我正在从Jenkins 1.XX(没有管道)迁移到Jenkins 2,我想尽可能地复制我的流程.我在J2上设置的管道工作除了使用JenkinsFile外,完全相同.唯一的问题是,管道插件似乎不支持像Freestyle Jobs那样支持特定版本的推广.有没有人找到解决这个问题的方法?
在我的vars文件中,我有一个有时会设置的变量,而其他时候我想动态设置它。例如,我有一个要安装的RPM。我可以将位置手动存储在变量中,或者如果我没有特定的位置,我想从Jenkins获取最新信息。我的问题是,如何检查变量是否未定义或为空,如果是,仅使用Jenkins的默认值(已存储在var中)?
这是我的想法:
...code which gets host_vars[jenkins_rpm]
- hosts: "{{ host }}"
tasks:
- name: Set Facts
set_fact:
jenkins_rpm: "{{ hostvars['localhost']['jenkins_rpm'] }}"
- name: If my_rpm is empty or not defined, just use the jenkins_rpm
set_fact: my_rpm=jenkins_rpm
when: !my_rpm | my_rpm == ""
Run Code Online (Sandbox Code Playgroud) 我有一个 ansible 角色的任务,它调用一个带有一堆定义为 ansible 变量的 args 的脚本。任务如下所示:
- name: Generate config files
command: /etc/whatever/gen-config.sh -n {{domain}} -m {{ another_option }} -w {{ws_enabled | default('N') }} -r {{ last_one_optional}}
Run Code Online (Sandbox Code Playgroud)
问题是 -r 是一个可选参数,所以有时我没有一个 ansible 变量可以传递给它,如果我使用 default("") 代替,脚本会抱怨。仅当定义了 {{last_one_optional}} 时,是否有某种方法可以选择包含 -r?我已经看到了一些内联的 jinja if 语句,我不知道这是否适用于 ansible。
我正在使用P4V来查看我的perforce工作区.我在工作区内的多个目录中更改了多个文件.有没有办法创建包含所有这些更改的差异,以便我可以上传它以进行代码审查?如果这是一项微不足道的任务,我道歉.我是Perforce的新手,在与Accurev和Git共度几年后,我仍在学习术语和工具.
我有一个ISO 8601时间存储在一个变量中,我有一些小时存储在另一个变量中,如下所示:
my $current_time = shift; #looks like: 2015-07-01T15:38:08Z
my $hours = shift; # looks like: 12
Run Code Online (Sandbox Code Playgroud)
我的目标是将小时数添加到当前时间,但似乎没有任何内置的Perl函数来执行此操作.在Powershell中,您可以执行以下操作:
$currentTime = $currentTime .AddHours($hours)
Run Code Online (Sandbox Code Playgroud)
在Perl中有一个简单的方法吗?
我试图在Python中迭代字典.输出必须类似于某种格式,因此它可以用作其他内容的输入.输入看起来像这样:
"ok":"1",
"invalid", "0",
"unknown", "4",
...
Run Code Online (Sandbox Code Playgroud)
输出应如下所示:
operation,ok=1,invalid=0,unknown=4,...
Run Code Online (Sandbox Code Playgroud)
我真的很接近于使用for循环,但我读到这可以用.join()Python 很容易地完成.这是我现在的代码:
output_str = 'operation,'
for key, val in events.items():
output_str += '{0}={1},'.format(key, val)
print output_str
Run Code Online (Sandbox Code Playgroud)
我可以这样做.join吗?我读到加入将允许我跳过最后一次迭代的逗号.如果我这样做,我只是不确定如何将所有"操作"字符串添加到所有内容中.