Search in sources :

Example 1 with Action

use of hudson.model.Action in project blueocean-plugin by jenkinsci.

the class PipelineNodeUtil method isSkippedStage.

public static boolean isSkippedStage(@Nullable FlowNode node) {
    if (node == null) {
        return false;
    }
    for (Action action : node.getActions()) {
        if (action instanceof TagsAction && ((TagsAction) action).getTagValue(StageStatus.TAG_NAME) != null) {
            TagsAction tagsAction = (TagsAction) action;
            String value = tagsAction.getTagValue(StageStatus.TAG_NAME);
            return value != null && value.equals(StageStatus.getSkippedForConditional());
        }
    }
    return false;
}
Also used : ErrorAction(org.jenkinsci.plugins.workflow.actions.ErrorAction) InputAction(org.jenkinsci.plugins.workflow.support.steps.input.InputAction) LabelAction(org.jenkinsci.plugins.workflow.actions.LabelAction) ThreadNameAction(org.jenkinsci.plugins.workflow.actions.ThreadNameAction) LogAction(org.jenkinsci.plugins.workflow.actions.LogAction) StageAction(org.jenkinsci.plugins.workflow.actions.StageAction) Action(hudson.model.Action) PauseAction(org.jenkinsci.plugins.workflow.support.actions.PauseAction) TagsAction(org.jenkinsci.plugins.workflow.actions.TagsAction) TagsAction(org.jenkinsci.plugins.workflow.actions.TagsAction)

Example 2 with Action

use of hudson.model.Action in project promoted-builds-plugin by jenkinsci.

the class PromotedEnvVarTokenMacroTest method testEnvironmentVariableExpansion.

@Test
public void testEnvironmentVariableExpansion() throws Exception {
    // Assemble
    r.jenkins.setSecurityRealm(r.createDummySecurityRealm());
    User u = User.get("foo");
    u.setFullName("Foobar");
    SecurityContextHolder.getContext().setAuthentication(u.impersonate());
    MockFolder parent = r.createFolder("Folder");
    FreeStyleProject project = parent.createProject(FreeStyleProject.class, "Project");
    JobPropertyImpl promotionProperty = new JobPropertyImpl(project);
    PromotionProcess promotionProcess = promotionProperty.addProcess("promo");
    promotionProcess.conditions.clear();
    ManualCondition manualCondition = new ManualCondition();
    manualCondition.getParameterDefinitions().add(new StringParameterDefinition("PROMOTION_PARAM", "defaultValue"));
    promotionProcess.conditions.add(manualCondition);
    Action approvalAction = new ManualCondition.ManualApproval(promotionProcess.getName(), new LinkedList<ParameterValue>());
    TokenMacroExpressionRecorder recorder = new TokenMacroExpressionRecorder("${PROMOTION_ENV,var=\"PROMOTION_PARAM\"}");
    promotionProcess.getBuildSteps().add(recorder);
    // Act & promote
    FreeStyleBuild build = project.scheduleBuild2(0).get();
    build.addAction(approvalAction);
    build.save();
    Promotion promotion = promotionProcess.considerPromotion2(build, Arrays.asList((ParameterValue) new StringParameterValue("PROMOTION_PARAM", "FOO"))).get();
    // Check results
    EnvVars env = promotion.getEnvironment(TaskListener.NULL);
    assertEquals("The PROMOTION_PARAM variable has not been injected", "FOO", env.get("PROMOTION_PARAM"));
    assertEquals("The promotion variable value has not been resolved by the PROMOTION_PARAM macro", "FOO", recorder.getCaptured());
}
Also used : Action(hudson.model.Action) User(hudson.model.User) StringParameterDefinition(hudson.model.StringParameterDefinition) StringParameterValue(hudson.model.StringParameterValue) ParameterValue(hudson.model.ParameterValue) StringParameterValue(hudson.model.StringParameterValue) FreeStyleBuild(hudson.model.FreeStyleBuild) MockFolder(org.jvnet.hudson.test.MockFolder) FreeStyleProject(hudson.model.FreeStyleProject) JobPropertyImpl(hudson.plugins.promoted_builds.JobPropertyImpl) Promotion(hudson.plugins.promoted_builds.Promotion) ManualCondition(hudson.plugins.promoted_builds.conditions.ManualCondition) EnvVars(hudson.EnvVars) PromotionProcess(hudson.plugins.promoted_builds.PromotionProcess) Test(org.junit.Test)

