2019-07-02 13:00:36 +02:00
|
|
|
#!groovy
|
2020-09-24 13:47:20 +02:00
|
|
|
import org.junit.After
|
2019-07-02 13:00:36 +02:00
|
|
|
import org.junit.Before
|
|
|
|
import org.junit.Rule
|
|
|
|
import org.junit.Test
|
|
|
|
import org.junit.rules.ExpectedException
|
|
|
|
import org.junit.rules.RuleChain
|
|
|
|
import util.BasePiperTest
|
|
|
|
import util.JenkinsCredentialsRule
|
|
|
|
import util.JenkinsDockerExecuteRule
|
|
|
|
import util.JenkinsReadYamlRule
|
|
|
|
import util.JenkinsShellCallRule
|
|
|
|
import util.JenkinsStepRule
|
|
|
|
import util.Rules
|
|
|
|
|
2020-09-24 13:47:20 +02:00
|
|
|
import com.sap.piper.Utils
|
|
|
|
|
2019-07-02 13:00:36 +02:00
|
|
|
import static org.hamcrest.CoreMatchers.containsString
|
|
|
|
import static org.hamcrest.CoreMatchers.hasItem
|
|
|
|
import static org.hamcrest.CoreMatchers.is
|
|
|
|
import static org.hamcrest.CoreMatchers.not
|
|
|
|
import static org.junit.Assert.assertThat
|
|
|
|
|
|
|
|
class ContainerPushToRegistryTest extends BasePiperTest {
|
|
|
|
private ExpectedException exception = ExpectedException.none()
|
|
|
|
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
|
|
|
|
private JenkinsDockerExecuteRule dockerRule = new JenkinsDockerExecuteRule(this)
|
|
|
|
private JenkinsShellCallRule shellCallRule = new JenkinsShellCallRule(this)
|
|
|
|
|
|
|
|
@Rule
|
|
|
|
public RuleChain rules = Rules
|
|
|
|
.getCommonRules(this)
|
|
|
|
.around(new JenkinsReadYamlRule(this))
|
|
|
|
.around(exception)
|
|
|
|
.around(shellCallRule)
|
|
|
|
.around(dockerRule)
|
|
|
|
.around(new JenkinsCredentialsRule(this)
|
|
|
|
.withCredentials('testCredentialsId', 'registryUser', '********')
|
|
|
|
)
|
|
|
|
.around(stepRule)
|
|
|
|
|
2021-05-06 11:17:02 +02:00
|
|
|
def dockerMock = new DockerMock('test')
|
|
|
|
|
2019-07-02 13:00:36 +02:00
|
|
|
class DockerMock {
|
2021-05-06 11:17:02 +02:00
|
|
|
|
|
|
|
LinkedList<DockerRegistry> registries
|
|
|
|
String image
|
|
|
|
|
2019-07-02 13:00:36 +02:00
|
|
|
DockerMock(name){
|
2021-05-06 11:17:02 +02:00
|
|
|
this.image = name
|
|
|
|
this.registries = [] as LinkedList
|
2019-07-02 13:00:36 +02:00
|
|
|
}
|
|
|
|
def withRegistry(paramRegistry, paramCredentials, paramClosure){
|
2021-05-06 11:17:02 +02:00
|
|
|
this.registries.add(new DockerRegistry(paramRegistry, paramCredentials, paramCredentials? false : true))
|
2019-07-02 13:00:36 +02:00
|
|
|
return paramClosure()
|
|
|
|
}
|
|
|
|
def withRegistry(paramRegistry, paramClosure){
|
2021-05-06 11:17:02 +02:00
|
|
|
return withRegistry(paramRegistry, null, paramClosure)
|
2019-07-02 13:00:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
def image(name) {
|
2021-05-06 11:17:02 +02:00
|
|
|
this.image = name
|
2019-07-02 13:00:36 +02:00
|
|
|
return new ContainerImageMock()
|
|
|
|
}
|
2021-05-06 11:17:02 +02:00
|
|
|
|
|
|
|
protected DockerRegistry getSourceRegistry() {
|
|
|
|
if (registries.size() == 1) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return registries.first
|
|
|
|
}
|
|
|
|
protected DockerRegistry getTargetRegistry() {
|
|
|
|
if (registries.size() == 1) {
|
|
|
|
return registries.first
|
|
|
|
}
|
|
|
|
return registries.last
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class DockerRegistry {
|
|
|
|
final boolean isAnonymous
|
|
|
|
final String credentials
|
|
|
|
final String url
|
|
|
|
|
|
|
|
DockerRegistry(url, credentials, isAnonymous) {
|
|
|
|
this.url = url
|
|
|
|
this.credentials = credentials
|
|
|
|
this.isAnonymous = isAnonymous
|
|
|
|
}
|
2019-07-02 13:00:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
def dockerMockPushes = []
|
|
|
|
def dockerMockPull = false
|
|
|
|
class ContainerImageMock {
|
|
|
|
ContainerImageMock(){}
|
|
|
|
def push(tag){
|
|
|
|
dockerMockPushes.add(tag)
|
|
|
|
}
|
|
|
|
def push(){
|
|
|
|
push('default')
|
|
|
|
}
|
|
|
|
|
|
|
|
def pull(){
|
|
|
|
dockerMockPull = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Before
|
|
|
|
void init() {
|
2021-05-06 11:17:02 +02:00
|
|
|
binding.setVariable('docker', dockerMock)
|
2020-09-24 13:47:20 +02:00
|
|
|
Utils.metaClass.echo = { def m -> }
|
|
|
|
}
|
|
|
|
|
|
|
|
@After
|
|
|
|
public void tearDown() {
|
|
|
|
Utils.metaClass = null
|
2019-07-02 13:00:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void testNoImageProvided() {
|
|
|
|
exception.expectMessage(containsString('Please provide a dockerImage'))
|
|
|
|
stepRule.step.containerPushToRegistry(
|
|
|
|
script: nullScript,
|
|
|
|
dockerRegistryUrl: 'https://testRegistry',
|
|
|
|
dockerCredentialsId: 'testCredentialsId',
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void testDefault() {
|
|
|
|
stepRule.step.containerPushToRegistry(
|
|
|
|
script: nullScript,
|
|
|
|
dockerRegistryUrl: 'https://testRegistry',
|
|
|
|
dockerCredentialsId: 'testCredentialsId',
|
|
|
|
dockerImage: 'testImage:tag',
|
|
|
|
)
|
|
|
|
|
2021-05-06 11:17:02 +02:00
|
|
|
assertThat(dockerMock.targetRegistry.url, is('https://testRegistry'))
|
|
|
|
assertThat(dockerMock.targetRegistry.credentials, is('testCredentialsId'))
|
|
|
|
assertThat(dockerMock.image, is('testImage:tag'))
|
2019-07-02 13:00:36 +02:00
|
|
|
assertThat(dockerMockPushes, hasItem('default'))
|
|
|
|
assertThat(dockerMockPushes, not(hasItem('latest')))
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void testBuildImagePushLatest() {
|
|
|
|
def dockerBuildImage = new ContainerImageMock()
|
|
|
|
stepRule.step.containerPushToRegistry(
|
|
|
|
script: nullScript,
|
|
|
|
dockerRegistryUrl: 'https://testRegistry',
|
|
|
|
dockerCredentialsId: 'testCredentialsId',
|
|
|
|
dockerBuildImage: dockerBuildImage,
|
|
|
|
tagLatest: true
|
|
|
|
)
|
|
|
|
|
2021-05-06 11:17:02 +02:00
|
|
|
assertThat(dockerMock.targetRegistry.url, is('https://testRegistry'))
|
|
|
|
assertThat(dockerMock.targetRegistry.credentials, is('testCredentialsId'))
|
|
|
|
assertThat(dockerMock.sourceRegistry, is (null))
|
|
|
|
assertThat(dockerMock.image, is('test'))
|
2019-07-02 13:00:36 +02:00
|
|
|
assertThat(dockerMockPushes, hasItem('default'))
|
|
|
|
assertThat(dockerMockPushes, hasItem('latest'))
|
|
|
|
}
|
|
|
|
|
2021-06-28 08:02:06 +02:00
|
|
|
@Test
|
|
|
|
void testBuildImagePushArtifactVersion() throws Exception {
|
|
|
|
nullScript.commonPipelineEnvironment.setArtifactVersion('1.0.0')
|
|
|
|
def dockerBuildImage = new ContainerImageMock()
|
|
|
|
stepRule.step.containerPushToRegistry(
|
|
|
|
script: nullScript,
|
|
|
|
dockerRegistryUrl: 'https://testRegistry',
|
|
|
|
dockerCredentialsId: 'testCredentialsId',
|
|
|
|
dockerBuildImage: dockerBuildImage,
|
|
|
|
tagArtifactVersion: true
|
|
|
|
)
|
2019-07-02 13:00:36 +02:00
|
|
|
|
2021-06-28 08:02:06 +02:00
|
|
|
assertThat(dockerMock.targetRegistry.url, is('https://testRegistry'))
|
|
|
|
assertThat(dockerMock.targetRegistry.credentials, is('testCredentialsId'))
|
|
|
|
assertThat(dockerMock.sourceRegistry, is (null))
|
|
|
|
assertThat(dockerMock.image, is('test'))
|
|
|
|
assertThat(dockerMockPushes, hasItem('default'))
|
|
|
|
assertThat(dockerMockPushes, not(hasItem('latest')))
|
|
|
|
assertThat(dockerMockPushes, hasItem('1.0.0'))
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void testBuildImagePushLatestAndArtifactVersion() throws Exception {
|
|
|
|
nullScript.commonPipelineEnvironment.setArtifactVersion('1.0.0')
|
|
|
|
def dockerBuildImage = new ContainerImageMock()
|
|
|
|
stepRule.step.containerPushToRegistry(
|
|
|
|
script: nullScript,
|
|
|
|
dockerRegistryUrl: 'https://testRegistry',
|
|
|
|
dockerCredentialsId: 'testCredentialsId',
|
|
|
|
dockerBuildImage: dockerBuildImage,
|
|
|
|
tagArtifactVersion: true,
|
|
|
|
tagLatest: true
|
|
|
|
)
|
|
|
|
|
|
|
|
assertThat(dockerMock.targetRegistry.url, is('https://testRegistry'))
|
|
|
|
assertThat(dockerMock.targetRegistry.credentials, is('testCredentialsId'))
|
|
|
|
assertThat(dockerMock.sourceRegistry, is (null))
|
|
|
|
assertThat(dockerMock.image, is('test'))
|
|
|
|
assertThat(dockerMockPushes, hasItem('default'))
|
|
|
|
assertThat(dockerMockPushes, hasItem('latest'))
|
|
|
|
assertThat(dockerMockPushes, hasItem('1.0.0'))
|
|
|
|
}
|
2019-07-02 13:00:36 +02:00
|
|
|
|
|
|
|
@Test
|
|
|
|
void testFromEnv() {
|
|
|
|
nullScript.commonPipelineEnvironment.setValue('containerImage', 'path/testImage:tag')
|
|
|
|
nullScript.commonPipelineEnvironment.setValue('containerRegistryUrl', 'https://testRegistry:55555')
|
|
|
|
|
|
|
|
stepRule.step.containerPushToRegistry(
|
|
|
|
script: nullScript,
|
|
|
|
dockerRegistryUrl: 'https://testRegistry',
|
|
|
|
dockerCredentialsId: 'testCredentialsId',
|
|
|
|
)
|
|
|
|
|
2021-05-06 11:17:02 +02:00
|
|
|
assertThat(dockerMock.sourceRegistry.url, is('https://testRegistry:55555'))
|
|
|
|
assertThat(dockerMock.sourceRegistry.isAnonymous, is(true))
|
|
|
|
assertThat(dockerMock.targetRegistry.url, is('https://testRegistry'))
|
|
|
|
assertThat(dockerMock.targetRegistry.credentials, is('testCredentialsId'))
|
|
|
|
assertThat(dockerMock.targetRegistry.isAnonymous, is(false))
|
|
|
|
assertThat(dockerMock.image, is('path/testImage:tag'))
|
2019-07-02 13:00:36 +02:00
|
|
|
assertThat(shellCallRule.shell, hasItem('docker tag testRegistry:55555/path/testImage:tag path/testImage:tag'))
|
|
|
|
assertThat(dockerMockPull, is(true))
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void testWithSourceImageAndRegistry() {
|
|
|
|
stepRule.step.containerPushToRegistry(
|
|
|
|
script: nullScript,
|
|
|
|
dockerCredentialsId: 'testCredentialsId',
|
|
|
|
dockerRegistryUrl: 'https://testRegistry',
|
|
|
|
sourceImage: 'testSourceName:testSourceTag',
|
|
|
|
sourceRegistryUrl: 'http://testSourceRegistry'
|
|
|
|
)
|
|
|
|
|
2021-05-06 11:17:02 +02:00
|
|
|
assertThat(dockerMock.sourceRegistry.url, is('http://testSourceRegistry'))
|
|
|
|
assertThat(dockerMock.image, is('testSourceName:testSourceTag'))
|
|
|
|
assertThat(dockerMock.sourceRegistry.isAnonymous, is(true))
|
2019-07-02 13:00:36 +02:00
|
|
|
assertThat(shellCallRule.shell, hasItem('docker tag testSourceRegistry/testSourceName:testSourceTag testSourceName:testSourceTag'))
|
|
|
|
assertThat(dockerMockPull, is(true))
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void testWithSourceAndTarget() {
|
|
|
|
stepRule.step.containerPushToRegistry(
|
|
|
|
script: nullScript,
|
|
|
|
dockerCredentialsId: 'testCredentialsId',
|
|
|
|
dockerImage: 'testImage:tag',
|
|
|
|
dockerRegistryUrl: 'https://testRegistry',
|
|
|
|
sourceImage: 'testSourceName:testSourceTag',
|
|
|
|
sourceRegistryUrl: 'http://testSourceRegistry'
|
|
|
|
)
|
|
|
|
|
2021-05-06 11:17:02 +02:00
|
|
|
assertThat(dockerMock.sourceRegistry.url, is('http://testSourceRegistry'))
|
|
|
|
assertThat(dockerMock.sourceRegistry.isAnonymous, is(true))
|
|
|
|
assertThat(dockerMock.image, is('testSourceName:testSourceTag'))
|
|
|
|
assertThat(shellCallRule.shell, hasItem('docker tag testSourceRegistry/testSourceName:testSourceTag testImage:tag'))
|
|
|
|
assertThat(dockerMockPull, is(true))
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void testWithAuthenticatedSourceAndTarget() {
|
|
|
|
stepRule.step.containerPushToRegistry(
|
|
|
|
script: nullScript,
|
|
|
|
dockerCredentialsId: 'testCredentialsId',
|
|
|
|
dockerImage: 'testImage:tag',
|
|
|
|
dockerRegistryUrl: 'https://testRegistry',
|
|
|
|
sourceCredentialsId: 'testSourceCredentialsId',
|
|
|
|
sourceImage: 'testSourceName:testSourceTag',
|
|
|
|
sourceRegistryUrl: 'http://testSourceRegistry'
|
|
|
|
)
|
|
|
|
|
|
|
|
assertThat(dockerMock.sourceRegistry.url, is('http://testSourceRegistry'))
|
|
|
|
assertThat(dockerMock.sourceRegistry.credentials, is('testSourceCredentialsId'))
|
|
|
|
assertThat(dockerMock.targetRegistry.url, is('https://testRegistry'))
|
|
|
|
assertThat(dockerMock.targetRegistry.credentials, is('testCredentialsId'))
|
|
|
|
assertThat(dockerMock.image, is('testSourceName:testSourceTag'))
|
2019-07-02 13:00:36 +02:00
|
|
|
assertThat(shellCallRule.shell, hasItem('docker tag testSourceRegistry/testSourceName:testSourceTag testImage:tag'))
|
|
|
|
assertThat(dockerMockPull, is(true))
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void testKubernetesMove() {
|
|
|
|
binding.setVariable('docker', null)
|
|
|
|
shellCallRule.setReturnValue('docker ps -q > /dev/null', 1)
|
|
|
|
|
|
|
|
stepRule.step.containerPushToRegistry(
|
|
|
|
script: nullScript,
|
|
|
|
dockerCredentialsId: 'testCredentialsId',
|
|
|
|
dockerImage: 'testImage:tag',
|
|
|
|
dockerRegistryUrl: 'https://my.registry:55555',
|
|
|
|
skopeoImage: 'skopeo:latest',
|
|
|
|
sourceImage: 'sourceImage:sourceTag',
|
|
|
|
sourceRegistryUrl: 'https://my.source.registry:44444'
|
|
|
|
)
|
|
|
|
|
|
|
|
assertThat(shellCallRule.shell, hasItem('skopeo copy --src-tls-verify=false --dest-tls-verify=false --dest-creds=\'registryUser\':\'********\' docker://my.source.registry:44444/sourceImage:sourceTag docker://my.registry:55555/testImage:tag'))
|
|
|
|
assertThat(dockerRule.dockerParams.dockerImage, is('skopeo:latest'))
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void testKubernetesMoveTagLatest() {
|
|
|
|
binding.setVariable('docker', null)
|
|
|
|
shellCallRule.setReturnValue('docker ps -q > /dev/null', 1)
|
|
|
|
|
|
|
|
stepRule.step.containerPushToRegistry(
|
|
|
|
script: nullScript,
|
|
|
|
dockerCredentialsId: 'testCredentialsId',
|
|
|
|
dockerImage: 'testImage:tag',
|
|
|
|
dockerRegistryUrl: 'https://my.registry:55555',
|
|
|
|
sourceImage: 'sourceImage:sourceTag',
|
|
|
|
sourceRegistryUrl: 'https://my.source.registry:44444',
|
|
|
|
tagLatest: true
|
|
|
|
)
|
|
|
|
|
|
|
|
assertThat(shellCallRule.shell, hasItem('skopeo copy --src-tls-verify=false --dest-tls-verify=false --dest-creds=\'registryUser\':\'********\' docker://my.source.registry:44444/sourceImage:sourceTag docker://my.registry:55555/testImage:tag'))
|
|
|
|
assertThat(shellCallRule.shell, hasItem('skopeo copy --src-tls-verify=false --dest-tls-verify=false --dest-creds=\'registryUser\':\'********\' docker://my.source.registry:44444/sourceImage:sourceTag docker://my.registry:55555/testImage:latest'))
|
|
|
|
}
|
|
|
|
|
2021-06-28 08:02:06 +02:00
|
|
|
@Test
|
|
|
|
void testKubernetesMoveTagArtifactVersion() {
|
|
|
|
nullScript.commonPipelineEnvironment.setArtifactVersion('1.0.0')
|
|
|
|
binding.setVariable('docker', null)
|
|
|
|
shellCallRule.setReturnValue('docker ps -q > /dev/null', 1)
|
|
|
|
|
|
|
|
stepRule.step.containerPushToRegistry(
|
|
|
|
script: nullScript,
|
|
|
|
dockerCredentialsId: 'testCredentialsId',
|
|
|
|
dockerImage: 'testImage:tag',
|
|
|
|
dockerRegistryUrl: 'https://my.registry:55555',
|
|
|
|
sourceImage: 'sourceImage:sourceTag',
|
|
|
|
sourceRegistryUrl: 'https://my.source.registry:44444',
|
|
|
|
tagArtifactVersion: true
|
|
|
|
)
|
|
|
|
|
|
|
|
assertThat(shellCallRule.shell, hasItem('skopeo copy --src-tls-verify=false --dest-tls-verify=false --dest-creds=\'registryUser\':\'********\' docker://my.source.registry:44444/sourceImage:sourceTag docker://my.registry:55555/testImage:tag'))
|
|
|
|
assertThat(shellCallRule.shell, hasItem('skopeo copy --src-tls-verify=false --dest-tls-verify=false --dest-creds=\'registryUser\':\'********\' docker://my.source.registry:44444/sourceImage:sourceTag docker://my.registry:55555/testImage:1.0.0'))
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void testKubernetesMoveTagLatestAndArtifactVersion() {
|
|
|
|
nullScript.commonPipelineEnvironment.setArtifactVersion('1.0.0')
|
|
|
|
binding.setVariable('docker', null)
|
|
|
|
shellCallRule.setReturnValue('docker ps -q > /dev/null', 1)
|
|
|
|
|
|
|
|
stepRule.step.containerPushToRegistry(
|
|
|
|
script: nullScript,
|
|
|
|
dockerCredentialsId: 'testCredentialsId',
|
|
|
|
dockerImage: 'testImage:tag',
|
|
|
|
dockerRegistryUrl: 'https://my.registry:55555',
|
|
|
|
sourceImage: 'sourceImage:sourceTag',
|
|
|
|
sourceRegistryUrl: 'https://my.source.registry:44444',
|
|
|
|
tagLatest: true,
|
|
|
|
tagArtifactVersion: true
|
|
|
|
)
|
|
|
|
|
|
|
|
assertThat(shellCallRule.shell, hasItem('skopeo copy --src-tls-verify=false --dest-tls-verify=false --dest-creds=\'registryUser\':\'********\' docker://my.source.registry:44444/sourceImage:sourceTag docker://my.registry:55555/testImage:tag'))
|
|
|
|
assertThat(shellCallRule.shell, hasItem('skopeo copy --src-tls-verify=false --dest-tls-verify=false --dest-creds=\'registryUser\':\'********\' docker://my.source.registry:44444/sourceImage:sourceTag docker://my.registry:55555/testImage:latest'))
|
|
|
|
assertThat(shellCallRule.shell, hasItem('skopeo copy --src-tls-verify=false --dest-tls-verify=false --dest-creds=\'registryUser\':\'********\' docker://my.source.registry:44444/sourceImage:sourceTag docker://my.registry:55555/testImage:1.0.0'))
|
|
|
|
}
|
|
|
|
|
2019-07-02 13:00:36 +02:00
|
|
|
@Test
|
|
|
|
void testKubernetesSourceOnly() {
|
|
|
|
binding.setVariable('docker', null)
|
|
|
|
shellCallRule.setReturnValue('docker ps -q > /dev/null', 1)
|
|
|
|
|
|
|
|
stepRule.step.containerPushToRegistry(
|
|
|
|
script: nullScript,
|
|
|
|
dockerCredentialsId: 'testCredentialsId',
|
|
|
|
dockerRegistryUrl: 'https://my.registry:55555',
|
|
|
|
sourceImage: 'sourceImage:sourceTag',
|
|
|
|
sourceRegistryUrl: 'https://my.source.registry:44444'
|
|
|
|
)
|
|
|
|
|
|
|
|
assertThat(shellCallRule.shell, hasItem('skopeo copy --src-tls-verify=false --dest-tls-verify=false --dest-creds=\'registryUser\':\'********\' docker://my.source.registry:44444/sourceImage:sourceTag docker://my.registry:55555/sourceImage:sourceTag'))
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void testKubernetesSourceRegistryFromEnv() {
|
|
|
|
binding.setVariable('docker', null)
|
|
|
|
shellCallRule.setReturnValue('docker ps -q > /dev/null', 1)
|
|
|
|
|
|
|
|
nullScript.commonPipelineEnvironment.setValue('containerImage', 'sourceImage:sourceTag')
|
|
|
|
nullScript.commonPipelineEnvironment.setValue('containerRegistryUrl', 'https://my.source.registry:44444')
|
|
|
|
|
|
|
|
stepRule.step.containerPushToRegistry(
|
|
|
|
script: nullScript,
|
|
|
|
dockerCredentialsId: 'testCredentialsId',
|
|
|
|
dockerRegistryUrl: 'https://my.registry:55555',
|
|
|
|
sourceImage: 'sourceImage:sourceTag',
|
|
|
|
)
|
|
|
|
|
|
|
|
assertThat(shellCallRule.shell, hasItem('skopeo copy --src-tls-verify=false --dest-tls-verify=false --dest-creds=\'registryUser\':\'********\' docker://my.source.registry:44444/sourceImage:sourceTag docker://my.registry:55555/sourceImage:sourceTag'))
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void testKubernetesPushTar() {
|
|
|
|
binding.setVariable('docker', null)
|
|
|
|
shellCallRule.setReturnValue('docker ps -q > /dev/null', 1)
|
|
|
|
|
|
|
|
exception.expectMessage('Only moving images')
|
|
|
|
stepRule.step.containerPushToRegistry(
|
|
|
|
script: nullScript,
|
|
|
|
dockerCredentialsId: 'testCredentialsId',
|
|
|
|
dockerArchive: 'myImage.tar',
|
|
|
|
dockerImage: 'testImage:tag',
|
|
|
|
dockerRegistryUrl: 'https://my.registry:55555',
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|