小编Ren*_*ler的帖子

将Jenkins插件安装到Docker Jenkins

我有以下Dockerfile jenkins作为基本图像:

FROM jenkins
USER root
ENV JENKINS_MIRROR http://mirrors.jenkins-ci.org
RUN for plugin in git-client git ws-cleanup ; do wget -O $JENKINS_HOME/plugins/${plugin}.hpi $JENKINS_MIRROR/plugins/${plugin}/latest/${plugin}.hpi ; done
EXPOSE 8080
Run Code Online (Sandbox Code Playgroud)

我正在尝试安装一些额外的插件,但它给我一个错误说 no such file or directory 在此输入图像描述

然后我启动并连接到此构建步骤的容器,以"调试"错误: 在此输入图像描述

但是,我找不到原因,因为每个目录似乎都存在.此外,如果我然后在bash中手动运行for循环,所有插件都正确安装...

我进一步注意到,如果我将它们安装在根目录中,插件的安装工作如下:

RUN for plugin in git-client git ws-cleanup ; do wget -O ${plugin}.hpi $JENKINS_MIRROR/plugins/${plugin}/latest/${plugin}.hpi ; done
Run Code Online (Sandbox Code Playgroud)

但是,这是错误的地方,因为它们必须放在$ JENKINS_HOME/plugins目录中

为什么我无法安装插件$JENKINS_HOME/plugins

linux jenkins docker dockerfile

21
推荐指数
2
解决办法
2万
查看次数

Spring Boot:如何在单元测试中使用liquibase设置测试数据

我正在尝试使用liquibase为一些测试设置数据库模式和一些测试数据.每个测试都有一个单独的更改日志,用于设置架构和测试的一些特定数据.

为了使我的测试工作,我需要在每次测试之前删除模式并用新的测试数据填充它.但是,似乎这不起作用,因为一些测试失败,因为旧的测试数据仍然可用.我认为我的配置不正确.如何在每次测试之前强制liquibase删除架构?

我的测试如下:

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = MyTestConfig.class)
@TestPropertySource(properties = "liquibase.change-log=classpath:changelog/schema-with-testdata.xml")
public class MyRepositoryTest {
Run Code Online (Sandbox Code Playgroud)

测试的配置如下:

@SpringApplicationConfiguration
@Configuration
@EnableAutoConfiguration
@ComponentScan("com.mypackage")
@EntityScan(basePackages = { "com.mypackage.domain" })
@EnableJpaRepositories(basePackages = { "com.mypackage.domain", "com.mypackage.infra.persistence" })
public class MyTestConfig {
Run Code Online (Sandbox Code Playgroud)

而src/main/test/resources下的application.properties是

liquibase.drop-first=true
spring.jpa.hibernate.ddl-auto=none
Run Code Online (Sandbox Code Playgroud)

java spring liquibase spring-boot

17
推荐指数
2
解决办法
1万
查看次数

找不到SecurityMockMvcConfigurers

我正在尝试编写一个Spring安全测试,如http://docs.spring.io/spring-security/site/docs/4.0.x/reference/htmlsingle/#test-mockmvc-setup所述.我需要导入SecurityMockMvcConfigurers为静态导入,但我的IDE找不到该类.

我的pom.xml如下所示:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.0.M2</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)

Spring Boot 1.4.0.M2导入Spring Security 4.0.4.RELEASE.我在这个版本中找不到这个类.我需要哪种额外的依赖?或者我没有考虑过什么呢?

java spring spring-security spring-boot

16
推荐指数
1
解决办法
6134
查看次数

使用PostgreSQL运行DataJpaTest

我用Spring Boot编写了一个jpa测试,如下所述:https: //spring.io/blog/2016/04/15/testing-improvements-in-spring-boot-1-4

@RunWith(SpringRunner.class)
@DataJpaTest
public class UserRepositoryTests {

@Autowired
private TestEntityManager entityManager;

...
}
Run Code Online (Sandbox Code Playgroud)

这默认配置内存中的数据库.如何配置此测试,它使用我的本地PostgreSQL数据库?

spring spring-boot

11
推荐指数
2
解决办法
4296
查看次数

有条件地在 maven 中设置属性

我想根据它是否是快照构建在 Maven 中有条件地设置一个属性。伪代码如下

if ${project.version} ends with "-SNAPSHOT"     
then
   deployFileUrl = ${project.distributionManagement.snapshotRepository.url}
else
   deployFileUrl = ${project.distributionManagement.repository.url}
Run Code Online (Sandbox Code Playgroud)

我如何在 Maven 中实现这个?

我用 build-helper-maven-plugin 试了一下,如下

