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;
}
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());
}
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();
}
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;
}
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;
}
Aggregations