我在jenkins上为一个项目定义了几个环境变量,其中我想将其中一些变量合并到构建成功前后发送的电子邮件通知中。
但是groovy.text.Template似乎不接受这些环境变量。
我还使用了“将环境变量注入到构建过程的功能帮助:将环境变量注入到构建过程”,并按如下方式定义了我的变量
BUILD_NAME=${BUILD_NAME}
Run Code Online (Sandbox Code Playgroud)
BUILD_NAME我执行构建时在哪里被接受为参数。
请有人可以帮我这个忙。
Groovy断言包含:
assert testList.contains(4)
| |
| false
[1, 2, 6, 3, 4]
Run Code Online (Sandbox Code Playgroud)
我疯了吗?
这是测试代码:
List testList = tester.getFactors(12)
assert testList.size() == 5
assert testList.contains(1)
assert testList.contains(2)
assert testList.contains(3)
assert testList.contains(4)
assert testList.contains(6)
Run Code Online (Sandbox Code Playgroud)
如果我删除除contains(4)和contains(6)之外的所有内容,则它们中的任何一个或两个都会失败.
这是getFactors方法:
List getFactors(int number)
{
def retList = new ArrayList();
(1..Math.sqrt(number)).each() { i ->
if(number % i == 0)
{
//add both the number and the division result
retList.add(i)
if(i>1)
retList.add(number / i)
}
}
retList;
}
Run Code Online (Sandbox Code Playgroud)
任何想法都非常感激.
打开 Groovy 文件时出现以下异常:
org.osgi.framework.BundleException: Exception in org.codehaus.groovy.eclipse.refactoring.Activator.start() of bundle org.codehaus.groovy.eclipse.refactoring.
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
...
Caused by: java.lang.NoClassDefFoundError: org/codehaus/jdt/groovy/integration/LanguageSupport
Run Code Online (Sandbox Code Playgroud)
或者
java.lang.NoClassDefFoundError: org/codehaus/groovy/eclipse/refactoring/formatter/GroovyIndentationService
at org.codehaus.groovy.eclipse.editor.GroovyAutoIndentStrategy.<init>(GroovyAutoIndentStrategy.java:50)
at org.codehaus.groovy.eclipse.editor.GroovyConfiguration.getAutoEditStrategies(GroovyConfiguration.java:181)
...
Caused by: org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter$TerminatingClassNotFoundException: An error occurred while automatically activating bundle org.codehaus.groovy.eclipse.refactoring (47).
...
Caused by: org.osgi.framework.BundleException: Exception in org.codehaus.groovy.eclipse.refactoring.Activator.start() of bundle org.codehaus.groovy.eclipse.refactoring.
...
Caused by: java.lang.NoClassDefFoundError: org/codehaus/jdt/groovy/integration/LanguageSupport
Caused by: java.lang.ClassNotFoundException: org.codehaus.jdt.groovy.integration.LanguageSupport
Run Code Online (Sandbox Code Playgroud) 我是 Grails 的新手,但我有一个旧项目。我必须修改该项目并将其上传回服务器。要修改该项目,我需要 Grails 1.3.7。在谷歌上搜索,但找不到下载的地方。请帮我找到它或建议我以任何其他方式运行我的旧网站。
我在config.groovy中写下面给出的代码
grails.plugins.springsecurity.providerNames = [
'rememberMeAuthenticationProvider'
]
grails.plugin.springsecurity.rememberMe.cookieName='grails_remember_me'
grails.plugin.springsecurity.rememberMe.alwaysRemember=false
grails.plugin.springsecurity.rememberMe.tokenValiditySeconds=31*24*60*60
grails.plugin.springsecurity.rememberMe.parameter='_spring_security_remember_me'
grails.plugin.springsecurity.rememberMe.key='monitoringApp'
grails.plugin.springsecurity.rememberMe.useSecureCookie=false
grails.plugin.springsecurity.rememberMe.persistent=false
grails.plugin.databasemigration.updateOnStart = true
Run Code Online (Sandbox Code Playgroud)
我在我的gsp页面上写下面给出的代码
<div class="col-xs-7">
<div class="checkbox">
<label>
<input type='checkbox' name='_spring_security_remember_me' id='remember_me'
<g:if test='${hasCookie}'>checked='checked'</g:if>/>
<g:message code="springSecurity.login.remember.me.label"/>
</label>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我的控制器所有动作都使用弹簧安全完全认证@Secured(['IS_AUTHENTICATED_FULLY'])但我无法使用弹簧安全的 好处记住我的功能.请帮助我.
我正在使用grails版本2.3.0和spring security:"spring-security-core:2.0-RC2"
我有以下2个groovy片段,应该做同样但但他们没有.
try {
throw new RuntimeException()
} catch (IllegalStateException) {
println("hello!")
}
Run Code Online (Sandbox Code Playgroud)
这个输出 'hello!'
try {
throw new RuntimeException()
} catch (IllegalStateException e) {
println("hello!")
}
Run Code Online (Sandbox Code Playgroud)
而这个输出是一个意外的例外:
Caught: java.lang.RuntimeException
java.lang.RuntimeException
at 2.run(2.groovy:2)
Run Code Online (Sandbox Code Playgroud)
请注意唯一的区别是,在一个片段e中,catch块中没有参数.
我正在运行以下版本的groovy和JVM.
groovy --version
Groovy Version: 2.0.5 JVM: 1.6.0_37 Vendor: Sun Microsystems Inc. OS: Linux
这是预期的行为还是编译器中的错误?谢谢
我试图在Jenkins(https://jenkins-ci.org)脚本控制台中运行find命令,该控制台允许从Web界面运行groovy脚本.
我的代码是:
ProcessBuilder pb = new ProcessBuilder();
pb.directory(new File("/var/lib/jenkins/jobs/myJob");
pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
command = 'find . -name build.xml -exec echo \"{}\" \\;'
println(command)
pb.command(command.split(" "));
pb.start().waitFor();
Run Code Online (Sandbox Code Playgroud)
Web UI将显示println的结果:
find . -name build.xml -exec echo "{}" \;
Run Code Online (Sandbox Code Playgroud)
jenkins日志(/var/log/jenkins/jenkins.log)记录以下错误:
find: missing argument to `-exec'
Run Code Online (Sandbox Code Playgroud)
但是,如果我find . -name build.xml -exec echo "{}" \;通过shell 运行web UI()中输出的相同命令,则不会出现此类错误.
另外,如果我替换\;witih +,命令有效!
因此,使用processBuilder并且\\;作为命令行参数传递的东西是可疑的
我正在使用Roman Mazur 的勺子gradle插件。我能够一次运行所有测试,但我无法指定要启动的“组”测试。目前我的勺子设置看起来像这样:
spoon {
debug = true
baseOutputDir = file("$buildDir/spoon-log")
if (project.hasProperty('spoonClassName')) {
className = project.spoonClassName
if (project.hasProperty('spoonMethodName')) {
methodName = project.spoonMethodName
}
}
adbTimeout = 60 * 60;
}
Run Code Online (Sandbox Code Playgroud)
我的测试位于包中:
我的目标是创建单独的 gradle 任务,这些任务依赖于勺子分别从每个包启动测试。Roman 给了我们参数instrumentationArgs,它应该能够编辑勺子内的一些属性。
正如我在勺子的主 git 上看到的那样,你可以指定包,勺子运行器应该在其中查找你的测试,示例如下:
--e package=com.mypackage.unit_tests
Run Code Online (Sandbox Code Playgroud)
所以我的想法是把这个属性放到 instrumentationArgs 中。因此,我创建了这样的勺子任务:
task spoonAuthFlowTests(type: GradleBuild, dependsOn: ['spoon']) {
spoon {
instrumentationArgs = ["package=com.myapp.instrumentation.flowtests.AuthFlowTests"]
noAnimations = true;
}
}
task spoonFlowTests(type: GradleBuild, dependsOn: ['spoon']) {
spoon {
instrumentationArgs = ["package=com.myapp.instrumentation.flowtests"]
noAnimations = true; …Run Code Online (Sandbox Code Playgroud) 我有带有 spring security 插件(2.0-RC5)的 grails 2.5.1 应用程序。我想阻止每个用户的当前会话数。我读过一些博客,但它不起作用。(http://www.block-consult.com/blog/2012/01/20/restricting-concurrent-user-sessions-in-grails-2-using-spring -security-core-plugin/ ) 我的 resources.groovy
beans = {
sessionRegistry(SessionRegistryImpl)
concurrencyFilter(ConcurrentSessionFilter,sessionRegistry,'/main/index'){
logoutHandlers = [ref("rememberMeServices"), ref("securityContextLogoutHandler")]
}
concurrentSessionControlStrategy(ConcurrentSessionControlAuthenticationStrategy, sessionRegistry) {
exceptionIfMaximumExceeded = true
maximumSessions = 1
}
}
Run Code Online (Sandbox Code Playgroud)
在我的 boostrap.groovy 中
def init = { servletContext ->
SpringSecurityUtils.clientRegisterFilter('concurrencyFilter', SecurityFilterPosition.CONCURRENT_SESSION_FILTER)
}
Run Code Online (Sandbox Code Playgroud)
和我的 config.groovy 我添加了这个:
grails.plugin.springsecurity.useHttpSessionEventPublisher = true
Run Code Online (Sandbox Code Playgroud)
谢谢..
1-为什么如下:
android.buildVariants.each { variant ->
... my code
}
Run Code Online (Sandbox Code Playgroud)
给我以下错误?
无法在com.android.build.gradle.AppExtension_Decorated@1bf6bde6上找到属性"buildVariants".
2-为什么以下静默不执行"...我的代码"?
android.applicationVariants.each { variant ->
... my code
}
Run Code Online (Sandbox Code Playgroud)