Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for multitag #71

Merged
merged 1 commit into from
Oct 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions PR-Testing/README
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ the test-openshift-pipeline-plugin job, it will be the hpi file from your PR. B
you have to the plugin in the same way.

The `docker build` command used, if run from the same directory as this README, and if an "openshift-pipeline.jpi" file
exists in the "jpi" subdirectory, is: docker build -f ./Dockerfile-jenkins-test-new-plugin -t openshift/jenkins-plugin-snapshot-test:latest .
exists in the "jpi" subdirectory, is:
docker build -f ./Dockerfile-jenkins-test-new-plugin -t openshift/jenkins-plugin-snapshot-test:latest .

The next step is to then run the extended tests for the plugin located at https://github.com/openshift/origin.
From the top level directory of a clone of that repository, this command is run: test/extended/core.sh --ginkgo.focus='openshift pipeline plugin' -ginkgo.v"
From the top level directory of a clone of that repository, this command is run:
test/extended/core.sh --ginkgo.focus='openshift pipeline plugin' -ginkgo.v

That extended test typically verifies the functionality of the openshift-pipeline plugin installed into OpenShift's official jenkins image (see https://github.com/openshift/jenkins),
but it will look for the local existence of the openshift/jenkins-plugin-snapshot-test:latest image, and if present, deploy and test against that image instead.
That extended test typically verifies the functionality of the openshift-pipeline plugin installed into OpenShift's
official jenkins image (see https://github.com/openshift/jenkins), but it will look for the local existence of
the openshift/jenkins-plugin-snapshot-test:latest image, and if present, deploy and test against that image instead.
3 changes: 2 additions & 1 deletion PR-Testing/jpi/README
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Any openshift-pipelin.hpi to be tested is copied here as `openshift-pipeline.jpi` and then incorporated into a jenkins image built via a `docker build` using the Dockerfile in the parent directory to this directory.
Any openshift-pipeline.hpi to be tested is copied here as `openshift-pipeline.jpi` and then incorporated
into a jenkins image built via a `docker build` using the Dockerfile in the parent directory to this directory.
The resulting image can then be used for testing.
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,21 +181,31 @@ Optional parameters are:

The step name is "openshiftTag". Mandatory parameters are:

- "sourceStream" or "srcStream": The ImageStream of the existing image.
- "sourceStream" or "srcStream": The ImageStream of the existing image.

- "sourceTag" or "srcTag": The tag (ImageStreamTag type) or ID (ImageStreamImage type) of the existing image.
- "sourceTag" or "srcTag": The tag (ImageStreamTag type) or ID (ImageStreamImage type) of the existing image.

- "destinationStream" or "destStream": The ImageStream for the new tag.
- "destinationStream" or "destStream": The ImageStream for the new tag. A comma delimited list can be specified.

- "destinationTag" or "destTag": The name of the new tag.
- "destinationTag" or "destTag": The name of the new tag. A comma delimited list can be specified.

The following combinations are supported:
1. 1 destination stream and 1 destination tag (i.e. single tag applies to single stream)
- `destinationStream: 'stream1', destinationTag: 'tag1'`
1. 1 destination stream and N destination tags (i.e. all tags apply to the same stream)
- `destinationStream: 'stream1', destinationTag: 'tag1, tag2'`
1. 1 destination tag and N destination streams (i.e. all streams will get the same tag)
- `destinationStream: 'stream1, stream2', destinationTag: 'tag1'`
1. N destination streams and N destination tags (i.e. each index will be combined to form a unique stream:tag combination)
- `destinationStream: 'stream1, stream2', destinationTag: 'tag1, tag2'`

Optional parameters are:

- "alias": Whether to update destination tag whenever the source tag changes. Equivalent of the `--alias` option for the `oc tag` command. When false, the destination tag type is "ImageStreamImage", and when true, the destination tag type is "ImageStreamTag".
- "alias": Whether to update destination tag whenever the source tag changes. Equivalent of the `--alias` option for the `oc tag` command. When false, the destination tag type is "ImageStreamImage", and when true, the destination tag type is "ImageStreamTag".

- "destinationNamespace": The name of the project to host the destinationStream:destinationTag. If nothing is specified, the plugin will inspect the PROJECT_NAME environment variable.
- "destinationNamespace": The name of the project to host the destinationStream:destinationTag. If nothing is specified, the plugin will use the source namespace.

- "destinationAuthToken": The authorization token for interacting with the destinationNamespace. If you do not supply a value, the plugin will assume it is running in the OpenShift Jenkins image and attempt to load the kubernetes service account token stored in that image.
- "destinationAuthToken": The authorization token for interacting with the destinationNamespace. If you do not supply a value, the plugin will assume it is running in the OpenShift Jenkins image and attempt to load the kubernetes service account token stored in that image.

#### "Verify OpenShift Build"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public class MessageConstants {
/*
* These messages are for the "Tag OpenShift Image" jenkins build step implemented by OpenShiftImageTagger
*/
public static final String START_TAG = "\n\nStarting \"" + OpenShiftImageTagger.DISPLAY_NAME + "\" with the source [image stream:tag] \"%s:%s\" from the project \"%s\" and destination [image stream:tag] \"%s:%s\" from the project \"%s\".";
public static final String START_TAG = "\n\nStarting \"" + OpenShiftImageTagger.DISPLAY_NAME + "\" with the source [image stream:tag] \"%s:%s\" from the project \"%s\" and destination stream(s) \"%s\" with tag(s) \"%s\" from the project \"%s\".";
public static final String EXIT_TAG_CANNOT_CREATE_DEST_IS = "\n\nExiting \"" + OpenShiftImageTagger.DISPLAY_NAME + "\" unsuccessfully; could not create the image stream \"%s\" in the project \"%s\".";
public static final String EXIT_TAG_CANNOT_GET_IS = "\n\nExiting \"" + OpenShiftImageTagger.DISPLAY_NAME + "\" unsuccessfully; could not retrieve the image stream \"%s\" from the project \"%s\".";
public static final String EXIT_TAG_NOT_FOUND = "\n\nExisting \"" + OpenShiftImageTagger.DISPLAY_NAME + "\" unsuccessfully; could not fine either an image tag or ID \"%s\" associated with the image stream \"%s\".";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
package com.openshift.jenkins.plugins.pipeline;

import com.openshift.jenkins.plugins.pipeline.model.IOpenShiftImageTagger;
import hudson.Extension;
import hudson.util.FormValidation;
import hudson.model.AbstractProject;
import hudson.tasks.Builder;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Builder;
import hudson.util.FormValidation;
import net.sf.json.JSONObject;

import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.QueryParameter;

import com.openshift.jenkins.plugins.pipeline.model.IOpenShiftImageTagger;
//import com.openshift.restclient.authorization.TokenAuthorizationStrategy;

import org.kohsuke.stapler.StaplerRequest;

import javax.servlet.ServletException;

import java.io.IOException;
//import java.util.Map;

public class OpenShiftImageTagger extends OpenShiftBaseStep implements IOpenShiftImageTagger {

Expand All @@ -29,9 +24,7 @@ public class OpenShiftImageTagger extends OpenShiftBaseStep implements IOpenShif
protected final String destinationNamespace;
protected final String destinationAuthToken;
protected final String alias;
// marked transient so don't serialize these next 2 in the workflow plugin flow; constructed on per request basis
// protected transient TokenAuthorizationStrategy destinationBearerToken;


// Fields in config.jelly must match the parameter names in the "DataBoundConstructor"
@DataBoundConstructor
public OpenShiftImageTagger(String apiURL, String testTag, String prodTag, String namespace, String authToken, String verbose, String testStream, String prodStream, String destinationNamespace, String destinationAuthToken, String alias) {
Expand All @@ -54,19 +47,39 @@ public String getAlias() {
return alias;
}

public String getTestTag() {
@Deprecated
public String getTestTag() {
return testTag;
}

public String getSrcTag() {
return testTag;
}

public String getProdTag() {
return prodTag;
@Deprecated
public String getProdTag() {
return prodTag;
}

public String getDestTag() {
return prodTag;
}

public String getTestStream() {

@Deprecated
public String getTestStream() {
return testStream;
}

public String getSrcStream() {
return testStream;
}

public String getProdStream() {
@Deprecated
public String getProdStream() {
return prodStream;
}

public String getDestStream() {
return prodStream;
}

Expand All @@ -78,15 +91,6 @@ public String getDestinationAuthToken() {
return this.destinationAuthToken;
}

/* public TokenAuthorizationStrategy getDestinationToken() {
return destinationBearerToken;
}

public void setDestinationToken(TokenAuthorizationStrategy token) {
destinationBearerToken = token;
}
*/

// Overridden for better type safety.
// If your plugin doesn't really define any property on Descriptor,
// you don't have to do this.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
package com.openshift.jenkins.plugins.pipeline.dsl;
import com.openshift.jenkins.plugins.pipeline.ParamVerify;
import com.openshift.jenkins.plugins.pipeline.model.IOpenShiftImageTagger;
import hudson.Extension;
import hudson.model.Action;
import hudson.model.BuildListener;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Action;
import hudson.model.BuildListener;
import hudson.tasks.BuildStepMonitor;

import org.jenkinsci.plugins.workflow.steps.AbstractStepDescriptorImpl;
import org.jenkinsci.plugins.workflow.steps.Step;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

import com.openshift.jenkins.plugins.pipeline.ParamVerify;
import com.openshift.jenkins.plugins.pipeline.model.IOpenShiftImageTagger;
//import com.openshift.restclient.authorization.TokenAuthorizationStrategy;

import java.util.Collection;
import java.util.Map;
import java.util.logging.Logger;


public class OpenShiftImageTagger extends OpenShiftBaseStep implements IOpenShiftImageTagger {

Expand All @@ -30,9 +25,7 @@ public class OpenShiftImageTagger extends OpenShiftBaseStep implements IOpenShif
protected String destinationNamespace;
protected String destinationAuthToken;
protected String alias;
// marked transient so don't serialize these next 2 in the workflow plugin flow; constructed on per request basis
//protected transient TokenAuthorizationStrategy destinationBearerToken;


// Fields in config.jelly must match the parameter names in the "DataBoundConstructor"
@DataBoundConstructor
public OpenShiftImageTagger(String srcStream, String srcTag, String destStream, String destTag) {
Expand Down Expand Up @@ -107,19 +100,6 @@ public String getDestinationAuthToken() {
this.destinationAuthToken = destinationAuthToken;
}

/* public TokenAuthorizationStrategy getDestinationToken() {
return destinationBearerToken;
}

public void setDestinationToken(TokenAuthorizationStrategy token) {
destinationBearerToken = token;
}
*/


private static final Logger LOGGER = Logger.getLogger(OpenShiftImageTagger.class.getName());


@Extension
public static class DescriptorImpl extends AbstractStepDescriptorImpl {

Expand Down
Loading