 <plugin>
    <groupId>org.codehaus.mojo</groupId>
     <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
            <execution>
                <id>regex-properties</id>
                <goals>
                    <goal>regex-properties</goal>
                </goals>
                    <configuration>
                        <regexPropertySettings>
                            <regexPropertySetting>
                                <name>deployFileUrl</name>
                                <value>${project.version}</value>
                                <regex>.*-SNAPSHOT</regex>
                                <replacement>${project.distributionManagement.snapshotRepository.url}</replacement>
                                <failIfNoMatch>false</failIfNoMatch>
                            </regexPropertySetting>
                        </regexPropertySettings>
                    </configuration>
                </execution>
            </executions>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

这种方法的问题是我无法实现 else 条件。

java maven

9
推荐指数
2
解决办法
3053
查看次数

Spring Boot在调试模式下阻止H2控制台

我正在尝试在调试模式下的WebIntegrationTest期间访问H2控制台.但是,当我调试测试时,我注意到Spring Boot正在阻止H2控制台.一旦达到断点,H2控制台也会被阻止.我正在使用Spring Boot 1.3.1.RELEASE.

以下测试中的每个断点都会导致阻止H2控制台.在断点1中,将显示登录页面.然后我按下登录按钮但没有任何反应,直到我继续测试到下一个断点.在断点2中,我已登录并可以执行查询.但只有当我要到下一个断点时,才会出现查询结果.

@Test
public void whenGetById_thenCorrectId() throws InterruptedException {
    // do some stuff
    // breakpoint 1
    Thread.sleep(1000);
    // breakpoint 2
    Thread.sleep(1000);
    // breakpoint 3
}
Run Code Online (Sandbox Code Playgroud)

WebIntegrationTest配置如下:

@ActiveProfiles("local,unittest")
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = MyApplication.class)
@WebIntegrationTest({"spring.h2.console.enabled=true", "server.port=8080"})
public class MyResourceTest {
Run Code Online (Sandbox Code Playgroud)

如何将H2-in-memory数据库与调试模式分离?

java spring spring-boot

8
推荐指数
1
解决办法
1454
查看次数

延迟加载模块中Angular Material datepicker的语言切换

如何在整个应用程序中切换我的材料瞄准器的语言(即对于急切和延迟加载的组件中的datepickers)?

我创建了一个stackblitz示例来演示我的问题:

https://stackblitz.com/edit/angular-4cu4cb

一旦在热切或延迟加载的组件中更改了语言,我想更改两个日期选择器的语言.不幸的是,这还不行.

我怎样才能做到这一点?

angular-material angular

8
推荐指数
1
解决办法
705
查看次数

Spring Boot集成测试中的H2控制台

我正在使用Spring Boot 1.3.1.RELEASE。我通过spring.h2.console.enabled=trueapplication.properties文件中进行设置来启用了H2 Web控制台。如果启动Spring Boot应用程序,则可以通过访问H2 Web控制台http://localhost:8080/h2-console/

但是,当我在调试模式下(已设置断点)执行集成测试时,无法访问控制台。不幸的是,这不起作用(该站点不可用)。集成测试的配置如下:

@ActiveProfiles("local,unittest")
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = MyApplication.class)
@WebAppConfiguration
@IntegrationTest
public class MyResourceTest {
Run Code Online (Sandbox Code Playgroud)

我没有考虑什么?

java h2 spring-boot

6
推荐指数
1
解决办法
3087
查看次数

springSecurityFilterChain不能为null

我正在使用Spring Boot 1.4.0.M2,我编写了以下测试用例,以确保具有弹簧安全性的控制器正常运行.

@RunWith(SpringRunner.class)
@WebMvcTest(HelloController.class)
public class HelloControllerTest {

    @Autowired
    private WebApplicationContext wac;

    private MockMvc mockMvc;

    @Before
    public void setUp() {
        mockMvc = MockMvcBuilders
                .webAppContextSetup(wac)
                .alwaysDo(print())
                .apply(springSecurity())
                .build();
    }

    @Test
    public void getHelloShouldReturnWithCacheControlSet() throws Exception {
        this.mockMvc.perform(get("/hello")
                .accept(MediaType.TEXT_PLAIN))
                .andExpect(status().isOk())
                .andExpect(content().string("Hello World!"))
                .andExpect(header().stringValues("Cache-Control", "max-age=5"));
    }
}
Run Code Online (Sandbox Code Playgroud)

当我运行测试时,抛出以下异常:

java.lang.IllegalStateException: springSecurityFilterChain cannot be null. Ensure a Bean with the name springSecurityFilterChain implementing Filter is present or inject the Filter to be used.
Run Code Online (Sandbox Code Playgroud)

所有其他代码可以在这里找到:https://github.com/renewinkler84/http-cache-demo

为什么抛出这个异常?还有什么我需要配置?

spring spring-security spring-boot

5
推荐指数
1
解决办法
3629
查看次数

Angular Material 中日期选择器的 A11yLabel 是什么?

什么是dateA11yLabelmonthYearA11yLabel配置自定义格式的日期选择是什么时候?他们在做什么?我在 Angular Material 文档中没有找到这个信息。

export const MY_FORMATS = {
  parse: {
    dateInput: 'LL',
  },
  display: {
    dateInput: 'LL',
    monthYearLabel: 'MMM YYYY',
    dateA11yLabel: 'LL',
    monthYearA11yLabel: 'MMMM YYYY',
  },
};
Run Code Online (Sandbox Code Playgroud)

https://material.angular.io/components/datepicker/overview#customizing-the-parse-and-display-formats

angular-material angular

5
推荐指数
2
解决办法
684
查看次数