Example 3 with Action

use of hudson.model.Action in project promoted-builds-plugin by jenkinsci.

the class PromotionEnvironmentVariablesTest method shouldSetJobAndJobFullNames.

@Test
public void shouldSetJobAndJobFullNames() throws Descriptor.FormException, IOException, InterruptedException, ExecutionException, Exception {
    // Assemble
    r.jenkins.setSecurityRealm(r.createDummySecurityRealm());
    User u = User.get("foo");
    u.setFullName("Foobar");
    SecurityContextHolder.getContext().setAuthentication(u.impersonate());
    MockFolder parent = r.createFolder("Folder");
    FreeStyleProject project = parent.createProject(FreeStyleProject.class, "Project");
    JobPropertyImpl promotionProperty = new JobPropertyImpl(project);
    PromotionProcess promotionProcess = promotionProperty.addProcess("promo");
    promotionProcess.conditions.clear();
    promotionProcess.conditions.add(new ManualCondition());
    Action approvalAction = new ManualCondition.ManualApproval(promotionProcess.getName(), new ArrayList<ParameterValue>());
    // Act
    FreeStyleBuild build = project.scheduleBuild2(0).get();
    build.setDisplayName("1234");
    build.addAction(approvalAction);
    build.save();
    Promotion promotion = promotionProcess.considerPromotion2(build).get();
    EnvVars env = promotion.getEnvironment(TaskListener.NULL);
    // Assert
    assertEquals("Folder/Project", env.get("PROMOTED_JOB_FULL_NAME"));
    assertEquals("Project", env.get("PROMOTED_JOB_NAME"));
    assertEquals("Foobar", env.get("PROMOTED_USER_NAME"));
    assertEquals("foo", env.get("PROMOTED_USER_ID"));
    assertEquals("1234", env.get("PROMOTED_DISPLAY_NAME"));
    project.delete();
    parent.delete();
}
Also used : Action(hudson.model.Action) User(hudson.model.User) ParameterValue(hudson.model.ParameterValue) FreeStyleBuild(hudson.model.FreeStyleBuild) MockFolder(org.jvnet.hudson.test.MockFolder) FreeStyleProject(hudson.model.FreeStyleProject) ManualCondition(hudson.plugins.promoted_builds.conditions.ManualCondition) EnvVars(hudson.EnvVars) Test(org.junit.Test)

Example 4 with Action

use of hudson.model.Action in project hudson-2.x by hudson.

the class BuildTrigger method execute.

/**
     * Convenience method to trigger downstream builds.
     *
     * @param build
     *      The current build. Its downstreams will be triggered.
     * @param listener
     *      Receives the progress report.
     */
