我正在使用Jenkins 2来编译Java项目,我想从pom.xml中读取该版本,我遵循这个例子:
https://github.com/jenkinsci/pipeline-plugin/blob/master/TUTORIAL.md
这个例子表明:
似乎访问文件系统存在一些安全问题,但我无法弄清楚它给出了什么(或为什么)这个问题:
我只是做了一个与示例有点不同的事情:
def version() {
String path = pwd();
def matcher = readFile("${path}/pom.xml") =~ '<version>(.+)</version>'
return matcher ? matcher[0][1] : null
}
Run Code Online (Sandbox Code Playgroud)
我在运行'version'方法时遇到的错误:
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use method groovy.lang.GroovyObject invokeMethod java.lang.String java.lang.Object (org.codehaus.groovy.runtime.GStringImpl call org.codehaus.groovy.runtime.GStringImpl)
at org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelist.rejectMethod(StaticWhitelist.java:165)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:117)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:103)
at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:15)
at WorkflowScript.run(WorkflowScript:71)
at ___cps.transform___(Native Method)
at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:55)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:106)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:79)
at sun.reflect.GeneratedMethodAccessor408.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:100)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:79)
at sun.reflect.GeneratedMethodAccessor408.invoke(Unknown Source) …
Run Code Online (Sandbox Code Playgroud) 我在Jenkins by Clouldbees中使用了Pipeline插件(之前的名称是Workflow插件),我试图在Groovy脚本中获取用户名但我无法实现它.
stage 'checkout svn'
node('master') {
// Get the user name logged in Jenkins
}
Run Code Online (Sandbox Code Playgroud) 我已经有一个 Eureka 服务器正在运行,并且在那里注册了一个微服务(account-server -> Service B)。问题是当尝试使用Service A中的 Feign 时。假设我在服务 A 上了一堂课。
@FeignClient("account-server")
public interface AccountFooProxy {
@RequestMapping(
value = {"/deviceToken/{deviceToken}"},
method = {RequestMethod.GET}
)
String getAccountByDeviceToken(@PathVariable("deviceToken") String var1);
}
Run Code Online (Sandbox Code Playgroud)
我已经知道“帐户服务器”已在尤里卡注册。服务A中的SpringBoot是:
@SpringBootApplication
@EnableFeignClients
@EnableDiscoveryClient
public class AuthServerApplication {
public static void main(String[] args) {
SpringApplication.run(AuthServerApplication.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
然后是同一个服务 A 中的 RestController,我在其中创建了这个虚拟类以 @Autowired 一个 FeignClient 来调用服务 B
@RestController
@RequestMapping("/foo")
class FooTest {
@Autowired
private AccountFooProxy accountProxy;
private static final String DEVICE_TOKEN = "xxx";
@RequestMapping(path = "/foo", method = …
Run Code Online (Sandbox Code Playgroud) 我有一个包含多个步骤的管道,例如:
stage 'dev - compile'
node('master') {
//do something
}
stage 'test- compile'
node('master') {
//do something
}
stage 'prod- compile'
node('master') {
//do something
}
Run Code Online (Sandbox Code Playgroud)
我想在工作中出现问题时发送电子邮件,无论错误发生在何处,我都能发送电子邮件,例如:
try {
/**
all the code above
**/
} catch(Exception e) {
mail the error
}
Run Code Online (Sandbox Code Playgroud) 我认为这对你来说可能是一个非常简单的问题.
但我搜索了很多,我不知道我是非常傻瓜还是我使用了错误的班级(NSMutableArray
).
我想为特定键添加一个对象,以便我以后可以检索它.
例如:
NSMutableArray *grisOcurrencias = [[NSMutableArray alloc] init];
[grisOcurrencias setValue:ocurrencia forKey:[NSString stringWithFormat: @"%f", pixelVal]];
Run Code Online (Sandbox Code Playgroud)
但是如果我执行类似的操作,则数组不会插入到数组中:
[grisOcurrencias addObject: ocurrencia]
Run Code Online (Sandbox Code Playgroud)
插入对象.
难道我做错了什么?
其他的事情......我想通过它的密钥恢复对象,我应该使用什么方法?
非常感谢
我有一个使用Nexus的远程存储库.
这些存储库要求登录,我更愿意使用登录来公开这些存储库.
这是我的settings.xml
<settings>
<servers>
<server>
<id>dev-repo</id>
<username>user</username>
<password>password</password>
</server>
</servers>
</settings>
Run Code Online (Sandbox Code Playgroud)
开发人员正在使用pom.xml:
<distributionManagement>
<repository>
<id>dev-repo</id>
<url>http://ip:port/nexus/content/repositories/dev-repo/</url>
</repository>
</distributionManagement>
Run Code Online (Sandbox Code Playgroud)
使用该配置一切正常,但我更喜欢他们必须在mvn命令中传递登录,或者命令询问提示登录而不是硬编码在settings.xml中登录
有任何想法吗?
先感谢您.
我正在拿书做模拟测试,我发现了这个问题:
import java.util.concurrent.atomic.AtomicInteger;
class AtomicVariableTest {
private static AtomicInteger counter = new AtomicInteger(0);
static class Decrementer extends Thread {
public void run() {
counter.decrementAndGet(); // #1
}
}
static class Incrementer extends Thread {
public void run() {
counter.incrementAndGet(); // #2
}
}
public static void main(String[] args) {
for (int i = 0; i < 5; i++) {
new Incrementer().start();
new Decrementer().start();
}
System.out.println(counter);
}
}
Run Code Online (Sandbox Code Playgroud)
答案:
该程序将始终打印0.
但我认为无法保证线程在打印计数器值时完成.
我的意思是,大部分时间它会返回0,但如果你对理论严格,则无法保证这一点.
我对么?
我试图在settings.xml中使用加密密码.我在我的pom.xml中有一个连接到数据库的插件,使用sql-maven-plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.4</version>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.5.0</version>
</dependency>
</dependencies>
<configuration>
<driver>oracle.jdbc.driver.OracleDriver</driver>
<url>jdbc:oracle:thin:@ip.com:1521:SID</url>
<username>someUser</username>
<password>{JucQpWS78Q0HW+3ZS/FCCGHQpwbJ8ySl2Io/ILJqf88=}</password>
</configuration>
<executions>
<execution>
<id>update-configuration</id>
<phase>package</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<autocommit>false</autocommit>
<srcFiles>
<srcFile>src/main/sql/update_sim_configuration.sql</srcFile>
</srcFiles>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
哪个工作正常如果我将密码作为纯文本放在我的pom.xml中,我想从我的settings.xml读取此密码,密码以这种方式加密:
mvn -ep the_password
Run Code Online (Sandbox Code Playgroud)
我在我的settings.xml中
...
<server>
<id>rms13-db-dev</id>
<username>user</username>
<password>{JucQpWS78Q0HW+3ZS/FCCGHQpwbJ8ySl2Io/ILJqf88=}</password>
</server>
...
Run Code Online (Sandbox Code Playgroud)
我想'读'解码'rms13-db-dev'中的'密码',我该如何实现?或者如果您有替代版本来实现这一目标.
java ×3
jenkins ×3
maven ×3
arrays ×1
cloudbees ×1
concurrency ×1
dictionary ×1
feign ×1
groovy ×1
mojo ×1
nexus ×1
objective-c ×1
spring-boot ×1