public static boolean execute(AbstractBuild build, BuildListener listener) {
    PrintStream logger = listener.getLogger();
    // Check all downstream Project of the project, not just those defined by BuildTrigger
    final DependencyGraph graph = Hudson.getInstance().getDependencyGraph();
    List<Dependency> downstreamProjects = new ArrayList<Dependency>(graph.getDownstreamDependencies(build.getProject()));
    // Sort topologically
    Collections.sort(downstreamProjects, new Comparator<Dependency>() {

        public int compare(Dependency lhs, Dependency rhs) {
            // Swapping lhs/rhs to get reverse sort:
            return graph.compare(rhs.getDownstreamProject(), lhs.getDownstreamProject());
        }
    });
    for (Dependency dep : downstreamProjects) {
        AbstractProject p = dep.getDownstreamProject();
        if (p.isDisabled()) {
            logger.println(Messages.BuildTrigger_Disabled(p.getName()));
            continue;
        }
        List<Action> buildActions = new ArrayList<Action>();
        if (dep.shouldTriggerBuild(build, listener, buildActions)) {
            // this is not completely accurate, as a new build might be triggered
            // between these calls
            String name = p.getName() + " #" + p.getNextBuildNumber();
            if (p.scheduleBuild(p.getQuietPeriod(), new UpstreamCause((Run) build), buildActions.toArray(new Action[buildActions.size()]))) {
                logger.println(Messages.BuildTrigger_Triggering(name));
            } else {
                logger.println(Messages.BuildTrigger_InQueue(name));
            }
        }
    }
    return true;
}
Also used : PrintStream(java.io.PrintStream) Action(hudson.model.Action) ArrayList(java.util.ArrayList) UpstreamCause(hudson.model.Cause.UpstreamCause) DependencyGraph(hudson.model.DependencyGraph) Run(hudson.model.Run) Dependency(hudson.model.DependencyGraph.Dependency) AbstractProject(hudson.model.AbstractProject)

Example 5 with Action

use of hudson.model.Action in project hudson-2.x by hudson.

the class LabelAtom method updateTransientActions.

protected void updateTransientActions() {
    Vector<Action> ta = new Vector<Action>();
    // add the config link
    if (!getApplicablePropertyDescriptors().isEmpty()) {
        // if there's no property descriptor, there's nothing interesting to configure.
        ta.add(new Action() {

            public String getIconFileName() {
                if (Hudson.getInstance().hasPermission(Hudson.ADMINISTER))
                    return "setting.gif";
                else
                    return null;
            }

            public String getDisplayName() {
                return "Configure";
            }

            public String getUrlName() {
                return "configure";
            }
        });
    }
    for (LabelAtomProperty p : properties) ta.addAll(p.getActions(this));
    transientActions = ta;
}
Also used : Action(hudson.model.Action) Vector(java.util.Vector)

Aggregations

Action (hudson.model.Action)7 ArrayList (java.util.ArrayList)3 GitLabLinkAction (argelbargel.jenkins.plugins.gitlab_branch_source.actions.GitLabLinkAction)2 GitLabProjectAvatarMetadataAction (argelbargel.jenkins.plugins.gitlab_branch_source.actions.GitLabProjectAvatarMetadataAction)2 GitLabSCMAcceptMergeRequestAction (argelbargel.jenkins.plugins.gitlab_branch_source.actions.GitLabSCMAcceptMergeRequestAction)2 GitLabSCMCauseAction (argelbargel.jenkins.plugins.gitlab_branch_source.actions.GitLabSCMCauseAction)2 GitLabSCMHeadMetadataAction (argelbargel.jenkins.plugins.gitlab_branch_source.actions.GitLabSCMHeadMetadataAction)2 GitLabSCMPublishAction (argelbargel.jenkins.plugins.gitlab_branch_source.actions.GitLabSCMPublishAction)2 EnvVars (hudson.EnvVars)2 FreeStyleBuild (hudson.model.FreeStyleBuild)2 FreeStyleProject (hudson.model.FreeStyleProject)2 ParameterValue (hudson.model.ParameterValue)2 User (hudson.model.User)2 ManualCondition (hudson.plugins.promoted_builds.conditions.ManualCondition)2 Nonnull (javax.annotation.Nonnull)2 ObjectMetadataAction (jenkins.scm.api.metadata.ObjectMetadataAction)2 PrimaryInstanceMetadataAction (jenkins.scm.api.metadata.PrimaryInstanceMetadataAction)2 ChangeRequestSCMHead (jenkins.scm.api.mixin.ChangeRequestSCMHead)2 TagSCMHead (jenkins.scm.api.mixin.TagSCMHead)2 Test (org.junit.Test)2