├── src
├── main
│ ├── resources
│ │ ├── index.properties
│ │ ├── io
│ │ │ └── jenkins
│ │ │ │ └── plugins
│ │ │ │ └── adobe
│ │ │ │ └── cloudmanager
│ │ │ │ ├── builder
│ │ │ │ ├── CloudManagerBuilder
│ │ │ │ │ ├── config-program.properties
│ │ │ │ │ ├── config-pipeline.properties
│ │ │ │ │ ├── config-aioProject.properties
│ │ │ │ │ ├── config-program.jelly
│ │ │ │ │ ├── config-aioProject.jelly
│ │ │ │ │ └── config-pipeline.jelly
│ │ │ │ ├── RepositorySyncBuilder
│ │ │ │ │ ├── config.properties
│ │ │ │ │ ├── help-force.properties
│ │ │ │ │ ├── help.properties
│ │ │ │ │ ├── help-force.jelly
│ │ │ │ │ ├── help.jelly
│ │ │ │ │ └── config.jelly
│ │ │ │ ├── StartPipelineBuilder
│ │ │ │ │ ├── help.jelly
│ │ │ │ │ ├── help.properties
│ │ │ │ │ └── config.jelly
│ │ │ │ └── Messages.properties
│ │ │ │ ├── step
│ │ │ │ ├── AdvancePipelineStep
│ │ │ │ │ ├── config.properties
│ │ │ │ │ ├── help-actions.properties
│ │ │ │ │ ├── help.properties
│ │ │ │ │ ├── help.jelly
│ │ │ │ │ ├── help-actions.jelly
│ │ │ │ │ └── config.jelly
│ │ │ │ ├── PipelineEndStep
│ │ │ │ │ ├── config.properties
│ │ │ │ │ ├── help-mirror.properties
│ │ │ │ │ ├── help-empty.properties
│ │ │ │ │ ├── help.properties
│ │ │ │ │ ├── help-empty.jelly
│ │ │ │ │ ├── help-mirror.jelly
│ │ │ │ │ ├── help.jelly
│ │ │ │ │ └── config.jelly
│ │ │ │ ├── PollPipelineStep
│ │ │ │ │ ├── config.properties
│ │ │ │ │ ├── help-quiet.properties
│ │ │ │ │ ├── help-recurrencePeriod.properties
│ │ │ │ │ ├── help.properties
│ │ │ │ │ ├── help.jelly
│ │ │ │ │ ├── help-quiet.jelly
│ │ │ │ │ ├── help-recurrencePeriod.jelly
│ │ │ │ │ └── config.jelly
│ │ │ │ ├── execution
│ │ │ │ │ ├── PipelineStepStateExecution
│ │ │ │ │ │ ├── approval.properties
│ │ │ │ │ │ ├── codeQuality.properties
│ │ │ │ │ │ ├── index.jelly
│ │ │ │ │ │ ├── approval.jelly
│ │ │ │ │ │ └── codeQuality.jelly
│ │ │ │ │ └── Messages.properties
│ │ │ │ ├── PipelineStepStateStep
│ │ │ │ │ ├── help-waitingPause.properties
│ │ │ │ │ ├── help-advance.properties
│ │ │ │ │ ├── help-autoAdvance.properties
│ │ │ │ │ ├── config.properties
│ │ │ │ │ ├── help-actions.properties
│ │ │ │ │ ├── help.properties
│ │ │ │ │ ├── help.jelly
│ │ │ │ │ ├── help-actions.jelly
│ │ │ │ │ ├── help-advance.jelly
│ │ │ │ │ ├── help-autoAdvance.jelly
│ │ │ │ │ ├── help-waitingPause.jelly
│ │ │ │ │ └── config.jelly
│ │ │ │ └── Messages.properties
│ │ │ │ ├── trigger
│ │ │ │ ├── PipelineStartTrigger
│ │ │ │ │ ├── config.properties
│ │ │ │ │ ├── help.properties
│ │ │ │ │ ├── help.jelly
│ │ │ │ │ └── config.jelly
│ │ │ │ └── Messages.properties
│ │ │ │ ├── config
│ │ │ │ ├── AdobeIOConfig
│ │ │ │ │ ├── config.properties
│ │ │ │ │ ├── help-webhookEnabled.properties
│ │ │ │ │ ├── help-webhookEnabled.jelly
│ │ │ │ │ └── config.jelly
│ │ │ │ ├── AdobeIOProjectConfig
│ │ │ │ │ ├── help.properties
│ │ │ │ │ ├── help-name.properties
│ │ │ │ │ ├── help-apiUrl.properties
│ │ │ │ │ ├── config.properties
│ │ │ │ │ ├── help-name.jelly
│ │ │ │ │ ├── help-apiUrl.jelly
│ │ │ │ │ ├── help.jelly
│ │ │ │ │ └── config.groovy
│ │ │ │ └── Messages.properties
│ │ │ │ ├── action
│ │ │ │ ├── CloudManagerBuildAction
│ │ │ │ │ ├── index.properties
│ │ │ │ │ ├── summary.jelly
│ │ │ │ │ └── index.jelly
│ │ │ │ ├── PIpelineStepDecisionAction
│ │ │ │ │ └── summary.jelly
│ │ │ │ ├── PipelineWaitingAction
│ │ │ │ │ ├── summary.jelly
│ │ │ │ │ └── index.jelly
│ │ │ │ └── Messages.properties
│ │ │ │ ├── util
│ │ │ │ └── Messages.properties
│ │ │ │ └── webhook
│ │ │ │ ├── subscriber
│ │ │ │ └── Messages.properties
│ │ │ │ └── Messages.properties
│ │ └── index.jelly
│ ├── webapp
│ │ ├── icons
│ │ │ └── Adobe_Experience_Cloud_logo_48px.png
│ │ └── help.html
│ └── java
│ │ └── io
│ │ └── jenkins
│ │ └── plugins
│ │ └── adobe
│ │ └── cloudmanager
│ │ ├── trigger
│ │ ├── CMPipelineStartCause.java
│ │ └── PipelineStartEvent.java
│ │ ├── webhook
│ │ ├── CMEvent.java
│ │ └── subscriber
│ │ │ ├── CloudManagerSubscriberEvent.java
│ │ │ ├── CloudManagerEventSubscriber.java
│ │ │ ├── PipelineEndEventSubscriber.java
│ │ │ └── PipelineStepEventSubscriber.java
│ │ ├── step
│ │ ├── execution
│ │ │ ├── Failure.java
│ │ │ ├── Cancellation.java
│ │ │ ├── RemoteStateInterruption.java
│ │ │ ├── AdvancePipelineExecution.java
│ │ │ └── PollPipelineExecution.java
│ │ ├── AdvancePipelineStep.java
│ │ ├── PollPipelineStep.java
│ │ └── PipelineEndStep.java
│ │ ├── CloudManagerPipelineExecution.java
│ │ ├── action
│ │ └── PipelineStepDecisionAction.java
│ │ ├── builder
│ │ └── StartPipelineBuilder.java
│ │ ├── util
│ │ ├── CloudManagerApiUtil.java
│ │ ├── DescriptorHelper.java
│ │ └── CredentialsUtil.java
│ │ └── config
│ │ └── AdobeIOConfig.java
└── test
│ ├── resources
│ ├── events
│ │ ├── pipeline-ended.json
│ │ ├── step-ended.json
│ │ ├── step-started.json
│ │ ├── step-waiting.json
│ │ └── pipeline-started.json
│ ├── mockserver.properties
│ └── io
│ │ └── jenkins
│ │ └── plugins
│ │ └── adobe
│ │ └── cloudmanager
│ │ └── config
│ │ └── configuration-as-code.yaml
│ └── java
│ └── io
│ └── jenkins
│ └── plugins
│ └── adobe
│ └── cloudmanager
│ ├── test
│ └── RestartTest.java
│ ├── config
│ ├── AdobeIOConfigTest.java
│ └── ConfigAsCodeTest.java
│ ├── step
│ └── execution
│ │ └── AbstractStepExecutionTest.java
│ └── builder
│ └── CloudManagerBuilderTest.java
├── .github
├── release-drafter.yml
├── CODEOWNERS
├── dependabot.yml
└── workflows
│ ├── cd.yaml
│ └── jenkins-security-scan.yml
├── .mvn
├── maven.config
└── extensions.xml
├── doc
├── builder
│ ├── start-pipeline
│ │ ├── start-pipeline.png
│ │ └── README.md
│ └── repository-sync
│ │ └── README.md
├── config
│ ├── adobeio-project
│ │ ├── configure-project.png
│ │ ├── test-configuration.png
│ │ └── README.md
│ └── jenkins-credentials
│ │ ├── add-private-key.gif
│ │ ├── add-adobe-io-domain.gif
│ │ ├── add-client-secret-creds.gif
│ │ └── README.md
├── action
│ ├── pipeline-waiting
│ │ ├── cloud-manager-waiting.png
│ │ └── README.md
│ └── cloud-manager-build
│ │ ├── cloud-manager-details.png
│ │ └── README.md
├── step
│ ├── poll-pipeline
│ │ └── README.md
│ ├── advance-pipeline
│ │ └── README.md
│ ├── pipeline-end
│ │ └── README.md
│ └── pipeline-step-state
│ │ └── README.md
└── trigger
│ └── start-pipeline
│ └── README.md
├── Jenkinsfile
├── LICENSE
├── .gitignore
└── README.md
/src/main/resources/index.properties:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.github/release-drafter.yml:
--------------------------------------------------------------------------------
1 | _extends: .github
2 |
--------------------------------------------------------------------------------
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | * @jenkinsci/adobe-cloud-manager-plugin-developers
2 |
--------------------------------------------------------------------------------
/.mvn/maven.config:
--------------------------------------------------------------------------------
1 | -Pconsume-incrementals
2 | -Pmight-produce-incrementals
3 | -Dchangelist.format=%d.v%s
4 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/builder/CloudManagerBuilder/config-program.properties:
--------------------------------------------------------------------------------
1 | title=Program
2 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/builder/CloudManagerBuilder/config-pipeline.properties:
--------------------------------------------------------------------------------
1 | title=Pipeline
2 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/AdvancePipelineStep/config.properties:
--------------------------------------------------------------------------------
1 | actions.title=Waiting Actions
2 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/builder/CloudManagerBuilder/config-aioProject.properties:
--------------------------------------------------------------------------------
1 | title=AIO Project
2 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PipelineEndStep/config.properties:
--------------------------------------------------------------------------------
1 | mirror.title=Mirror State
2 | empty.title=Empty Block
3 |
--------------------------------------------------------------------------------
/doc/builder/start-pipeline/start-pipeline.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenkinsci/adobe-cloud-manager-plugin/master/doc/builder/start-pipeline/start-pipeline.png
--------------------------------------------------------------------------------
/doc/config/adobeio-project/configure-project.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenkinsci/adobe-cloud-manager-plugin/master/doc/config/adobeio-project/configure-project.png
--------------------------------------------------------------------------------
/doc/config/adobeio-project/test-configuration.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenkinsci/adobe-cloud-manager-plugin/master/doc/config/adobeio-project/test-configuration.png
--------------------------------------------------------------------------------
/doc/config/jenkins-credentials/add-private-key.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenkinsci/adobe-cloud-manager-plugin/master/doc/config/jenkins-credentials/add-private-key.gif
--------------------------------------------------------------------------------
/doc/action/pipeline-waiting/cloud-manager-waiting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenkinsci/adobe-cloud-manager-plugin/master/doc/action/pipeline-waiting/cloud-manager-waiting.png
--------------------------------------------------------------------------------
/doc/config/jenkins-credentials/add-adobe-io-domain.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenkinsci/adobe-cloud-manager-plugin/master/doc/config/jenkins-credentials/add-adobe-io-domain.gif
--------------------------------------------------------------------------------
/doc/action/cloud-manager-build/cloud-manager-details.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenkinsci/adobe-cloud-manager-plugin/master/doc/action/cloud-manager-build/cloud-manager-details.png
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PollPipelineStep/config.properties:
--------------------------------------------------------------------------------
1 | recurrencePeriod.title=Recurrence Period in Milliseconds
2 | quiet.title=Quiet Mode
3 |
--------------------------------------------------------------------------------
/doc/config/jenkins-credentials/add-client-secret-creds.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenkinsci/adobe-cloud-manager-plugin/master/doc/config/jenkins-credentials/add-client-secret-creds.gif
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/trigger/PipelineStartTrigger/config.properties:
--------------------------------------------------------------------------------
1 | project.title=AIO Project
2 | program.title=Program
3 | pipeline.title=Pipeline
4 |
5 |
--------------------------------------------------------------------------------
/src/main/webapp/icons/Adobe_Experience_Cloud_logo_48px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenkinsci/adobe-cloud-manager-plugin/master/src/main/webapp/icons/Adobe_Experience_Cloud_logo_48px.png
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PollPipelineStep/help-quiet.properties:
--------------------------------------------------------------------------------
1 | help.text=If true, does not log a message each time the condition is checked. Defaults to false.
2 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/execution/PipelineStepStateExecution/approval.properties:
--------------------------------------------------------------------------------
1 | prompt=Pipeline requires approval to advance.
2 | approve=Approve
3 | cancel=Cancel
4 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/config/AdobeIOConfig/config.properties:
--------------------------------------------------------------------------------
1 | displayName=Adobe IO
2 | title=Adobe IO Projects
3 | webhook.title=Enable WebHook
4 | configs.caption=Add Adobe IO Project
5 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/config/AdobeIOProjectConfig/help.properties:
--------------------------------------------------------------------------------
1 | help.text=Fill out the form using the properties from the JWT Service Account configuration in the AdobeIO Project.
2 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PipelineStepStateStep/help-waitingPause.properties:
--------------------------------------------------------------------------------
1 | help.text=If set to false, when a waiting event is encountered the pipeline will not pause for user input.
2 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PipelineEndStep/help-mirror.properties:
--------------------------------------------------------------------------------
1 | help.text=If true, this pipeline will mirror the state of the remote pipeline. (i.e. Remote errors will fail this step).
2 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/config/AdobeIOProjectConfig/help-name.properties:
--------------------------------------------------------------------------------
1 | help.text=Provide a name for this configuration. This will be used by pipelines and jobs to reference this configuration.
2 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PipelineStepStateStep/help-advance.properties:
--------------------------------------------------------------------------------
1 | help.text=If enabled, when a *finished* event occurs for any specified action, this step will complete and continue the pipeline.
2 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PipelineStepStateStep/help-autoAdvance.properties:
--------------------------------------------------------------------------------
1 | help.text=If selected, then any event which would cause this step to wait, will automatically be advanced in Cloud Manager.
2 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/builder/RepositorySyncBuilder/config.properties:
--------------------------------------------------------------------------------
1 | repository.title=Cloud Manager Repository URL
2 | credentialsId.title=Cloud Manager Repository Credentials
3 | force.title=Force Git Push
4 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/execution/PipelineStepStateExecution/codeQuality.properties:
--------------------------------------------------------------------------------
1 | prompt=Pipeline quality gates require approval for override.
2 | approve=Override Quality Gate
3 | cancel=Cancel Execution
4 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PipelineStepStateStep/config.properties:
--------------------------------------------------------------------------------
1 | actions.title=Build Actions
2 | advance.title=Advance Step
3 | autoApprove.title=Auto Approve Step
4 | waitingPause.title=Pause for Waiting Events
5 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PollPipelineStep/help-recurrencePeriod.properties:
--------------------------------------------------------------------------------
1 | help.text=Sets the wait period between retries in milliseconds. Defaults to 5m. \
2 |
\
3 | Maximum allowed wait period is 15m.
4 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/builder/RepositorySyncBuilder/help-force.properties:
--------------------------------------------------------------------------------
1 | help.text=Select this if you want to force push the update to Cloud Manager. \
2 |
\
3 | Note: This will override any merge/remote conflicts.
4 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/builder/StartPipelineBuilder/help.jelly:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ${%help.text}
5 |
6 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "maven"
4 | directory: "/"
5 | schedule:
6 | interval: "weekly"
7 | - package-ecosystem: "github-actions"
8 | directory: "/"
9 | schedule:
10 | interval: "daily"
11 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/builder/StartPipelineBuilder/help.properties:
--------------------------------------------------------------------------------
1 | help.text=Starts an Adobe Cloud Manager pipeline. \
2 |
\
3 | The program and pipeline values can be specified by either their names or unique ids.
4 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/config/AdobeIOProjectConfig/help-apiUrl.properties:
--------------------------------------------------------------------------------
1 | help.text=API endpoint of Adobe IO.
\
2 | To use the default production endpoint, leave this field the default value of https://ims-na1.adobelogin.com.
3 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PipelineEndStep/help-empty.properties:
--------------------------------------------------------------------------------
1 | help.text=Set to true if an empty inner block will be used. Hold over until JENKINS-65646 is fixed.
2 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/action/CloudManagerBuildAction/index.properties:
--------------------------------------------------------------------------------
1 | page.title=Adobe Cloud Manager Pipeline Execution Details
2 | steps.heading=Execution Steps:
3 | logs.text=Download logs
4 | qualityResults.text=Download Quality Check Results
5 |
6 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/action/PIpelineStepDecisionAction/summary.jelly:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ${it.displayName}
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/builder/RepositorySyncBuilder/help.properties:
--------------------------------------------------------------------------------
1 | description=Synchronize a Cloud Manager Git repo with this project's repository. The repository must be Git based.
2 | help.text=Provide the Git repo URL and a reference to credentials which have access to the specified repository.
3 | link.text=Cloud Manager Git documentation
4 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/action/PipelineWaitingAction/summary.jelly:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Adobe Cloud Manager step: ${it.displayName}
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PipelineStepStateStep/help-actions.properties:
--------------------------------------------------------------------------------
1 | help.text=Selected actions wll be processed by this Step. If left bank, all events will be processed. \
2 | See the Cloud Manager docs for meanings of actions.
3 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/config/AdobeIOConfig/help-webhookEnabled.properties:
--------------------------------------------------------------------------------
1 | help.text=Enable or disable the webhook for processing events from Adobe IO. \
2 |
\
3 | When disabled, the webhook will log a warning when any requests come in at the WebHook URL, but it is otherwise ignored. \
4 |
\
5 | When enabled, the webhook will operate as described in the documentation.
6 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/trigger/PipelineStartTrigger/help.properties:
--------------------------------------------------------------------------------
1 | help.text=Triggers a Jenkins job when the specified remote Adobe Cloud Manager pipeline has started. \
2 |
\
3 | This trigger only works if the Cloud Manager WebHook is enabled. \
4 |
\
5 | The program and pipeline values can be specified by either their names or unique ids.
6 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/AdvancePipelineStep/help-actions.properties:
--------------------------------------------------------------------------------
1 | help.text=Select the build actions which this step will advance. If left bank, all waiting actions are handled by this step. \
2 | See the Cloud Manager docs for meanings of actions.
3 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/config/AdobeIOProjectConfig/config.properties:
--------------------------------------------------------------------------------
1 | name.title=Name
2 | apiUrl.title=API URL
3 | clientId.title=Client Id (aka API Key)
4 | orgId.title=Adobe Organization Id
5 | techAcctId.title=Technical Account Id
6 | clientSecret.title=Client Secret Credential
7 | privateKey.title=Private Key Credential
8 |
9 | validate.title=Test Connection
10 | progress=Authenticating...
11 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/execution/PipelineStepStateExecution/index.jelly:
--------------------------------------------------------------------------------
1 |
2 |
3 | Pipeline Execution Event State: ${it.id}
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.mvn/extensions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | io.jenkins.tools.incrementals
4 | git-changelist-maven-extension
5 | 1.2
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.github/workflows/cd.yaml:
--------------------------------------------------------------------------------
1 | # Note: additional setup is required, see https://www.jenkins.io/redirect/continuous-delivery-of-plugins
2 |
3 | name: cd
4 | on:
5 | workflow_dispatch:
6 | check_run:
7 | types:
8 | - completed
9 |
10 | jobs:
11 | maven-cd:
12 | uses: jenkins-infra/github-reusable-workflows/.github/workflows/maven-cd.yml@v1
13 | secrets:
14 | MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
15 | MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }}
16 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/util/Messages.properties:
--------------------------------------------------------------------------------
1 | CloudManagerApiUtil.error.missingAioProject=Unable to location AIO Project for name: {0}.
2 | CloudManagerApiUtil.error.CloudManagerApiException=An API exception occurred: {0}.
3 |
4 | CredentialsUtil.error.privateKeyError=Unable to read Private Key credential id {0}, error was: {1}.
5 |
6 | DescriptorHelper.defaultListItem=-None-
7 | DescriptorHelper.error.CloudManagerApiException=An API exception occurred: {0}.
8 |
9 |
--------------------------------------------------------------------------------
/Jenkinsfile:
--------------------------------------------------------------------------------
1 | /*
2 | See the documentation for more options:
3 | https://github.com/jenkins-infra/pipeline-library/
4 | */
5 | buildPlugin(
6 | forkCount: '1C', // run this number of tests in parallel for faster feedback. If the number terminates with a 'C', the value will be multiplied by the number of available CPU cores
7 | useContainerAgent: true, // Set to `false` if you need to use Docker for containerized tests
8 | configurations: [
9 | [platform: 'linux', jdk: 21],
10 | [platform: 'windows', jdk: 17],
11 | ])
12 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/action/CloudManagerBuildAction/summary.jelly:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Program: ${it.cmExecution.programId}
6 | Pipeline: ${it.cmExecution.pipelineId}
7 | Execution: ${it.cmExecution.executionId}
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/Messages.properties:
--------------------------------------------------------------------------------
1 | ApprovePipelineStep.displayName=Adobe Cloud Manager Advance Pipeline
2 | ApprovePipelineStep.error.invalidAction=Found action [{0}] which is not a known advance action.
3 | PipelineEndStep.displayName=Adobe Cloud Manager Pipeline End
4 | PipelineStepStateStep.displayName=Adobe Cloud Manager Pipeline Step State
5 | PipelineStepStateStep.failure.approveAndNoWait=Invalid state - cannot set 'autoApprove = true' and 'waitingPause = false'
6 | PollPipelineStep.displayName=Poll Adobe Cloud Manager Pipeline
7 |
8 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PipelineEndStep/help.properties:
--------------------------------------------------------------------------------
1 | help.text=This step will wait for an event from Adobe IO indicating that this pipeline has finished. \
2 |
\
3 | This step requires a block until this issue is resolved. \
4 |
\
5 | Note: Do not use this step with an empty block. If you do not provide any mechanism to pause the pipeline inside this step's block, and do not set emtpy to true, an infinite waiting loop will occur.
6 |
7 |
--------------------------------------------------------------------------------
/doc/action/pipeline-waiting/README.md:
--------------------------------------------------------------------------------
1 | # Cloud Manager Pipeline Waiting Action
2 |
3 | When a [Pipeline Step State step](/doc/step/pipeline-step-state) receives an event that indicates the remote Cloud Manager pipeline is waiting, a waiting action is added to the current Jenkins build.
4 |
5 | This action will allow teams to approve the Cloud Manager build from the Jenkins job.
6 |
7 | A link to the approval page is available on the build side panel, when this action has paused a pipeline:
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/execution/PipelineStepStateExecution/approval.jelly:
--------------------------------------------------------------------------------
1 |
2 |
3 | ${%prompt}
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/execution/PipelineStepStateExecution/codeQuality.jelly:
--------------------------------------------------------------------------------
1 |
2 |
3 | ${%prompt}
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/webhook/subscriber/Messages.properties:
--------------------------------------------------------------------------------
1 | CloudManagerEventSubscriber.error.createApi=Unable to process event subscription, could not create Cloud Manager API client.
2 | CloudManagerEventSubscriber.error.notifyExecution=Error occurred when notifying execution of event: {0}.
3 | CloudManagerEventSubscriber.error.api=Error occurred invoking Cloud Manager API: {0}.
4 |
5 | PipelineStartEventSubscriber.debug.notified=Notified {0} PipelineStartTriggers of start event [{1}].
6 | PipelineStepEventSubscriber.warn.invalidStepState=Could not find type for step state: {0}.
7 |
8 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/AdvancePipelineStep/help.properties:
--------------------------------------------------------------------------------
1 | help.text=This step will advance a Cloud Manager Pipeline. The pipeline execution must be \
2 | in the context, via use of acmStartPipeline step or remote event. \
3 |
\
4 | If no actions are specified, it will advance the pipeline of whichever waiting state it is in. \
5 | If this is not desired, specify a particular build action. \
6 |
\
7 | If the pipeline is not in one of the configured actions, this step will fail. If a non-waiting action is configured, \
8 | this step will fail.
9 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/action/PipelineWaitingAction/index.jelly:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/doc/action/cloud-manager-build/README.md:
--------------------------------------------------------------------------------
1 | # Cloud Manager Build Action
2 |
3 | When either the [Pipeline Start Builder](/doc/builder/start-pipeline/README.md) or the [Pipeline Start Trigger](/doc/trigger/start-pipeline/README.md) are used, the Cloud Manager pipeline execution details are stored on the Jenkins build.
4 |
5 | Future steps require this information to determine if they are interested in WebHook events, or use it to make API calls for state observation.
6 |
7 | A link to the build information is available on the build side panel:
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/test/resources/events/pipeline-ended.json:
--------------------------------------------------------------------------------
1 | {
2 | "event_id": "1",
3 | "event": {
4 | "@id": "1",
5 | "@type": "https://ns.adobe.com/experience/cloudmanager/event/ended",
6 | "xdmEventEnvelope:objectType": "https://ns.adobe.com/experience/cloudmanager/pipeline-execution",
7 | "activitystreams:published": "",
8 | "activitystreams:to": {
9 | "xdmImsOrg:id": "1234567890@AdobeOrg",
10 | "@type": "xdmImsOrg"
11 | },
12 | "activitystreams:object": {
13 | "@id": "https://cloudmanager.adobe.io/api/program/1/pipeline/2/execution/3",
14 | "@type": "https://ns.adobe.com/experience/cloudmanager/pipeline-execution"
15 | }
16 | }
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/src/test/resources/events/step-ended.json:
--------------------------------------------------------------------------------
1 | {
2 | "event_id": "1",
3 | "event": {
4 | "@id": "1",
5 | "@type": "https://ns.adobe.com/experience/cloudmanager/event/ended",
6 | "xdmEventEnvelope:objectType": "https://ns.adobe.com/experience/cloudmanager/execution-step-state",
7 | "activitystreams:published": "",
8 | "activitystreams:to": {
9 | "xdmImsOrg:id": "1234567890@AdobeOrg",
10 | "@type": "xdmImsOrg"
11 | },
12 | "activitystreams:object": {
13 | "@id": "https://cloudmanager.adobe.io/api/program/1/pipeline/2/execution/3/phase/4/step/7",
14 | "@type": "https://ns.adobe.com/experience/cloudmanager/execution-step-state"
15 | }
16 | }
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/src/test/resources/events/step-started.json:
--------------------------------------------------------------------------------
1 | {
2 | "event_id": "1",
3 | "event": {
4 | "@id": "1",
5 | "@type": "https://ns.adobe.com/experience/cloudmanager/event/started",
6 | "xdmEventEnvelope:objectType": "https://ns.adobe.com/experience/cloudmanager/execution-step-state",
7 | "activitystreams:published": "",
8 | "activitystreams:to": {
9 | "xdmImsOrg:id": "1234567890@AdobeOrg",
10 | "@type": "xdmImsOrg"
11 | },
12 | "activitystreams:object": {
13 | "@id": "https://cloudmanager.adobe.io/api/program/1/pipeline/2/execution/3/phase/4/step/5",
14 | "@type": "https://ns.adobe.com/experience/cloudmanager/execution-step-state"
15 | }
16 | }
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/src/test/resources/events/step-waiting.json:
--------------------------------------------------------------------------------
1 | {
2 | "event_id": "1",
3 | "event": {
4 | "@id": "1",
5 | "@type": "https://ns.adobe.com/experience/cloudmanager/event/waiting",
6 | "xdmEventEnvelope:objectType": "https://ns.adobe.com/experience/cloudmanager/execution-step-state",
7 | "activitystreams:published": "",
8 | "activitystreams:to": {
9 | "xdmImsOrg:id": "1234567890@AdobeOrg",
10 | "@type": "xdmImsOrg"
11 | },
12 | "activitystreams:object": {
13 | "@id": "https://cloudmanager.adobe.io/api/program/1/pipeline/2/execution/3/phase/4/step/6",
14 | "@type": "https://ns.adobe.com/experience/cloudmanager/execution-step-state"
15 | }
16 | }
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/src/test/resources/events/pipeline-started.json:
--------------------------------------------------------------------------------
1 | {
2 | "event_id": "1",
3 | "event": {
4 | "@id": "1",
5 | "@type": "https://ns.adobe.com/experience/cloudmanager/event/started",
6 | "xdmEventEnvelope:objectType": "https://ns.adobe.com/experience/cloudmanager/pipeline-execution",
7 | "activitystreams:published": "2021-05-20T22:45:21.090Z",
8 | "activitystreams:to": {
9 | "xdmImsOrg:id": "1234567890@AdobeOrg",
10 | "@type": "xdmImsOrg"
11 | },
12 | "activitystreams:object": {
13 | "@id": "https://cloudmanager.adobe.io/api/program/1/pipeline/2/execution/3",
14 | "@type": "https://ns.adobe.com/experience/cloudmanager/pipeline-execution"
15 | }
16 | }
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/.github/workflows/jenkins-security-scan.yml:
--------------------------------------------------------------------------------
1 | name: Jenkins Security Scan
2 | on:
3 | push:
4 | branches:
5 | - "master"
6 | pull_request:
7 | types: [ opened, synchronize, reopened ]
8 | workflow_dispatch:
9 |
10 | permissions:
11 | security-events: write
12 | contents: read
13 | actions: read
14 |
15 | jobs:
16 | security-scan:
17 | uses: jenkins-infra/jenkins-security-scan/.github/workflows/jenkins-security-scan.yaml@v2
18 | with:
19 | java-cache: 'maven' # Optionally enable use of a build dependency cache. Specify 'maven' or 'gradle' as appropriate.
20 | # java-version: 21 # Optionally specify what version of Java to set up for the build, or remove to use a recent default.
21 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PipelineStepStateStep/help.properties:
--------------------------------------------------------------------------------
1 | help.text=This step will wait for an event from Adobe IO step events. \
2 |
\
3 | If the event is a simple occurrence of a step gate, it will be logged to the build console. \
4 |
\
5 | By default, any waiting event will pause the pipeline unless autoApprove is true. Advancing the pipeline requires uer interaction or a remote event. If waitingPause is set to true, then the pipeline will not pause. See the GitHub documentation for more details on use.
6 |
--------------------------------------------------------------------------------
/src/test/resources/mockserver.properties:
--------------------------------------------------------------------------------
1 | ###
2 | # #%L
3 | # Adobe Cloud Manager Client Library
4 | # %%
5 | # Copyright (C) 2020 - 2021 Adobe Inc.
6 | # %%
7 | # Licensed under the Apache License, Version 2.0 (the "License");
8 | # you may not use this file except in compliance with the License.
9 | # You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing, software
14 | # distributed under the License is distributed on an "AS IS" BASIS,
15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | # See the License for the specific language governing permissions and
17 | # limitations under the License.
18 | # #L%
19 | ###
20 | mockserver.logLevel=WARN
21 |
--------------------------------------------------------------------------------
/doc/step/poll-pipeline/README.md:
--------------------------------------------------------------------------------
1 | # Poll Pipeline Step
2 |
3 | This step will poll the Adobe Cloud Manager API, monitoring for a pipeline for completion.
4 |
5 | **Note**: *This feature requires that either a [Pipeline Start Trigger](/doc/trigger/start-pipeline/README.md) or a [Pipeline Start Builder](/doc/builder/start-pipeline/README.md) is defined earlier in the pipeline.*
6 |
7 | ## Usage
8 |
9 | Syntax:
10 |
11 | ```
12 | acmPollPipeline(
13 | recurrencePeriod: 300000,
14 | quiet: true
15 | )
16 | ```
17 |
18 | ### Optional Properties
19 |
20 | * `recurrencePeriod`: The time to wait between polling events, in milliseconds
21 | * Default: 5 minutes
22 | * Minimum: 30 seconds
23 | * Maximum: 15 minutes
24 | * `quiet`: Flag to indicate whether or not to log each polling event. Default *false*
25 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/trigger/Messages.properties:
--------------------------------------------------------------------------------
1 | PipelineStartTrigger.error.missingAioProject=Missing AIO Project for name: {0}.
2 | PipelineStartTrigger.error.missingProgram=Could not find program: {0}.
3 | PipelineStartTrigger.error.missingPipeline=Could not find pipeline: {0}.
4 | PipelineStartTrigger.warn.invalidJob=Trigger configured with a Job that can not be scheduled: {0}.
5 | PipelineStartTrigger.debug.lookupProgramId=Pipeline was configured with a Program name [{0}], looking up the ID via API.
6 | PipelineStartTrigger.debug.lookupPipelineId=Pipeline was configured with a Pipeline name [{0}], looking up the ID via API.
7 | PipelineStartTrigger.debug.startJob=Starting job from event [{0}].
8 |
9 | CMPipelineStartCause.shortDescription=Started by AdobeIO Cloud Manager event: {0}.
10 |
--------------------------------------------------------------------------------
/src/test/resources/io/jenkins/plugins/adobe/cloudmanager/config/configuration-as-code.yaml:
--------------------------------------------------------------------------------
1 | unclassified:
2 |
3 | adobeioconfig:
4 | projectConfigs:
5 | - name: "Test Project 1"
6 | clientId: "Client Id 1"
7 | imsOrganizationId: "Ims Organization Id 1"
8 | technicalAccountId: "Technical Account Id 1"
9 | clientSecretCredentialsId: "Client Secret Credentials Id 1"
10 | privateKeyCredentialsId: "Private Key Credentials Id 1"
11 | - name: "Test Project 2"
12 | apiUrl: "http://notdefault.adobe.io/url"
13 | clientId: "Client Id 2"
14 | imsOrganizationId: "Ims Organization Id 2"
15 | technicalAccountId: "Technical Account Id 2"
16 | clientSecretCredentialsId: "Client Secret Credentials Id 2"
17 | privateKeyCredentialsId: "Private Key Credentials Id 2"
18 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PollPipelineStep/help.properties:
--------------------------------------------------------------------------------
1 | help.text=Periodically checks whether or not a Cloud Manager pipeline execution has completed. The pipeline execution must be \
2 | in the context, via use of acmStartPipeline step or remote event. \
3 | Checks will be made every period as specified by the recurrence period property. \
4 |
\
5 | Default pause between checks is 5 minutes. A check will be made immediately upon this step's declaration in case the \
6 | execution has completed. \
7 |
\
8 | There is expiration limit for the checks, as long as the Cloud Manager API indicates that the execution has not ended, \
9 | this will continue to check its status. \
10 |
\
11 | Any errors that arise in underlying checks will immediately terminate this step.
12 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/action/Messages.properties:
--------------------------------------------------------------------------------
1 | CloudManagerBuildAction.warn.unknownStep=Log download requested for an unknown step or one that doesn't have logs.
2 | CloudManagerBuildAction.error.downloadLogs.creatApi=Unable to create API for log download. Check logs for details.
3 | CloudManagerBuildAction.error.downloadLogs=An error occurred while attempting to download the requested step logs: {0}
4 |
5 | PipelineWaitingAction.displayName=User action required.
6 | PipelineWaitingAction.error.loadState=Unable to load the execution state.
7 | PipelineWaitingAction.warn.missingExecution=No execution found for run: ({0}).
8 | PipelineWaitingAction.warn.lostExecutions=Some execution ids not restored from run: ({0}).
9 | PipelineWaitingAction.error.loadExecutions=An error occurred during loading of executions {0}.
10 |
11 | PipelineStepDecisionAction.displayName=User {0} {1} build step action {2}.
12 | CloudManagerBuildAction.PipelineStep.status=Reached action [{0}] with status [{1}]
13 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Ahmed Musallam
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/doc/builder/start-pipeline/README.md:
--------------------------------------------------------------------------------
1 | # Start Pipeline Builder
2 |
3 | This builder will start the specified Adobe Cloud Manager pipeline.
4 |
5 | ## Usage
6 |
7 | This can be used as either a Builder via the UI or a Step in a Pipeline definition.
8 |
9 | ### Builder
10 |
11 | Configure the build step as part of the job. Selecting the Adobe IO Configuration will populate the Programs available. Selection of a program will display the available pipelines.
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | ### Step
20 |
21 | Syntax
22 |
23 | ```
24 | acmStartPipeline(
25 | aioProject: 'AIO Project',
26 | program: 'Program Name',
27 | pipeline: 'Pipeline Name'
28 | )
29 | ```
30 |
31 | #### Properties
32 |
33 | * `aioProject`: The name of the Adobe IO Project configuration as specified in the Jenkins Global settings
34 | * `program`: A reference to the Program context for the Pipeline.
35 | * This value can be specified as a name or id of the Program
36 | * `pipeline`: The pipeline in the program that will trigger this Jenkins pipeline.
37 | * This value can be specified as a name or id of the Program
38 |
--------------------------------------------------------------------------------
/doc/trigger/start-pipeline/README.md:
--------------------------------------------------------------------------------
1 | # Pipeline Start Trigger
2 |
3 | This is a Pipeline trigger which will start the Jenkins pipeline when an Adobe IO event is received that corresponds to the configuration. When the configured pipeline is started in Cloud Manager, it will start the *this* Jenkins pipeline.
4 |
5 | **Note**: *This feature requires that the [Adobe IO Webhook](/README.md#adobeio-webhook) is enabled.*
6 |
7 | ## Usage
8 |
9 | This configuration is to configure a Pipeline, therefore it is used in the `properties` section.
10 |
11 | Syntax
12 |
13 | ```
14 | properties([
15 | pipelineTriggers([
16 | acmPipelineStart(aioProject: 'AIO Project', program: 'Program Name', pipeline: 'Pipeline Name')
17 | ])
18 | ])
19 |
20 | ```
21 |
22 | ### Properties
23 |
24 | * `aioProject`: The name of the Adobe IO Project configuration as specified in the Jenkins Global settings
25 | * `program`: A reference to the Program context for the Pipeline.
26 | * This value can be specified as a name or id of the Program
27 | * `pipeline`: The pipeline in the program that will trigger this Jenkins pipeline.
28 | * This value can be specified as a name or id of the Program
29 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ### Java ###
2 | *.class
3 |
4 | # Mobile Tools for Java (J2ME)
5 | .mtj.tmp/
6 |
7 | # Package Files #
8 | *.jar
9 | *.war
10 | *.ear
11 |
12 | # exclude jar for gradle wrapper
13 | !gradle/wrapper/*.jar
14 |
15 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
16 | hs_err_pid*
17 |
18 |
19 | # OS Files
20 | .DS_Store
21 |
22 | ### Maven ###
23 | target/
24 | pom.xml.tag
25 | pom.xml.releaseBackup
26 | pom.xml.versionsBackup
27 | pom.xml.next
28 | release.properties
29 | dependency-reduced-pom.xml
30 | buildNumber.properties
31 | .mvn/timing.properties
32 |
33 | ### IntelliJ ###
34 | .idea/
35 | *.iml
36 |
37 | ### Eclipse ###
38 | *.pydevproject
39 | .metadata
40 | .gradle
41 | bin/
42 | tmp/
43 | *.tmp
44 | *.bak
45 | *.swp
46 | *~.nib
47 | local.properties
48 | .settings/
49 | .loadpath
50 |
51 | # Eclipse Core
52 | .project
53 |
54 | # External tool builders
55 | .externalToolBuilders/
56 |
57 | # Locally stored "Eclipse launch configurations"
58 | *.launch
59 |
60 | # Tests
61 | coverage/
62 | reports/
63 |
64 | # Jenkins local runs
65 | work/
66 | *.log
67 |
68 | # JEnv
69 | .java-version
70 |
71 | .DS_Store
72 | *.dylib
73 |
--------------------------------------------------------------------------------
/doc/builder/repository-sync/README.md:
--------------------------------------------------------------------------------
1 | # Repository Sync Builder
2 |
3 | This builder allows a pipeline to synchronize the current repository of the build process to the specified Cloud Manager Git repository.
4 |
5 | ## Usage
6 |
7 | Syntax:
8 |
9 | ```
10 | acmRepoSync(
11 | credentialsId: 'cm-git-credentials',
12 | url: 'https://git.cloudmanager.adobe.com/dummy/repo/',
13 | force: true
14 | )
15 | ```
16 |
17 | ### Required properties:
18 |
19 | * `url`: The URL of the Cloud Manager repository
20 | * `credentialsId`: The a reference to credentials for Cloud Manager git Authentication.
21 |
22 | ### Optional Properties
23 |
24 | * `force`: Whether or not to force the update.
25 | * **NOTE**: *This will overwrite everything in the Cloud Manager repository*
26 |
27 | ## Notes
28 |
29 | ### Pipelines
30 |
31 | A Git repository does not need to be specified when this step is used in the context of Pipeline as Code project.
32 |
33 | ### Multiple Gits
34 |
35 | If a project has multiple Git SCMs defined, the first one found will be used as the source repository.
36 |
37 | ### Missing Source
38 |
39 | If the build does not have any Git SCMs configured, this step will fail the build.
40 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/webhook/Messages.properties:
--------------------------------------------------------------------------------
1 | CloudManagerWebHook.error.missingAIOProject=Missing Adobe IO Project for IMS Org after receiving event: {0}.
2 |
3 | CMEventPayload.PayloadHandler.warn.unknownContentType=Unknown request body content type: {0}.
4 | CMEventPayload.PayloadHandler.trace.payload=Adobe IO Event Payload was: {0}
5 | CMEventPayload.PayloadHandler.warn.missingChallengeParameter=Request was missing challenge parameter.
6 | CMEventPayload.PayloadHandler.warn.eventParse=Unable to parse event from body, invalid or incomplete: {0}.
7 | CMEventPayload.PayloadHandler.warn.io=Unable to read request body: {0}.
8 |
9 | RequireCMEventPayload.Processor.warn.webhookDisabled=Adobe Cloud Manager Webhook is currently disabled, but received a request.
10 | RequireCMEventPayload.Processor.error.invalidArgs=Adobe Cloud Manager Webhook takes [(CMEvent) event] only.
11 | RequireCMEventPayload.Processor.error.missingBody=Adobe Cloud Manager Webhook requires a payload.
12 | RequireCMEventPayload.Processor.error.missingSignature=Adobe Cloud Manager Webhook requires valid, signed payload.
13 | RequireCMEventPayload.Processor.error.missingAIOProject=Adobe IO Webhook called, but no valid Adobe IO Projects found..
14 | RequireCMEventPayload.Processor.warn.signatureValidationError=An error occurred when attempting to validate a signature: {0}
15 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/config/AdobeIOProjectConfig/help-name.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 | ${%help.text}
30 |
31 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/config/AdobeIOProjectConfig/help-apiUrl.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 | ${%help.text}
30 |
31 |
--------------------------------------------------------------------------------
/src/test/java/io/jenkins/plugins/adobe/cloudmanager/test/RestartTest.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.test;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | public interface RestartTest {
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/builder/RepositorySyncBuilder/help-force.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 | ${%help.text}
30 |
31 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PollPipelineStep/help.jelly:
--------------------------------------------------------------------------------
1 |
26 |
27 |
28 |
29 | ${%help.text}
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/main/resources/index.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
30 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/AdvancePipelineStep/help.jelly:
--------------------------------------------------------------------------------
1 |
26 |
27 |
28 |
29 | ${%help.text}
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PipelineEndStep/help-empty.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 | ${%help.text}
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PipelineEndStep/help-mirror.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 | ${%help.text}
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PipelineStepStateStep/help.jelly:
--------------------------------------------------------------------------------
1 |
26 |
27 |
28 |
29 | ${%help.text}
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PollPipelineStep/help-quiet.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 | ${%help.text}
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PollPipelineStep/help-recurrencePeriod.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 | ${%help.text}
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/AdvancePipelineStep/help-actions.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 | ${%help.text}
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PipelineStepStateStep/help-actions.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 | ${%help.text}
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PipelineStepStateStep/help-advance.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 | ${%help.text}
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PipelineStepStateStep/help-autoAdvance.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 | ${%help.text}
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PipelineStepStateStep/help-waitingPause.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 | ${%help.text}
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/trigger/PipelineStartTrigger/help.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 | ${%help.text}
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PipelineEndStep/help.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 | ${%help.text}
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/config/AdobeIOProjectConfig/help.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 | ${%help.text}
30 |
31 | Adobe IO Console
32 |
33 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/builder/CloudManagerBuilder/config-program.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/builder/CloudManagerBuilder/config-aioProject.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/builder/CloudManagerBuilder/config-pipeline.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/config/AdobeIOConfig/help-webhookEnabled.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 | ${%help.text}
30 |
31 | Adobe IO WebHooks
32 |
33 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/builder/RepositorySyncBuilder/help.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 | ${%description}
30 |
31 | ${%help.text}
32 |
33 | ${%link.text}
34 |
35 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PipelineEndStep/config.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PollPipelineStep/config.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/trigger/CMPipelineStartCause.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.trigger;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import hudson.model.Cause;
30 | import lombok.Value;
31 |
32 | @Value
33 | public class CMPipelineStartCause extends Cause {
34 |
35 | String eventId;
36 |
37 | @Override
38 | public String getShortDescription() {
39 | return Messages.CMPipelineStartCause_shortDescription(eventId);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/webhook/CMEvent.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.webhook;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import io.adobe.cloudmanager.event.CloudManagerEvent;
30 | import lombok.Value;
31 |
32 | /**
33 | * A Cloud Manager Event received from a WebHook call. Helper for validation essentially.
34 | */
35 | @Value
36 | public class CMEvent {
37 | CloudManagerEvent.EventType eventType;
38 | String imsOrg;
39 | String payload;
40 | }
41 |
--------------------------------------------------------------------------------
/doc/step/advance-pipeline/README.md:
--------------------------------------------------------------------------------
1 | # Advance Pipeline Step
2 |
3 | [cloud-manager-events]: https://www.adobe.io/apis/experiencecloud/cloud-manager/docs.html#!AdobeDocs/cloudmanager-api-docs/master/receiving-events.md
4 |
5 | This step will advance the Cloud Manager pipeline. That pipeline must be in the proper state based on the actions specified in the step configuration. If the Cloud Manager pipeline is not in a valid state for advancing, then this step will fail the build.
6 |
7 | **Note**: *This feature requires that either a [Pipeline Start Trigger](/doc/trigger/start-pipeline/README.md) or a [Pipeline Start Builder](/doc/builder/start-pipeline/README.md) is defined earlier in the pipeline.*
8 |
9 | ## Usage
10 |
11 | Syntax:
12 |
13 | ```
14 | acmAdvancePipeline(
15 | actions: ['codeQuality', 'approval']
16 | )
17 | ```
18 |
19 | ### Optional Properties
20 |
21 | * `actions`: Optional list of [actions][cloud-manager-events] to which this step will respond.
22 | * An empty list constitutes all actions.
23 | * At this time only two values are valid: *codeQuality* and *approval*
24 |
25 | ## Use Cases
26 |
27 | ### Advance Pipeline After Pause
28 |
29 | The intent of this step is to be used in combination with a `acmPipelineStepState` step where the Cloud Manager Pipeline has paused, and offline actions are necessary before advancing the remote Pipeline.
30 |
31 | For example: Wait for the Cloud Manager pipeline to reach the Approval step, allowing for out-of-band operations such as performance or load testing using third party tools. Once those are successful advance the pipeline.
32 |
33 | ```
34 | acmPipelineStepState(actions: ['approval'], waitingPause: false)
35 | ...
36 | // Do other actions here
37 | ...
38 | acmAdvancePipeline(actions: ['approval'])
39 | ```
40 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/trigger/PipelineStartTrigger/config.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/trigger/PipelineStartEvent.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.trigger;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import java.time.OffsetDateTime;
30 |
31 | import lombok.Value;
32 |
33 | /**
34 | * Start event for notifying an Adobe Cloud Manager pipeline as started.
35 | */
36 | @Value
37 | public class PipelineStartEvent {
38 | String aioEventId;
39 | String aioProject;
40 | String programId;
41 | String pipelineId;
42 | String executionId;
43 | OffsetDateTime started;
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/AdvancePipelineStep/config.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 |
31 | Note: There is a display issue with this helper. This list contains more items than are permitted in the context.
32 |
The only valid values are codeQuality or approval.
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/builder/StartPipelineBuilder/config.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/builder/RepositorySyncBuilder/config.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/step/execution/Failure.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.step.execution;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import jenkins.model.CauseOfInterruption;
30 |
31 | /**
32 | * An interruption which occurs due to a Failure of the Cloud Manager pipeline.
33 | */
34 | public class Failure extends CauseOfInterruption {
35 | private static final long serialVersionUID = 1;
36 |
37 | public Failure() {
38 | }
39 |
40 | @Override
41 | public String getShortDescription() {
42 | return Messages.Failure_description();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/doc/step/pipeline-end/README.md:
--------------------------------------------------------------------------------
1 | # Pipeline End Step
2 |
3 | This step will pause a pipeline execution until a [Pipeline Execution Ended Event](https://www.adobe.io/apis/experiencecloud/cloud-manager/docs.html#!AdobeDocs/cloudmanager-api-docs/master/receiving-events.md) is received and processed by the pipeline subscribers, and passed to the executing step.
4 |
5 | **Note**: *This feature requires that the [Adobe IO Webhook](/README.md#adobeio-webhook) is enabled.*
6 |
7 | **Note**: *This feature requires that either a [Pipeline Start Trigger](/doc/trigger/start-pipeline/README.md) or a [Pipeline Start Builder](/doc/builder/start-pipeline/README.md) is defined earlier in the pipeline.*
8 |
9 | ## Usage
10 |
11 | Syntax:
12 |
13 | ```
14 | acmPipelineEnd(mirror: true) {
15 | // some block
16 | }
17 | ```
18 |
19 | This step requires a block until [this issue](https://issues.jenkins.io/browse/JENKINS-65646) is resolved.
20 |
21 | **Note:** *Do not use this step with an empty block. If you do not provide any mechanism to pause the pipeline inside this step's block, and do not set `emtpy` to true, an infinite waiting loop will occur.*
22 |
23 | ### Optional Properties
24 |
25 | * `mirror`: Flag indicating whether or not to mirror the Cloud Manager state to Jenkins. Default: *true*
26 | * When enabled, any Cloud Manager build failures or cancellations will cause this pipeline to reflect a `Failed` state.
27 | * `empty`: Flag indicating whether or not the body of this step is empty. Default: *false*
28 |
29 |
30 | ## Enclosed Pipeline Step State Steps
31 |
32 | When a [Pipeline Step State Step](/doc/step/pipeline-step-state/README.md) is wrapped by this step, when this step receives an event, it will quietly end the wrapped step. Any other steps contained within are ignored and allowed to finish their operations uninterrupted.
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/step/execution/Cancellation.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.step.execution;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import jenkins.model.CauseOfInterruption;
30 |
31 | /**
32 | * An interruption which occurs due to a Cancellation of the Cloud Manager pipeline.
33 | */
34 | public class Cancellation extends CauseOfInterruption {
35 | private static final long serialVersionUID = 1;
36 |
37 | public Cancellation() {
38 | }
39 |
40 | @Override
41 | public String getShortDescription() {
42 | return Messages.Cancellation_description();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/builder/Messages.properties:
--------------------------------------------------------------------------------
1 | CloudManagerBuilder.error.missingAioProject=Missing AIO Project for name: {0}.
2 | CloudManagerBuilder.error.missingProgram=Could not find program: {0}.
3 | CloudManagerBuilder.error.missingPipeline=Could not find pipeline: {0}.
4 | CloudManagerBuilder.error.CloudManagerApiException=An API exception occurred: {0}.
5 | CloudManagerBuilder.debug.lookupProgramId=Pipeline was configured with a Program name [{0}], looking up the ID via API.
6 | CloudManagerBuilder.debug.lookupPipelineId=Pipeline was configured with a Pipeline name [{0}], looking up the ID via API.
7 |
8 | RepositorySyncBuilder.error.missingGitRepository=Workflow run does not contain a git repository.
9 | RepositorySyncBuilder.error.notGitRepo=Project does not use Git as SCM.
10 | RepositorySyncBuilder.error.invalidRunType=Unknown run type, unable to find Git SCM.
11 | RepositorySyncBuilder.warning.multipleScms=Multiple SCMs found, using first ({0})
12 | RepositorySyncBuilder.error.missingGitInfo=Unable to find Git information: Git Branch = {0}; Git Commit = {1}.
13 | RepositorySyncBuilder.error.missingGitCredentials=Git credentials are missing for credentials id: {0}.
14 | RepositorySyncBuilder.error.invalidRemoteRepository=Remote repository was invalid ({0})
15 | RepositorySyncBuilder.error.pushFailed=Push to Cloud Manager remote failed with: {0}
16 |
17 | RepositorySyncBuilder.pushMessage=Pushing changes to Cloud Manager remote ({0})
18 | RepositorySyncBuilder.DescriptorImpl.displayName=Adobe Cloud Manager Repository Sync
19 |
20 | StartPipelineBuilder.error.duplicateBuild=Cloud Manager Build data already exists. No more than one build per run is allowed.
21 | StartPipelineBuilder.displayName=Start Adobe Cloud Manager pipeline
22 | StartPipelineBuilder.started=Start Adobe Cloud Manager Builder - Execution with id {0} started for pipeline {1}.
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/action/CloudManagerBuildAction/index.jelly:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | ${%page.title}
9 |
10 | Program: ${it.cmExecution.programId}
11 |
12 | Pipeline: ${it.cmExecution.pipelineId}
13 |
14 | Execution: ${it.cmExecution.executionId}
15 |
16 |
17 |
${%steps.heading}
18 |
19 |
20 | -
21 | ${step.status}
22 |
23 |
24 |
25 | - ${%logs.text}
26 |
27 |
28 | - ${%qualityResults.text}
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/doc/config/jenkins-credentials/README.md:
--------------------------------------------------------------------------------
1 | # Jenkins Credentials
2 |
3 | This plugin requires that credentials (private key and client secret) be added under a special Jenkins Credentials Domain that is restricted to the host `ims-na1.adobelogin.com`
4 |
5 | ## Create the Domain
6 |
7 | 1. As a Jenkins Admin, navigate to `Manage Jenkins` -> `Manage Credentials` and you should see the default `Jenkins` store listed.
8 | 1. Click the triangle icon next to the `Jenkins` store and click `Add Domain`. (This is tricky, see below screen recording.)
9 | 1. Use any Domain Name. We went with `Adobe IO`
10 | 1. Under `Specifications` section, click `Add` button and choose `hostname`
11 | 1. In the `Include` field, paste the domain `ims-na1.adobelogin.com`
12 | 1. Click `OK` to save.
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | ## Add the Adobe IO Client Secret
21 |
22 | 1. Navigate to the domain we created in the steps above.
23 | 1. Click `Add Credentials`
24 | 1. From the `Kind` dropdown, select `Secret text`
25 | 1. Keep the scope as `Global`
26 | 1. Add the Client Secret from the Adobe IO Project
27 | 1. Give it any ID you like, but it should be something meaningful and representative of the Adobe IO project. (We went with `cm-client-secret`)
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | ## Add the Adobe IO Private Key
36 |
37 | 1. Navigate to the domain we created in the steps above.
38 | 1. Click `Add Credentials`
39 | 1. From the `Kind` dropdown, select `Secret file`
40 | 1. Keep the scope as `Global`
41 | 1. Upload the private key file.
42 | 1. Give it any ID you like, but it should be something meaningful and representative of the Adobe IO project. (We went with `cm-private-key`)
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/PipelineStepStateStep/config.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/webhook/subscriber/CloudManagerSubscriberEvent.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.webhook.subscriber;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import javax.annotation.Nonnull;
30 |
31 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
32 | import io.adobe.cloudmanager.event.CloudManagerEvent;
33 | import lombok.Value;
34 |
35 | /**
36 | * An event which Subscribers can process.
37 | */
38 | @Value
39 | @SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE", justification = "Generated code.")
40 | public class CloudManagerSubscriberEvent {
41 | @Nonnull
42 | String aioProjectName;
43 | @Nonnull
44 | CloudManagerEvent.EventType type;
45 | @Nonnull
46 | String payload;
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/webapp/help.html:
--------------------------------------------------------------------------------
1 |
26 | You must create a new Cloud Manager API Integration in your adobe io console.
27 | Use the following documentation to create a new integration:
28 |
29 | Cloud Manager Documentation
30 |
31 | Once you've created the integration, you'll be able to copy paste the values into this form and test your connection.
32 |
33 |
34 | There also this Adobe IO documentation on creating Service Accounts (if the docs above are not sufficient).
35 |
36 | Adobe IO Documentation for creating a service account
37 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/step/execution/RemoteStateInterruption.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.step.execution;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import io.adobe.cloudmanager.PipelineExecution;
30 | import jenkins.model.CauseOfInterruption;
31 |
32 | /**
33 | * An interruption which occurs due to remote selection, cancellation or otherwise.
34 | */
35 | public class RemoteStateInterruption extends CauseOfInterruption {
36 |
37 | private static final long serialVersionUID = 1L;
38 |
39 | private final PipelineExecution.Status reason;
40 |
41 | public RemoteStateInterruption(PipelineExecution.Status reason) {
42 | this.reason = reason;
43 | }
44 |
45 | @Override
46 | public String getShortDescription() {
47 | return Messages.RemoteStateInterruption_failure_remoteError(reason);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/config/Messages.properties:
--------------------------------------------------------------------------------
1 | AdobeIOProjectConfig.displayName={0} ({1})
2 | AdobeIOProjectConfig.accessToken.description=Current access token for AIO Project: {0}.
3 |
4 | AdobeIOProjectConfig.error.authenticate.unresolvableCredentials=Error while authenticating. requiredOne of the required credentials is missing. Client Secret credentials id: ({0}), Private Key credentials id: ({1}).
5 | AdobeIOProjectConfig.error.credentialsAccess=Error accessing one of the required credentials: {0}
6 | AdobeIOProjectConfig.error.privateKeyError=Unable to read Private Key credential {0}.
7 | AdobeIOProjectConfig.error.authenticationError=Unable to authenticate using Project configuration: {0}.
8 | AdobeIOProjectConfig_warn_checkToken=Exception when checking validity of access token: {0}
9 |
10 | AdobeIOProjectConfig.error.unresolvableCredentialStore=Unable to find the credentials store for storing Access Token.
11 |
12 | AdobeIOProjectConfig.DescriptorImpl.displayName=Adobe IO Project
13 | AdobeIOProjectConfig.DescriptorImpl.error.missingName=Name is required.
14 | AdobeIOProjectConfig.DescriptorImpl.error.missingClientId=Client Id is required.
15 | AdobeIOProjectConfig.DescriptorImpl.error.missingImsOrg=IMS Organization Id is required.
16 | AdobeIOProjectConfig.DescriptorImpl.error.missingTechnicalAccountId=Technical Account Id is required.
17 | AdobeIOProjectConfig.DescriptorImpl.error.missingClientSecret=Client Secret credential is required.
18 | AdobeIOProjectConfig.DescriptorImpl.error.missingPrivateKey=Private Key credential is required.
19 | AdobeIOProjectConfig.DescriptorImpl.warn.doNotUseAddCredentialButton=Do not use the 'Add' button (if present). Refer to plugin docs.
20 |
21 | AdobeIOProjectConfig.DescriptorImpl.error.unresolvableClientSecret=Client Secret Credentials Id ({0}) does not exist.
22 | AdobeIOProjectConfig.DescriptorImpl.error.unresolvablePrivateKey=Private Key Credentials Id ({0}) does not exist.
23 | AdobeIOProjectConfig.DescriptorImpl.error.credentialValidationFailed=Credential verification failed.
24 | AdobeIOProjectConfig.DescriptorImpl.validate.credentialsVerified=Credentials verified for Org: {0}
25 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/CloudManagerPipelineExecution.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import java.io.Serializable;
30 |
31 | import org.apache.commons.lang3.StringUtils;
32 |
33 | import io.adobe.cloudmanager.PipelineExecution;
34 | import lombok.Value;
35 |
36 | /**
37 | * Representation of a Cloud Manager Pipeline Execution. Used to reduce repetition logic.
38 | */
39 | @Value
40 | public class CloudManagerPipelineExecution implements Serializable {
41 |
42 | private static final long serialVersionUID = 1L;
43 |
44 | String programId;
45 | String pipelineId;
46 | String executionId;
47 |
48 | public boolean equalTo(PipelineExecution pipelineExecution) {
49 | return StringUtils.equals(pipelineExecution.getProgramId(), programId) &&
50 | StringUtils.equals(pipelineExecution.getPipelineId(), pipelineId) &&
51 | StringUtils.equals(pipelineExecution.getId(), executionId);
52 |
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/doc/step/pipeline-step-state/README.md:
--------------------------------------------------------------------------------
1 | # Pipeline Step State Step
2 |
3 | [cloud-manager-events]: https://www.adobe.io/apis/experiencecloud/cloud-manager/docs.html#!AdobeDocs/cloudmanager-api-docs/master/receiving-events.md
4 |
5 | This step has two states:
6 | * Pause a pipeline until specific [Pipeline Execution Step Event][cloud-manager-events] has occurred.
7 | * Pause a pipeline and log each [Pipeline Execution Step Event][cloud-manager-events] that occurs.
8 |
9 | **Note**: *This feature requires that the [Adobe IO Webhook](/README.md#adobeio-webhook) is enabled.*
10 |
11 | **Note**: *This feature requires that either a [Pipeline Start Trigger](/doc/trigger/start-pipeline/README.md) or a [Pipeline Start Builder](/doc/builder/start-pipeline/README.md) is defined earlier in the pipeline.*
12 |
13 | ## Usage
14 |
15 | Syntax:
16 |
17 | ```
18 | acmPipelineStepState(
19 | actions: ['codeQuality', 'securityTest', 'productTest', 'uiTest'],
20 | advance: true,
21 | autoApprove: false
22 | )
23 | ```
24 |
25 | ### Optional Properties
26 |
27 | * `actions`: Optional list of [actions][cloud-manager-events] to which this step will respond.
28 | * An empty list constitutes all actions.
29 | * `advance`: Flag to indicate if this step should advance when receiving a *end* action.
30 | * `autoApprove`: Flag to indicate that when a *waiting* event occurs, it should advance the Cloud Manager build.
31 | * `waitingPause`: Flag to indicate if this step should pause the pipeline for user input, when a *waiting* event occurs.
32 | * When using this property, the `advance` property should be set to *true*.
33 |
34 | ## Use Cases
35 |
36 | ### Standalone
37 |
38 | This step can be used directly in a pipeline to wait for a specific Cloud Manager build action step. This will effectively pause the pipeline until the event occurs.
39 |
40 | ```
41 | acmPipelineStepState(actions: ['codeQuality'])
42 | ```
43 |
44 | If you wait to wait for a specific step, but do not want this pipeline to pause for user input, then disable the waiting pause.
45 |
46 | ```
47 | acmPipelineStepState(actions: ['codeQuality'], waitingPause: false)
48 | ```
49 |
50 | ### Pipeline End Step Block
51 |
52 | This step can be used inside of a [Pipeline End Step](/doc/step/pipeline-end/README.md) block. In this context, the Jenkins pipeline will simply log each event as it arrives, advancing or not.
53 |
54 | ```
55 | acamPipelineEnd {
56 | acmPipelineStepState(advance: false)
57 | }
58 | ```
59 |
--------------------------------------------------------------------------------
/doc/config/adobeio-project/README.md:
--------------------------------------------------------------------------------
1 | # Adobe IO Project
2 |
3 | An Adobe IO Project configuration is required for build steps to authenticate to Adobe IO for API calls.
4 |
5 | ## Configure Project
6 |
7 | Configuring a project is done by copying the values from the AIO Console to Jenkins. The example below shows the use of the example Client Secret and Private Key for the configuration.
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | ## Test Connection
16 |
17 | Once the configuration is complete, you can test it with the **Test Connection** button.
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | ## Configuration Details
27 |
28 | ### Enable Webhook
29 |
30 | This is a global property, it toggles whether or not the WebHook will process AdobeIO Events. By default the WebHook is disabled.
31 |
32 | #### Event Validation
33 |
34 | **All requests** received by the WebHook are validated according to the [AdobeIO Documentation](https://www.adobe.io/apis/experienceplatform/events/docs.html#!adobedocs/adobeio-events/master/intro/webhooks_intro.md#authenticating-events). Any event that cannot be validated returns an error; this includes the *Challenge* request.
35 |
36 | This feature can not be disabled.
37 |
38 | #### Enabled
39 |
40 | When enabled, the WebHook to process requests and pass them on to known subscribers. The WebHook endpoint is based on the Jenkins URL, which is found on the Jenkins Global configuration page. The WebHook is registered at:
41 |
42 | `{{Jenkins Url}}/aio-cloud-manager-webhook/`
43 |
44 | #### Disabled
45 |
46 | It is not possible to disable the Webhook Servlet entirely. However, when disabled the WebHook will ignore all requests, logging a warning that a request was received.
47 |
48 | ## Multiple Configurations
49 |
50 | This plugin supports multiple Adobe IO project configurations. Each must have a unique name, and are referenced by this name in step configurations. Simply add a new configuration for each integration needed.
51 |
52 | ### WebHook Handling
53 |
54 | The WebHook will use all available configurations to determine if a received event is valid. The first configuration found that can validate an event will be used as the AIO Project reference for all subscribers.
55 |
56 | Therefore, two configurations with the same credential details but different names can cause event processing to be lost.
57 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/step/execution/Messages.properties:
--------------------------------------------------------------------------------
1 | AbstractStepExecution.error.missingBuildData=Missing Adobe Cloud Manager build data, was the pipeline started?
2 | AbstractStepExecution.error.authentication=Unable to get Access Token, check Jenkins logs for details.
3 |
4 | AdvancePipelineExecution.error.invalidPipelineState=Remote pipeline was not in a state would could be advanced, state was: [{0}].
5 | AdvancePipelineExecution.info.advancingPipeline=Advancing pipeline in action state: [{0}].
6 |
7 | PipelineEndExecution.waiting=Cloud Manager Pipeline End Step - Waiting for an event.
8 | PipelineEndExecution.occurred=Cloud Manager Pipeline End Step - Pipeline Execution [{0}] has ended with state [{1}].
9 |
10 | PipelineStepStateExecution.occurred=Adobe Cloud Manager - Execution [{0}] has reached action [{1}] and with state [{2}].
11 | PipelineStepStateExecution.waiting=Cloud Manager Pipeline Step Execution - Waiting for an event.
12 | PipelineStepStateExecution.autoApprove=Cloud Manager Pipeline Step Execution - Waiting event reached, but auto approve was set. Approving.
13 | PipelineStepStateExecution.unknownStepAction=StepAction [{0}] was unknown, new API value?
14 | PipelineStepStateExecution.unknownWaitingAction=Asked to process Waiting StepAction [{0}], but not one supported at this time.
15 | PipelineStepStateExecution.endQuietly=Step ending by request, quietly.
16 | PipelineStepStateExecution.approvedBy=Step was approved by {0}.
17 | PipelineStepStateExecution.waitingApproval=Approval required.
18 |
19 | PipelineStepStateExecution.failure.processed=This step has already been processed.
20 | PipelineStepStateExecution.failure.buildPermission=You must have Build Job permissions to approve this step.
21 | PipelineStepStateExecution.failure.cancelPermission=You must have Cancel Job permissions to approve this step.
22 |
23 | PipelineStepStateExecution.warn.actionRemoval=Failed to remove action from run context.
24 | PipelineStepStateExecution.warn.endPause=Unable to end the pause action for run.
25 |
26 | PollPipelineExecution.waiting=Cloud Manager Pipeline execution is still running, waiting another {0}.
27 | PollPipelineExecution.complete=Cloud Manager Pipeline execution is complete.
28 | PollPipelineExecution.error.CloudManagerApiException=An API exception occurred: {0}.
29 |
30 | RemoteStateInterruption.failure.remoteError=Cloud Manager event indicated failure status: {0}.
31 |
32 | Cancellation.description=Cancelled by remote event.
33 | Failure.description=Failed due to remote failure.
34 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/config/AdobeIOConfig/config.jelly:
--------------------------------------------------------------------------------
1 |
2 |
27 |
28 |
30 |
40 |
41 |
42 |
43 |
44 |
45 | (${descriptor.webhookUrl})
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/src/test/java/io/jenkins/plugins/adobe/cloudmanager/config/AdobeIOConfigTest.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.config;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import java.util.ArrayList;
30 | import java.util.List;
31 |
32 | import org.junit.Rule;
33 | import org.junit.Test;
34 | import org.jvnet.hudson.test.JenkinsRule;
35 | import static org.junit.Assert.*;
36 |
37 | public class AdobeIOConfigTest {
38 |
39 | @Rule
40 | public JenkinsRule rule = new JenkinsRule();
41 |
42 | @Test
43 | public void configuation() {
44 | AdobeIOConfig config = AdobeIOConfig.configuration();
45 | assertNotNull(config);
46 | assertTrue(config.getProjectConfigs().isEmpty());
47 | }
48 |
49 | @Test
50 | public void projectConfigForName() {
51 |
52 | AdobeIOConfig aio = AdobeIOConfig.configuration();
53 |
54 | List configs;
55 | configs = new ArrayList<>();
56 | AdobeIOProjectConfig found = new AdobeIOProjectConfig();
57 | found.setName("Adobe IO Project");
58 | configs.add(found);
59 |
60 | AdobeIOProjectConfig config = new AdobeIOProjectConfig();
61 | config.setName("Another AdobeIO Project");
62 | configs.add(config);
63 |
64 | aio.setProjectConfigs(configs);
65 |
66 | assertEquals(found, aio.projectConfigFor("Adobe IO Project"));
67 |
68 | assertNull(aio.projectConfigFor("Not Found"));
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/action/PipelineStepDecisionAction.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.action;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import io.adobe.cloudmanager.StepAction;
30 | import lombok.Data;
31 | import org.jenkinsci.plugins.workflow.actions.PersistentAction;
32 | import org.kohsuke.stapler.export.ExportedBean;
33 |
34 | /**
35 | * Action for storing the decision made by a user on a Cloud Manager build step.
36 | */
37 | @Data
38 | @ExportedBean(defaultVisibility = 1510)
39 | public class PipelineStepDecisionAction implements PersistentAction {
40 |
41 | private final String userId;
42 | private final StepAction step;
43 | private final Decision decision;
44 |
45 | public PipelineStepDecisionAction(String userId, StepAction step, Decision decision) {
46 | this.userId = userId;
47 | this.step = step;
48 | this.decision = decision;
49 | }
50 |
51 | @Override
52 | public String getDisplayName() {
53 | return Messages.PipelineStepDecisionAction_displayName(userId, decision, step);
54 | }
55 |
56 | @Override
57 | public String getIconFileName() {
58 | return null;
59 | }
60 |
61 | @Override
62 | public String getUrlName() {
63 | return null; // Returning null keeps it off the left nav.
64 | }
65 |
66 | /**
67 | * Options for a decision.
68 | */
69 | public enum Decision {
70 | APPROVED, REJECTED
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/main/resources/io/jenkins/plugins/adobe/cloudmanager/config/AdobeIOProjectConfig/config.groovy:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.config.AdobeIOProjectConfig
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import io.jenkins.plugins.adobe.cloudmanager.config.AdobeIOProjectConfig
30 |
31 | def f = namespace(lib.FormTagLib)
32 | def c = namespace(lib.CredentialsTagLib)
33 |
34 | f.entry(title: _("name.title"), field: "name") {
35 | f.textbox()
36 | }
37 |
38 | f.entry(title: _("apiUrl.title"), field: "apiUrl") {
39 | f.textbox(default: AdobeIOProjectConfig.ADOBE_IO_URL)
40 | }
41 |
42 | f.entry(title: _("clientId.title"), field: "clientId") {
43 | f.textbox()
44 | }
45 |
46 | f.entry(title: _("orgId.title"), field: "imsOrganizationId") {
47 | f.textbox()
48 | }
49 |
50 | f.entry(title: _("techAcctId.title"), field: "technicalAccountId") {
51 | f.textbox()
52 | }
53 |
54 | f.entry(title: _("clientSecret.title"), field: "clientSecretCredentialsId") {
55 | c.select(context:app, includeUser:false, expressionAllowed:false)
56 | }
57 |
58 | f.entry(title: _("privateKey.title"), field: "privateKeyCredentialsId") {
59 | c.select(context:app, includeUser:false, expressionAllowed:false)
60 | }
61 |
62 | f.block() {
63 | f.validateButton(
64 | title: _("validate.title"),
65 | progress: _("progress"),
66 | method: "verifyCredentials",
67 | with: "apiUrl,imsOrganizationId,technicalAccountId,clientId,clientSecretCredentialsId,privateKeyCredentialsId"
68 | )
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/webhook/subscriber/CloudManagerEventSubscriber.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.webhook.subscriber;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import java.util.Set;
30 | import java.util.function.Function;
31 | import java.util.function.Predicate;
32 | import javax.annotation.Nonnull;
33 |
34 | import hudson.ExtensionList;
35 | import hudson.ExtensionPoint;
36 | import io.adobe.cloudmanager.event.CloudManagerEvent;
37 | import jenkins.model.Jenkins;
38 | import org.slf4j.Logger;
39 | import org.slf4j.LoggerFactory;
40 |
41 | /**
42 | * Abstract subscriber for Cloud Manager events. Provides standard logic for looking up concrete extensions.
43 | */
44 | public abstract class CloudManagerEventSubscriber implements ExtensionPoint {
45 |
46 | /**
47 | * Lists of all Cloud Manager Event Subscribers
48 | */
49 | public static ExtensionList all() {
50 | return Jenkins.get().getExtensionList(CloudManagerEventSubscriber.class);
51 | }
52 |
53 | /**
54 | * Predicate for filtering on streams.
55 | */
56 | public static Predicate interested(final CloudManagerEvent.EventType type) {
57 | return (subscriber) -> subscriber.types().contains(type);
58 | }
59 |
60 |
61 | /**
62 | * Function for processing events via streams.
63 | */
64 | public static Function process(final CloudManagerSubscriberEvent event) {
65 | return (subscriber) -> {
66 | subscriber.onEvent(event);
67 | return event;
68 | };
69 | }
70 |
71 | /**
72 | * List of event types that this subscriber can process.
73 | */
74 | @Nonnull
75 | protected abstract Set types();
76 |
77 | /**
78 | * Processes the event.
79 | */
80 | protected abstract void onEvent(final CloudManagerSubscriberEvent event);
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/step/execution/AdvancePipelineExecution.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.step.execution;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import java.util.List;
30 |
31 | import hudson.AbortException;
32 | import io.adobe.cloudmanager.CloudManagerApi;
33 | import io.adobe.cloudmanager.CloudManagerApiException;
34 | import io.adobe.cloudmanager.PipelineExecution;
35 | import io.adobe.cloudmanager.PipelineExecutionStepState;
36 | import io.adobe.cloudmanager.StepAction;
37 | import io.jenkins.plugins.adobe.cloudmanager.CloudManagerPipelineExecution;
38 | import org.jenkinsci.plugins.workflow.steps.StepContext;
39 |
40 | /**
41 | * Execution for a {@link io.jenkins.plugins.adobe.cloudmanager.step.AdvancePipelineStep}, advancing the remote Cloud Manager pipeline.
42 | */
43 | public class AdvancePipelineExecution extends AbstractStepExecution {
44 |
45 | private static final long serialVersionUID = 1L;
46 |
47 | private final List actions;
48 |
49 | public AdvancePipelineExecution(StepContext context, List actions) {
50 | super(context);
51 | this.actions = actions;
52 | }
53 |
54 | @Override
55 | public void doStart() throws Exception {
56 | try {
57 | CloudManagerPipelineExecution build = getBuildData().getCmExecution();
58 | CloudManagerApi api = getApi();
59 | PipelineExecution pe = api.getExecution(build.getProgramId(), build.getPipelineId(), build.getExecutionId());
60 |
61 | PipelineExecutionStepState step = api.getCurrentStep(pe);
62 | StepAction stepAction = StepAction.valueOf(step.getAction());
63 | if (actions.contains(stepAction)) {
64 | getTaskListener().getLogger().println(Messages.AdvancePipelineExecution_info_advancingPipeline(stepAction));
65 | api.advanceExecution(pe);
66 | getContext().onSuccess(null);
67 | } else {
68 | throw new AbortException(Messages.AdvancePipelineExecution_error_invalidPipelineState(stepAction));
69 | }
70 | } catch (CloudManagerApiException e) {
71 | throw new AbortException(e.getLocalizedMessage());
72 | }
73 | }
74 |
75 | @Override
76 | public boolean isAsync() {
77 | return false;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/builder/StartPipelineBuilder.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.builder;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import java.io.IOException;
30 | import java.io.PrintStream;
31 | import javax.annotation.Nonnull;
32 |
33 | import hudson.AbortException;
34 | import hudson.EnvVars;
35 | import hudson.Extension;
36 | import hudson.model.Run;
37 | import hudson.model.TaskListener;
38 | import io.adobe.cloudmanager.CloudManagerApi;
39 | import io.adobe.cloudmanager.CloudManagerApiException;
40 | import io.adobe.cloudmanager.PipelineExecution;
41 | import io.jenkins.plugins.adobe.cloudmanager.CloudManagerPipelineExecution;
42 | import io.jenkins.plugins.adobe.cloudmanager.action.CloudManagerBuildAction;
43 | import org.jenkinsci.Symbol;
44 | import org.kohsuke.stapler.DataBoundConstructor;
45 |
46 | /**
47 | * Starts the specified Cloud Manager pipeline.
48 | */
49 | public class StartPipelineBuilder extends CloudManagerBuilder {
50 |
51 | @DataBoundConstructor
52 | public StartPipelineBuilder() {
53 | }
54 |
55 | @Override
56 | public void perform(@Nonnull Run, ?> run, @Nonnull EnvVars env, @Nonnull TaskListener listener) throws InterruptedException, IOException {
57 | if (run.getAction(CloudManagerBuildAction.class) != null) {
58 | throw new AbortException(Messages.StartPipelineBuilder_error_duplicateBuild());
59 | }
60 |
61 | CloudManagerApi api = createApi();
62 | String programId = getProgramId(api);
63 | String pipelineId = getPipelineId(api, programId);
64 |
65 | try {
66 | PrintStream log = listener.getLogger();
67 | PipelineExecution execution = api.startExecution(programId, pipelineId);
68 | CloudManagerBuildAction data = new CloudManagerBuildAction(getAioProject(), new CloudManagerPipelineExecution(execution.getProgramId(), execution.getPipelineId(), execution.getId()));
69 | run.addAction(data);
70 | log.println(Messages.StartPipelineBuilder_started(execution.getId(), pipeline));
71 | } catch (CloudManagerApiException e) {
72 | throw new AbortException(Messages.CloudManagerBuilder_error_CloudManagerApiException(e.getLocalizedMessage()));
73 | }
74 | }
75 |
76 | // No workspace is necessary to start remote pipeline.
77 | @Override
78 | public boolean requiresWorkspace() {
79 | return false;
80 | }
81 |
82 | @Symbol("acmStartPipeline")
83 | @Extension
84 | public static class DescriptorImpl extends CloudManagerBuilderDescriptor {
85 |
86 | @Nonnull
87 | @Override
88 | public String getDisplayName() {
89 | return Messages.StartPipelineBuilder_displayName();
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/util/CloudManagerApiUtil.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.util;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import java.util.Optional;
30 | import java.util.function.Function;
31 | import javax.annotation.Nonnull;
32 |
33 | import hudson.util.Secret;
34 | import io.adobe.cloudmanager.CloudManagerApi;
35 | import io.adobe.cloudmanager.CloudManagerApiException;
36 | import io.adobe.cloudmanager.Pipeline;
37 | import io.jenkins.plugins.adobe.cloudmanager.config.AdobeIOConfig;
38 | import io.jenkins.plugins.adobe.cloudmanager.config.AdobeIOProjectConfig;
39 | import org.slf4j.Logger;
40 | import org.slf4j.LoggerFactory;
41 |
42 | public class CloudManagerApiUtil {
43 |
44 | private static final Logger LOGGER = LoggerFactory.getLogger(CloudManagerApiUtil.class);
45 |
46 | @Nonnull
47 | public static Function> createApi() {
48 | return (projectName) -> {
49 | AdobeIOProjectConfig aioProject = AdobeIOConfig.projectConfigFor(projectName);
50 | if (aioProject != null) {
51 | Secret token = aioProject.authenticate();
52 | if (token != null) {
53 | return Optional.of(CloudManagerApi.create(aioProject.getImsOrganizationId(), aioProject.getClientId(), token.getPlainText()));
54 | }
55 | } else {
56 | LOGGER.error(Messages.CloudManagerApiUtil_error_missingAioProject(projectName));
57 | }
58 | return Optional.empty();
59 | };
60 | }
61 |
62 | /**
63 | * Get the Program Id for the program by name its name.
64 | */
65 | @Nonnull
66 | public static Optional getProgramId(final CloudManagerApi api, final String programName) {
67 | try {
68 | return api.listPrograms()
69 | .stream()
70 | .filter(p -> programName.equals(p.getName()))
71 | .map(p -> p.getId())
72 | .findFirst();
73 | } catch (CloudManagerApiException ex) {
74 | LOGGER.error(Messages.CloudManagerApiUtil_error_CloudManagerApiException(ex.getLocalizedMessage()));
75 | return Optional.empty();
76 | }
77 | }
78 |
79 | /**
80 | * Get the Program Id for the pipeline by name its name.
81 | */
82 | @Nonnull
83 | public static Optional getPipelineId(final CloudManagerApi api, final String programId, final String pipelineName) {
84 | try {
85 | return api.listPipelines(programId, new Pipeline.NamePredicate(pipelineName))
86 | .stream()
87 | .map(p -> p.getId())
88 | .findFirst();
89 | } catch (CloudManagerApiException ex) {
90 | LOGGER.error(Messages.CloudManagerApiUtil_error_CloudManagerApiException(ex.getLocalizedMessage()));
91 | return Optional.empty();
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/webhook/subscriber/PipelineEndEventSubscriber.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.webhook.subscriber;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import java.io.IOException;
30 | import java.util.Collections;
31 | import java.util.Optional;
32 | import java.util.Set;
33 | import javax.annotation.Nonnull;
34 |
35 | import hudson.Extension;
36 | import io.adobe.cloudmanager.CloudManagerApi;
37 | import io.adobe.cloudmanager.CloudManagerApiException;
38 | import io.adobe.cloudmanager.PipelineExecution;
39 | import io.adobe.cloudmanager.event.CloudManagerEvent;
40 | import io.adobe.cloudmanager.event.PipelineExecutionEndEvent;
41 | import io.jenkins.plugins.adobe.cloudmanager.step.execution.PipelineEndExecution;
42 | import io.jenkins.plugins.adobe.cloudmanager.util.CloudManagerApiUtil;
43 | import org.jenkinsci.plugins.workflow.steps.StepExecution;
44 | import org.slf4j.Logger;
45 | import org.slf4j.LoggerFactory;
46 | import static io.adobe.cloudmanager.event.CloudManagerEvent.EventType.*;
47 |
48 | /**
49 | * Subscriber for Cloud Manager pipeline execution end events.
50 | */
51 | @Extension
52 | public class PipelineEndEventSubscriber extends CloudManagerEventSubscriber {
53 |
54 | private static final Logger LOGGER = LoggerFactory.getLogger(PipelineEndEventSubscriber.class);
55 | private static final Set EVENTS = Collections.singleton(PIPELINE_ENDED);
56 |
57 | @Nonnull
58 | @Override
59 | protected Set types() {
60 | return EVENTS;
61 | }
62 |
63 | /**
64 | * Calls all {@link io.jenkins.plugins.adobe.cloudmanager.step.PipelineEndStep} instances waiting for an event.
65 | */
66 | @Override
67 | protected void onEvent(CloudManagerSubscriberEvent event) {
68 | Optional api = CloudManagerApiUtil.createApi().apply(event.getAioProjectName());
69 | if (!api.isPresent()) {
70 | LOGGER.error(Messages.CloudManagerEventSubscriber_error_createApi());
71 | return;
72 | }
73 | try {
74 | final PipelineExecution pe = api.get().getExecution(CloudManagerEvent.parseEvent(event.getPayload(), PipelineExecutionEndEvent.class));
75 | StepExecution.applyAll(PipelineEndExecution.class, (execution) -> {
76 | try {
77 | if (execution.isApplicable(pe) && !execution.isFinished()) {
78 | execution.occurred(pe);
79 | }
80 | } catch (IOException | InterruptedException ex) {
81 | LOGGER.error(Messages.CloudManagerEventSubscriber_error_notifyExecution(ex.getLocalizedMessage()));
82 | }
83 | return null;
84 | });
85 | } catch (CloudManagerApiException e) {
86 | LOGGER.error(Messages.CloudManagerEventSubscriber_error_api(e.getLocalizedMessage()));
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/step/AdvancePipelineStep.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.step;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import java.util.ArrayList;
30 | import java.util.Arrays;
31 | import java.util.Collections;
32 | import java.util.HashSet;
33 | import java.util.List;
34 | import java.util.Set;
35 | import javax.annotation.Nonnull;
36 |
37 | import hudson.AbortException;
38 | import hudson.Extension;
39 | import hudson.model.Run;
40 | import hudson.model.TaskListener;
41 | import io.adobe.cloudmanager.StepAction;
42 | import io.jenkins.plugins.adobe.cloudmanager.step.execution.AdvancePipelineExecution;
43 | import org.jenkinsci.plugins.workflow.steps.Step;
44 | import org.jenkinsci.plugins.workflow.steps.StepContext;
45 | import org.jenkinsci.plugins.workflow.steps.StepDescriptor;
46 | import org.jenkinsci.plugins.workflow.steps.StepExecution;
47 | import org.kohsuke.stapler.DataBoundConstructor;
48 | import org.kohsuke.stapler.DataBoundSetter;
49 |
50 | /**
51 | * {@link Step} which will advance the current Cloud Manager pipeline execution in Cloud Manager Build context
52 | *
53 | * By default it will advance the Pipeline regardless of the current state. To narrow the scope, specify the {@code action} context.
54 | */
55 | public class AdvancePipelineStep extends Step {
56 | private static final List ALLOWED_ACTIONS = Arrays.asList(StepAction.codeQuality, StepAction.approval);
57 |
58 | private List actions = new ArrayList<>(ALLOWED_ACTIONS);;
59 |
60 | @DataBoundConstructor
61 | public AdvancePipelineStep() {
62 |
63 | }
64 |
65 | /**
66 | * List of actions to which this Step will respond. Default: {@code codeQuality} and {@code approval} actions.
67 | */
68 | @Nonnull
69 | public List getActions() {
70 | return actions;
71 | }
72 |
73 | @DataBoundSetter
74 | public void setActions(List actions) {
75 | if (actions != null && !actions.isEmpty()) {
76 | this.actions = actions;
77 | }
78 | }
79 |
80 | @Override
81 | public StepExecution start(StepContext context) throws Exception {
82 | for (StepAction action : actions) {
83 | if (!ALLOWED_ACTIONS.contains(action)) {
84 | throw new AbortException(Messages.ApprovePipelineStep_error_invalidAction(action));
85 | }
86 | }
87 | return new AdvancePipelineExecution(context, actions);
88 | }
89 |
90 | @Extension
91 | public static final class DescriptorImpl extends StepDescriptor {
92 | @Override
93 | public String getFunctionName() {
94 | return "acmAdvancePipeline";
95 | }
96 |
97 | @Override
98 | public Set extends Class>> getRequiredContext() {
99 | return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(Run.class, TaskListener.class)));
100 | }
101 |
102 | @Nonnull
103 | @Override
104 | public String getDisplayName() {
105 | return Messages.ApprovePipelineStep_displayName();
106 | }
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/util/DescriptorHelper.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.util;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import java.util.Collection;
30 | import java.util.Collections;
31 | import java.util.Optional;
32 | import javax.annotation.Nonnull;
33 |
34 | import org.apache.commons.lang3.StringUtils;
35 |
36 | import hudson.util.ListBoxModel;
37 | import io.adobe.cloudmanager.CloudManagerApi;
38 | import io.adobe.cloudmanager.CloudManagerApiException;
39 | import io.adobe.cloudmanager.Pipeline;
40 | import io.adobe.cloudmanager.Program;
41 | import io.jenkins.plugins.adobe.cloudmanager.config.AdobeIOConfig;
42 | import io.jenkins.plugins.adobe.cloudmanager.config.AdobeIOProjectConfig;
43 | import org.slf4j.Logger;
44 | import org.slf4j.LoggerFactory;
45 |
46 | /**
47 | * Helper for generating builder's UI selection lists.
48 | */
49 | public class DescriptorHelper {
50 |
51 | public static final Logger LOGGER = LoggerFactory.getLogger(DescriptorHelper.class);
52 |
53 | @Nonnull
54 | public static ListBoxModel fillAioProjectItems() {
55 | ListBoxModel lbm = new ListBoxModel();
56 | lbm.add(Messages.DescriptorHelper_defaultListItem(), "");
57 | AdobeIOConfig aio = AdobeIOConfig.configuration();
58 | for (AdobeIOProjectConfig cfg : aio.getProjectConfigs()) {
59 | String name = cfg.getName();
60 | if (name != null) {
61 | lbm.add(cfg.getDisplayName(), name);
62 | }
63 | }
64 | return lbm;
65 | }
66 |
67 | @Nonnull
68 | public static ListBoxModel fillProgramItems(String aioProject) {
69 | ListBoxModel lbm = new ListBoxModel();
70 | lbm.add(Messages.DescriptorHelper_defaultListItem(), "");
71 | try {
72 | if (StringUtils.isNotBlank(aioProject)) {
73 | Optional api = CloudManagerApiUtil.createApi().apply(aioProject);
74 | Collection programs = api.isPresent() ? api.get().listPrograms() : Collections.emptyList();
75 | for (Program p : programs) {
76 | lbm.add(p.getName(), p.getId());
77 | }
78 | }
79 | } catch (CloudManagerApiException e) {
80 | LOGGER.error(Messages.DescriptorHelper_error_CloudManagerApiException(e.getLocalizedMessage()));
81 | }
82 | return lbm;
83 | }
84 |
85 | @Nonnull
86 | public static ListBoxModel fillPipelineItems(String aioProject, String program) {
87 | ListBoxModel lbm = new ListBoxModel();
88 | lbm.add(Messages.DescriptorHelper_defaultListItem(), "");
89 |
90 | if (StringUtils.isNotBlank(aioProject) && StringUtils.isNotBlank(program)) {
91 | Optional api = CloudManagerApiUtil.createApi().apply(aioProject);
92 | try {
93 | Collection pipelines = api.isPresent() ? api.get().listPipelines(program) : Collections.emptyList();
94 | for (Pipeline p : pipelines) {
95 | lbm.add(p.getName(), p.getId());
96 | }
97 | } catch (CloudManagerApiException e) {
98 | LOGGER.error(Messages.DescriptorHelper_error_CloudManagerApiException(e.getLocalizedMessage()));
99 | }
100 | }
101 | return lbm;
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/step/PollPipelineStep.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.step;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import java.util.Arrays;
30 | import java.util.Collections;
31 | import java.util.HashSet;
32 | import java.util.Set;
33 | import javax.annotation.Nonnull;
34 |
35 | import hudson.Extension;
36 | import hudson.model.Run;
37 | import hudson.model.TaskListener;
38 | import io.jenkins.plugins.adobe.cloudmanager.step.execution.PollPipelineExecution;
39 | import org.jenkinsci.plugins.workflow.steps.Step;
40 | import org.jenkinsci.plugins.workflow.steps.StepContext;
41 | import org.jenkinsci.plugins.workflow.steps.StepDescriptor;
42 | import org.jenkinsci.plugins.workflow.steps.StepExecution;
43 | import org.kohsuke.stapler.DataBoundConstructor;
44 | import org.kohsuke.stapler.DataBoundSetter;
45 |
46 | /**
47 | * Polls the Cloud Manager API to determine if the pipeline has completed.
48 | *
49 | * The pipeline execution needs to be in the Job/Build context.
50 | *
51 | */
52 | public class PollPipelineStep extends Step {
53 |
54 | /**
55 | * Minimum time to wait before poll checks.
56 | */
57 | static final long MIN_RECURRENCE_PERIOD = 30000; // 30 seconds
58 | /**
59 | * Maximum time to wait before poll checks.
60 | */
61 | static final long MAX_RECURRENCE_PERIOD = 900000; // 15 minutes
62 | /**
63 | * Default time to wait before poll checks.
64 | */
65 | static final long DEFAULT_RECURRENCE_PERIOD = 300000; // 5 minutes
66 |
67 | private long recurrencePeriod = DEFAULT_RECURRENCE_PERIOD;
68 | private boolean quiet = false;
69 |
70 | @DataBoundConstructor
71 | public PollPipelineStep() {
72 | }
73 |
74 | /**
75 | * Wait period before repeated API checks, in milliseconds
76 | */
77 | public long getRecurrencePeriod() {
78 | return recurrencePeriod;
79 | }
80 |
81 | @DataBoundSetter
82 | public void setRecurrencePeriod(long recurrencePeriod) {
83 | this.recurrencePeriod = Math.max(MIN_RECURRENCE_PERIOD, Math.min(recurrencePeriod, MAX_RECURRENCE_PERIOD));
84 | }
85 |
86 | /**
87 | * Flag to indicate whether or not this step should log each API check.
88 | */
89 | public boolean isQuiet() {
90 | return quiet;
91 | }
92 |
93 | @DataBoundSetter
94 | public void setQuiet(boolean quiet) {
95 | this.quiet = quiet;
96 | }
97 |
98 | @Override
99 | public StepExecution start(StepContext context) throws Exception {
100 | return new PollPipelineExecution(context, recurrencePeriod, quiet);
101 | }
102 |
103 | @Extension
104 | public static final class DescriptorImpl extends StepDescriptor {
105 |
106 | @Override
107 | public String getFunctionName() {
108 | return "acmPollPipeline";
109 | }
110 |
111 | @Nonnull
112 | @Override
113 | public String getDisplayName() {
114 | return Messages.PollPipelineStep_displayName();
115 | }
116 |
117 | @Override
118 | public Set extends Class>> getRequiredContext() {
119 | return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(Run.class, TaskListener.class)));
120 | }
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/step/PipelineEndStep.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.step;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import java.util.Arrays;
30 | import java.util.Collections;
31 | import java.util.HashSet;
32 | import java.util.Set;
33 | import javax.annotation.Nonnull;
34 |
35 | import hudson.Extension;
36 | import hudson.model.Run;
37 | import hudson.model.TaskListener;
38 | import io.jenkins.plugins.adobe.cloudmanager.step.execution.PipelineEndExecution;
39 | import org.jenkinsci.plugins.workflow.graph.FlowNode;
40 | import org.jenkinsci.plugins.workflow.steps.Step;
41 | import org.jenkinsci.plugins.workflow.steps.StepContext;
42 | import org.jenkinsci.plugins.workflow.steps.StepDescriptor;
43 | import org.jenkinsci.plugins.workflow.steps.StepExecution;
44 | import org.kohsuke.stapler.DataBoundConstructor;
45 | import org.kohsuke.stapler.DataBoundSetter;
46 |
47 | /**
48 | * {@link Step} which waits for a Cloud Manager pipeline end event.
49 | *
50 | * If an Pipeline end event is received, all inner {@link PipelineStepStateStep} instances are quietly ended.
51 | * Any other inner steps are allowed to complete as configured.
52 | *
53 | *
54 | * See the Cloud Manager Events documentation.
55 | *
56 | *
57 | * Note: Syntax wise, until JENKINS-65646 is resolved, a block must be specified, even if its empty.
58 | *
59 | */
60 | public class PipelineEndStep extends Step {
61 |
62 | private boolean mirror = true;
63 | private boolean empty = false;
64 |
65 | @DataBoundConstructor
66 | public PipelineEndStep() {
67 |
68 | }
69 |
70 | /**
71 | * Flag if this step mirror the remote state. (Remote aborted results in local failure.)
72 | */
73 | public boolean isMirror() {
74 | return mirror;
75 | }
76 |
77 | @DataBoundSetter
78 | public void setMirror(boolean mirror) {
79 | this.mirror = mirror;
80 | }
81 |
82 | public boolean isEmpty() { return empty; }
83 |
84 | @DataBoundSetter
85 | public void setEmpty(boolean empty) { this.empty = empty; }
86 |
87 | @Override
88 | public StepExecution start(StepContext context) throws Exception {
89 | return new PipelineEndExecution(context, mirror, empty);
90 | }
91 |
92 | @Extension
93 | public static final class DescriptorImpl extends StepDescriptor {
94 |
95 | @Override
96 | public String getFunctionName() {
97 | return "acmPipelineEnd";
98 | }
99 |
100 | @Override
101 | public Set extends Class>> getRequiredContext() {
102 | return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(Run.class, FlowNode.class, TaskListener.class)));
103 | }
104 |
105 | @Nonnull
106 | @Override
107 | public String getDisplayName() {
108 | return Messages.PipelineEndStep_displayName();
109 | }
110 |
111 | @Override
112 | public boolean takesImplicitBlockArgument() {
113 | return true;
114 | }
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Adobe Cloud Manager plugin for Jenkins
2 |
3 | [](https://ci.jenkins.io/job/Plugins/job/adobe-cloud-manager-plugin/job/master/)
4 | [](https://plugins.jenkins.io/adobe-cloud-manager)
5 | [](https://github.com/jenkinsci/adobe-cloud-manager-plugin/releases/latest)
6 | [](https://plugins.jenkins.io/adobe-cloud-manager)
7 |
8 | - [Introduction](#introduction)
9 | - [Getting Started](#getting-started)
10 | - [Usage](#usage)
11 | - [Build Actions](#build-actions)
12 | - [Examples](#examples)
13 |
14 | ## Introduction
15 |
16 | This plugin is intended to allow teams to integrate their Adobe Cloud Manager release process with upstream, intermediate and downstream operational tasks. It provides mechanisms for activating builds, responding to AdobeIO Cloud Manager build events, and taking actions during approval steps.
17 |
18 | ## Versions
19 |
20 | This plugin uses automatic releases, which has a different version format. See https://www.jenkins.io/jep/229
21 |
22 | ## Getting Started
23 |
24 | Before using any of the builders or steps in this plugin, Jenkins needs to be configured to authenticate to an Adobe IO project. To do that, follow these steps:
25 |
26 | 1. [Create an Adobe IO API Integration](https://www.adobe.io/apis/experiencecloud/cloud-manager/docs.html#!AdobeDocs/cloudmanager-api-docs/master/create-api-integration.md).
27 | 1. [Add the credentials to Jenkins](/doc/config/jenkins-credentials/README.md)
28 | 1. [Configure an Adobe IO Project](/doc/config/adobeio-project/README.md)
29 |
30 | ### AdobeIO WebHook
31 |
32 | This plugin supports receiving AdobeIO Cloud Manager events. See the [Adobe IO Project configuration](/doc/config/adobeio-project/README.md#enable-webhook) for details on the WebHook operation, and the [Adobe IO documentation](https://www.adobe.io/apis/experienceplatform/events/docs.html#!adobedocs/adobeio-events/master/intro/webhooks_intro.md) on configuring a webhook endpoint.
33 |
34 | ## Usage
35 |
36 | The following builders and steps are available in this plugin. See the individual details page on how each functions and how to configure.
37 |
38 | All of the items listed here support syntax generation using the in-Jenkins *Pipeline Syntax* tool.
39 |
40 | ## Triggers
41 |
42 | - [Start Pipeline Trigger](/doc/trigger/start-pipeline/README.md)
43 |
44 | ## Steps/Builders
45 |
46 | - [Repository Sync Builder](/doc/builder/repository-sync/README.md)
47 | - [Start Pipeline Builder](/doc/builder/start-pipeline/README.md)
48 | - [Poll Pipeline Step](/doc/step/poll-pipeline/README.md)
49 | - [Pipeline Step Execution Step](/doc/step/pipeline-step-state/README.md)
50 | - [Pipeline End Execution Step](/doc/step/pipeline-end/README.md)
51 |
52 | ## Build Actions
53 |
54 | - [Cloud Manager Build](/doc/action/cloud-manager-build/README.md)
55 | - [Pipeline Waiting](/doc/action/pipeline-waiting/README.md)
56 |
57 | ## Examples
58 |
59 | Coming soon.
60 |
61 | ## Issues
62 |
63 | Report issues and enhancements in the [Jenkins issue tracker](https://issues.jenkins.io/issues/?jql=project%20%3D%20JENKINS%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20adobe-cloud-manager-plugin). The Component is `adobe-cloud-manager-plugin`.
64 |
65 | ## Contributing
66 |
67 | Refer to the general Jenkins. [contribution guidelines](https://github.com/jenkinsci/.github/blob/master/CONTRIBUTING.md).
68 |
69 | ### Code Submissions
70 |
71 | Submissions should come as pull request and will be reviewed by project committers.
72 |
73 | ### License Headers
74 |
75 | Please make sure to run the license header profile before creating a pull request. This can be done with:
76 |
77 | > $ mvn clean process-sources process-test-resources -Plicense-header-check
78 |
79 | This will tell you of any files with missing license headers.
80 |
81 | ## LICENSE
82 |
83 | Licensed under MIT, see [LICENSE](LICENSE)
84 |
85 | ## SUPPORT
86 |
87 | The Adobe Cloud Manager Jenkins Plugin is an open-source, community supported library.
88 |
89 | The Adobe Cloud Manager Jenkins Plugin NOT supported or warrantied by Adobe Systems Inc.
90 |
91 | For reporting bugs, contributing, or other questions about this project, please see the [contribution guidelines](https://github.com/jenkinsci/.github/blob/master/CONTRIBUTING.md).
92 |
--------------------------------------------------------------------------------
/src/test/java/io/jenkins/plugins/adobe/cloudmanager/step/execution/AbstractStepExecutionTest.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.step.execution;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import hudson.AbortException;
30 | import hudson.model.Run;
31 | import io.adobe.cloudmanager.CloudManagerApi;
32 | import io.jenkins.plugins.adobe.cloudmanager.CloudManagerPipelineExecution;
33 | import io.jenkins.plugins.adobe.cloudmanager.action.CloudManagerBuildAction;
34 | import io.jenkins.plugins.adobe.cloudmanager.config.AdobeIOConfig;
35 | import io.jenkins.plugins.adobe.cloudmanager.config.AdobeIOProjectConfig;
36 | import mockit.Expectations;
37 | import mockit.Injectable;
38 | import mockit.Mock;
39 | import mockit.MockUp;
40 | import mockit.Mocked;
41 | import mockit.Tested;
42 | import org.jenkinsci.plugins.workflow.steps.StepContext;
43 | import org.junit.Before;
44 | import org.junit.Test;
45 | import static org.junit.Assert.*;
46 |
47 | public class AbstractStepExecutionTest {
48 |
49 | private static final String found = "Found Config";
50 |
51 | @Tested
52 | private AbstractStepExecution tested;
53 |
54 | @Injectable
55 | private StepContext context;
56 |
57 | @Mocked
58 | private Run, ?> run;
59 |
60 | @Mocked
61 | private CloudManagerBuildAction data;
62 |
63 | @Mocked
64 | private CloudManagerPipelineExecution cmExecution;
65 |
66 | @Mocked
67 | private CloudManagerApi api;
68 |
69 | @Mocked
70 | private AdobeIOProjectConfig projectConfig;
71 |
72 | @Before
73 | public void before() throws Exception {
74 | new MockUp() {
75 | @Mock
76 | public AdobeIOProjectConfig projectConfigFor(String name) {
77 | return found.equals(name) ? projectConfig : null;
78 | }
79 | };
80 | new Expectations() {{
81 | context.get(Run.class);
82 | result = run;
83 | minTimes = 0;
84 | run.getAction(CloudManagerBuildAction.class);
85 | result = data;
86 | minTimes = 0;
87 | }};
88 | }
89 |
90 | @Test
91 | public void validateMissingAIOProject() throws Exception {
92 | new Expectations() {{
93 | data.getAioProjectName();
94 | result = "Missing";
95 | }};
96 | assertThrows(AbortException.class, () -> tested.validateData());
97 | }
98 |
99 | @Test
100 | public void validateMissingCMExecution() throws Exception {
101 | new Expectations() {{
102 | data.getAioProjectName();
103 | result = found;
104 | data.getCmExecution();
105 | result = null;
106 | }};
107 | assertThrows(AbortException.class, () -> tested.validateData());
108 | }
109 |
110 | @Test
111 | public void validateSuccess() throws Exception {
112 | new Expectations() {{
113 | data.getAioProjectName();
114 | result = found;
115 | data.getCmExecution();
116 | result = cmExecution;
117 | }};
118 | tested.validateData();
119 | }
120 |
121 | @Test
122 | public void projectMissing() throws Exception {
123 | new Expectations() {{
124 | data.getAioProjectName();
125 | result = "Missing";
126 | }};
127 | assertThrows(AbortException.class, () -> tested.getAioProject());
128 | }
129 |
130 | @Test
131 | public void projectFound() throws Exception {
132 | new Expectations() {{
133 | data.getAioProjectName();
134 | result = found;
135 | }};
136 | assertNotNull(tested.getAioProject());
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/src/test/java/io/jenkins/plugins/adobe/cloudmanager/config/ConfigAsCodeTest.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.config;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import java.util.List;
30 |
31 | import io.jenkins.plugins.casc.ConfigurationContext;
32 | import io.jenkins.plugins.casc.Configurator;
33 | import io.jenkins.plugins.casc.ConfiguratorRegistry;
34 | import io.jenkins.plugins.casc.misc.ConfiguredWithCode;
35 | import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithCodeRule;
36 | import io.jenkins.plugins.casc.model.CNode;
37 | import io.jenkins.plugins.casc.model.Mapping;
38 | import org.junit.Rule;
39 | import org.junit.Test;
40 | import static org.junit.Assert.*;
41 |
42 | public class ConfigAsCodeTest {
43 |
44 | @Rule
45 | public JenkinsConfiguredWithCodeRule rule = new JenkinsConfiguredWithCodeRule();
46 |
47 | @Test
48 | @ConfiguredWithCode("configuration-as-code.yaml")
49 | public void shouldSupportConfigurationAsCode() {
50 | AdobeIOConfig aioconfig = AdobeIOConfig.configuration();
51 |
52 | assertEquals("Configurations were loaded", 2, aioconfig.getProjectConfigs().size());
53 |
54 | AdobeIOProjectConfig config = aioconfig.getProjectConfigs().get(0);
55 | assertEquals("Name is correct.", "Test Project 1", config.getName());
56 | assertEquals("API URL is correct.", AdobeIOProjectConfig.ADOBE_IO_URL, config.getApiUrl());
57 | assertEquals("Client Id is correct", "Client Id 1", config.getClientId());
58 | assertEquals("IMS Org is correct", "Ims Organization Id 1", config.getImsOrganizationId());
59 | assertEquals("Tech Account is correct", "Technical Account Id 1", config.getTechnicalAccountId());
60 | assertEquals("Client Secret Cred is correct", "Client Secret Credentials Id 1", config.getClientSecretCredentialsId());
61 | assertEquals("Private Key Cred is correct", "Private Key Credentials Id 1", config.getPrivateKeyCredentialsId());
62 |
63 | config = aioconfig.getProjectConfigs().get(1);
64 | assertEquals("Name is correct.", "Test Project 2", config.getName());
65 | assertEquals("API URL is correct.", "http://notdefault.adobe.io/url", config.getApiUrl());
66 | assertEquals("Client Id is correct", "Client Id 2", config.getClientId());
67 | assertEquals("IMS Org is correct", "Ims Organization Id 2", config.getImsOrganizationId());
68 | assertEquals("Tech Account is correct", "Technical Account Id 2", config.getTechnicalAccountId());
69 | assertEquals("Client Secret Cred is correct", "Client Secret Credentials Id 2", config.getClientSecretCredentialsId());
70 | assertEquals("Private Key Cred is correct", "Private Key Credentials Id 2", config.getPrivateKeyCredentialsId());
71 | }
72 |
73 | @Test
74 | @ConfiguredWithCode("configuration-as-code.yaml")
75 | public void exportConfiguration() throws Exception {
76 | AdobeIOConfig aioconfig = AdobeIOConfig.configuration();
77 | ConfiguratorRegistry registry = ConfiguratorRegistry.get();
78 | ConfigurationContext context = new ConfigurationContext(registry);
79 | Configurator configurator = context.lookupOrFail(AdobeIOConfig.class);
80 |
81 | CNode node = configurator.describe(aioconfig, context);
82 | assertNotNull(node);
83 | Mapping mapping = node.asMapping();
84 | CNode configsNode = mapping.get("projectConfigs");
85 |
86 | @SuppressWarnings("unchecked")
87 | List configs = (List) configsNode.asSequence();
88 | assertEquals(2, configs.size());
89 | assertEquals("Project Name is correct.", "Test Project 1", configs.get(0).getScalarValue("name"));
90 | assertEquals("Project Name is correct.", "Test Project 2", configs.get(1).getScalarValue("name"));
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/step/execution/PollPipelineExecution.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.step.execution;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import java.io.IOException;
30 | import java.util.concurrent.ScheduledFuture;
31 | import java.util.concurrent.TimeUnit;
32 |
33 | import hudson.AbortException;
34 | import hudson.Util;
35 | import hudson.model.TaskListener;
36 | import io.adobe.cloudmanager.CloudManagerApi;
37 | import io.adobe.cloudmanager.CloudManagerApiException;
38 | import io.jenkins.plugins.adobe.cloudmanager.CloudManagerPipelineExecution;
39 | import io.jenkins.plugins.adobe.cloudmanager.config.AdobeIOProjectConfig;
40 | import io.jenkins.plugins.adobe.cloudmanager.util.CloudManagerApiUtil;
41 | import jenkins.util.Timer;
42 | import org.jenkinsci.plugins.workflow.steps.StepContext;
43 |
44 | /**
45 | * Execution for a {@link io.jenkins.plugins.adobe.cloudmanager.step.PollPipelineStep}.
46 | * Periodically checks if the specified Cloud Manager execution is complete.
47 | */
48 | public class PollPipelineExecution extends AbstractStepExecution {
49 |
50 | private static final long serialVersionUID = 1L;
51 |
52 | private final long recurrencePeriod;
53 | private final boolean quiet;
54 | protected transient volatile ScheduledFuture> task;
55 |
56 | public PollPipelineExecution(StepContext context, long recurrencePeriod, boolean quiet) {
57 | super(context);
58 | this.recurrencePeriod = recurrencePeriod;
59 | this.quiet = quiet;
60 | }
61 |
62 | @Override
63 | public void doStart() throws Exception {
64 | createTask();
65 | }
66 |
67 | @Override
68 | public void doResume() {
69 | createTask();
70 | }
71 |
72 | @Override
73 | public void doStop() throws Exception {
74 | if (task != null) {
75 | task.cancel(true);
76 | task = null;
77 | }
78 | }
79 |
80 | protected void createTask() {
81 | task = Timer.get().scheduleWithFixedDelay(() -> {
82 | try {
83 | AdobeIOProjectConfig aioProject = getAioProject();
84 | if (checkExecution(aioProject.getName())) {
85 | task.cancel(true);
86 | task = null;
87 | getContext().onSuccess(null);
88 | }
89 | } catch (IOException | InterruptedException e) {
90 | task.cancel(true);
91 | task = null;
92 | getContext().onFailure(e);
93 | }
94 | }, 0, recurrencePeriod, TimeUnit.MILLISECONDS);
95 | }
96 |
97 | private boolean checkExecution(String aioProjectName) throws AbortException {
98 | try {
99 | CloudManagerApi api = CloudManagerApiUtil.createApi().apply(aioProjectName).orElseThrow(() -> new AbortException(Messages.AbstractStepExecution_error_missingBuildData()));
100 | CloudManagerPipelineExecution execution = getBuildData().getCmExecution();
101 | if (api.isExecutionRunning(execution.getProgramId(), execution.getPipelineId(), execution.getExecutionId())) {
102 | if (!quiet) {
103 | getContext().get(TaskListener.class).getLogger().println(Messages.PollPipelineExecution_waiting(Util.getTimeSpanString(recurrencePeriod)));
104 | }
105 | return false;
106 | }
107 | getContext().get(TaskListener.class).getLogger().println(Messages.PollPipelineExecution_complete());
108 | } catch (AbortException e) {
109 | throw e;
110 | } catch (CloudManagerApiException e) {
111 | throw new AbortException(Messages.PollPipelineExecution_error_CloudManagerApiException(e.getLocalizedMessage()));
112 | } catch (Exception e) {
113 | throw new AbortException(e.getLocalizedMessage());
114 | }
115 | return true;
116 | }
117 |
118 | }
119 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/webhook/subscriber/PipelineStepEventSubscriber.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.webhook.subscriber;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import java.io.IOException;
30 | import java.util.Arrays;
31 | import java.util.HashSet;
32 | import java.util.Optional;
33 | import java.util.Set;
34 | import java.util.concurrent.TimeoutException;
35 | import javax.annotation.Nonnull;
36 |
37 | import hudson.Extension;
38 | import io.adobe.cloudmanager.CloudManagerApi;
39 | import io.adobe.cloudmanager.CloudManagerApiException;
40 | import io.adobe.cloudmanager.PipelineExecution;
41 | import io.adobe.cloudmanager.PipelineExecutionStepState;
42 | import io.adobe.cloudmanager.event.CloudManagerEvent;
43 | import io.adobe.cloudmanager.event.PipelineExecutionStepEndEvent;
44 | import io.adobe.cloudmanager.event.PipelineExecutionStepStartEvent;
45 | import io.adobe.cloudmanager.event.PipelineExecutionStepWaitingEvent;
46 | import io.jenkins.plugins.adobe.cloudmanager.step.execution.PipelineStepStateExecution;
47 | import io.jenkins.plugins.adobe.cloudmanager.util.CloudManagerApiUtil;
48 | import org.jenkinsci.plugins.workflow.steps.StepExecution;
49 | import org.slf4j.Logger;
50 | import org.slf4j.LoggerFactory;
51 | import static io.adobe.cloudmanager.event.CloudManagerEvent.EventType.*;
52 |
53 | /**
54 | * Subscriber for Cloud Manager pipeline execution step events.
55 | */
56 | @Extension
57 | public class PipelineStepEventSubscriber extends CloudManagerEventSubscriber {
58 | private static final Logger LOGGER = LoggerFactory.getLogger(PipelineStepEventSubscriber.class);
59 |
60 | private static final Set EVENTS = new HashSet<>(Arrays.asList(STEP_STARTED, STEP_WAITING, STEP_ENDED));
61 |
62 | @Nonnull
63 | @Override
64 | protected Set types() {
65 | return EVENTS;
66 | }
67 |
68 | /**
69 | * Calls all {@link io.jenkins.plugins.adobe.cloudmanager.step.PipelineStepStateStep} instances waiting for an event.
70 | */
71 | @Override
72 | protected void onEvent(final CloudManagerSubscriberEvent event) {
73 | Optional api = CloudManagerApiUtil.createApi().apply(event.getAioProjectName());
74 | if (!api.isPresent()) {
75 | LOGGER.error(Messages.CloudManagerEventSubscriber_error_createApi());
76 | return;
77 | }
78 | try {
79 |
80 | final PipelineExecutionStepState stepState;
81 | switch (event.getType()) {
82 | case STEP_STARTED:
83 | stepState = api.get().getExecutionStepState(CloudManagerEvent.parseEvent(event.getPayload(), PipelineExecutionStepStartEvent.class));
84 | break;
85 | case STEP_WAITING:
86 | stepState = api.get().getExecutionStepState(CloudManagerEvent.parseEvent(event.getPayload(), PipelineExecutionStepWaitingEvent.class));
87 | break;
88 | case STEP_ENDED:
89 | stepState = api.get().getExecutionStepState(CloudManagerEvent.parseEvent(event.getPayload(), PipelineExecutionStepEndEvent.class));
90 | break;
91 | default:
92 | LOGGER.warn(Messages.PipelineStepEventSubscriber_warn_invalidStepState(event.getType()));
93 | return;
94 | }
95 |
96 | final PipelineExecution pipelineExecution = stepState.getExecution();
97 | StepExecution.applyAll(PipelineStepStateExecution.class, (execution) -> {
98 | try {
99 | execution.process(pipelineExecution, stepState);
100 | } catch (IOException | InterruptedException | TimeoutException ex) {
101 | LOGGER.error(Messages.CloudManagerEventSubscriber_error_notifyExecution(ex.getLocalizedMessage()));
102 | }
103 | return null;
104 | });
105 | } catch (CloudManagerApiException e) {
106 | LOGGER.error(Messages.CloudManagerEventSubscriber_error_api(e.getLocalizedMessage()));
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/util/CredentialsUtil.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.util;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import java.io.IOException;
30 | import java.nio.charset.Charset;
31 | import java.util.Collections;
32 | import java.util.Optional;
33 | import javax.annotation.Nonnull;
34 |
35 | import org.apache.commons.io.IOUtils;
36 | import org.apache.commons.lang.StringUtils;
37 |
38 | import com.cloudbees.plugins.credentials.Credentials;
39 | import com.cloudbees.plugins.credentials.CredentialsMatchers;
40 | import com.cloudbees.plugins.credentials.CredentialsProvider;
41 | import hudson.util.Secret;
42 | import io.jenkins.plugins.adobe.cloudmanager.config.AdobeIOProjectConfig;
43 | import jenkins.model.Jenkins;
44 | import org.jenkinsci.plugins.plaincredentials.FileCredentials;
45 | import org.jenkinsci.plugins.plaincredentials.StringCredentials;
46 | import org.slf4j.Logger;
47 | import org.slf4j.LoggerFactory;
48 |
49 | /**
50 | * Utility class for looking up Credentials for different forms.
51 | */
52 | public class CredentialsUtil {
53 |
54 | private static final Logger LOGGER = LoggerFactory.getLogger(CredentialsUtil.class);
55 | /**
56 | * Find the Client Secret for the specified credential id.
57 | *
58 | * @param credentialsId the id of the credentials
59 | * @return optional string containing the credentials
60 | */
61 | @Nonnull
62 | public static Optional clientSecretFor(String credentialsId) {
63 | return aioScopedCredentialsFor(credentialsId, StringCredentials.class).map(StringCredentials::getSecret);
64 | }
65 |
66 | /**
67 | * Find the Private Key for the specified credential id. This is returned as the String contents of the provided credential file.
68 | *
69 | * @param credentialsId the id of the credentials
70 | * @return optional String containing the credentials
71 | */
72 | @Nonnull
73 | public static Optional privateKeyFor(String credentialsId) {
74 | return aioScopedCredentialsFor(credentialsId, FileCredentials.class)
75 | .map(creds -> {
76 | try {
77 | return Secret.fromString(IOUtils.toString(creds.getContent(), Charset.defaultCharset()));
78 | } catch (IOException e) {
79 | LOGGER.error(Messages.CredentialsUtil_error_privateKeyError(credentialsId, e.getLocalizedMessage()));
80 | return null;
81 | }
82 | });
83 | }
84 |
85 | /**
86 | * Look up a Credential object from the stores, using the specified Id.
87 | *
88 | * @param credentialsId the id of the credential
89 | * @param type the type of the credential to lookup.
90 | * @param which type of credentials to lookup.
91 | * @return optional credential for the provided id
92 | */
93 | @Nonnull
94 | public static Optional credentialsFor(String credentialsId, Class type) {
95 | return CredentialsMatchers.filter(
96 | CredentialsProvider.lookupCredentials(type, Jenkins.get(), null, Collections.emptyList()),
97 | CredentialsMatchers.withId(StringUtils.trimToEmpty(credentialsId))
98 | ).stream().findFirst();
99 |
100 | }
101 |
102 | /**
103 | * Look up a Credential object from the stores, using the specified Id. Credentials are limited to the Adobe IO Domain.
104 | *
105 | * @param credentialsId the id of the credential
106 | * @param type the type of the credential to lookup.
107 | * @param which type of credentials to lookup.
108 | * @return optional credential for the provided id
109 | */
110 | @Nonnull
111 | public static Optional aioScopedCredentialsFor(String credentialsId, Class type) {
112 | return CredentialsMatchers.filter(
113 | CredentialsProvider.lookupCredentials(type, Jenkins.get(), null, AdobeIOProjectConfig.getAIODomainRequirement()),
114 | CredentialsMatchers.withId(StringUtils.trimToEmpty(credentialsId))
115 | ).stream().findFirst();
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/src/main/java/io/jenkins/plugins/adobe/cloudmanager/config/AdobeIOConfig.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.config;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import java.util.ArrayList;
30 | import java.util.Collections;
31 | import java.util.List;
32 | import javax.annotation.CheckForNull;
33 | import javax.annotation.Nonnull;
34 |
35 | import org.apache.commons.lang3.StringUtils;
36 |
37 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
38 | import hudson.Extension;
39 | import io.jenkins.plugins.adobe.cloudmanager.webhook.CloudManagerWebHook;
40 | import jenkins.model.GlobalConfiguration;
41 | import jenkins.model.Jenkins;
42 | import net.sf.json.JSONObject;
43 | import org.kohsuke.stapler.DataBoundSetter;
44 | import org.kohsuke.stapler.StaplerRequest;
45 |
46 | /**
47 | * Global Configuration panel for Adobe IO projects.
48 | */
49 | @Extension
50 | public class AdobeIOConfig extends GlobalConfiguration {
51 |
52 | // XML Config file name for storage.
53 | public static final String CLOUD_MANAGER_CONFIGURATION_ID = "adobe-cloud-manager-plugin-config";
54 |
55 | // Protect against no configurations done, and NPE.
56 | private static final AdobeIOConfig EMPTY_CONFIG = new AdobeIOConfig(Collections.emptyList());
57 |
58 | private List projectConfigs = new ArrayList<>();
59 |
60 | // Webhook is disabled by default - make a conscious decision to enable it.
61 | private boolean webhookEnabled = false;
62 |
63 | @SuppressFBWarnings("MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR")
64 | public AdobeIOConfig() {
65 | getConfigFile().getXStream().alias("adobe-io-project-config", AdobeIOProjectConfig.class);
66 | load();
67 | }
68 |
69 | public AdobeIOConfig(@Nonnull List projectConfigs) {
70 | this.projectConfigs = projectConfigs;
71 | }
72 |
73 | /**
74 | * Helper for looking up this configuration, protecting against null.
75 | */
76 | @Nonnull
77 | public static AdobeIOConfig configuration() {
78 | AdobeIOConfig config = AdobeIOConfig.all().get(AdobeIOConfig.class);
79 | if (config == null) {
80 | config = EMPTY_CONFIG;
81 | }
82 | return config;
83 | }
84 |
85 | /**
86 | * Helper to find an AIO Project config based on a name.
87 | *
88 | * Name must match exactly.
89 | *
90 | *
91 | * Useful for checking after restarts or for long running builds.
92 | *
93 | *
94 | * @param name the name of the AIO Project Config
95 | * @return config or null
96 | */
97 | @CheckForNull
98 | public static AdobeIOProjectConfig projectConfigFor(@Nonnull String name) {
99 | return AdobeIOConfig.configuration().getProjectConfigs()
100 | .stream()
101 | .filter(c -> StringUtils.equals(name, c.getName()))
102 | .findFirst().orElse(null);
103 | }
104 |
105 | @Nonnull
106 | public List getProjectConfigs() {
107 | return Collections.unmodifiableList(projectConfigs);
108 | }
109 |
110 | @DataBoundSetter
111 | public void setProjectConfigs(@Nonnull List projectConfigs) {
112 | this.projectConfigs = projectConfigs;
113 | }
114 |
115 | public boolean isWebhookEnabled() {
116 | return webhookEnabled;
117 | }
118 |
119 | @DataBoundSetter
120 | public void setWebhookEnabled(boolean webhookEnabled) {
121 | this.webhookEnabled = webhookEnabled;
122 | }
123 |
124 | public String getWebhookUrl() {
125 | return String.format("%s/%s/", Jenkins.get().getRootUrl(), CloudManagerWebHook.URL_NAME);
126 | }
127 |
128 | /**
129 | * To avoid long class name as id in xml tag name and config file
130 | */
131 | @Override
132 | public String getId() {
133 | return CLOUD_MANAGER_CONFIGURATION_ID;
134 | }
135 |
136 | @Override
137 | public String getDisplayName() {
138 | return "Adobe IO";
139 | }
140 |
141 | @Override
142 | public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
143 | projectConfigs = new ArrayList<>(); // Form binding does not save empty lists properly.
144 | super.configure(req, json);
145 | save();
146 | return true;
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/src/test/java/io/jenkins/plugins/adobe/cloudmanager/builder/CloudManagerBuilderTest.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.plugins.adobe.cloudmanager.builder;
2 |
3 | /*-
4 | * #%L
5 | * Adobe Cloud Manager Plugin
6 | * %%
7 | * Copyright (C) 2020 - 2021 Adobe Inc.
8 | * %%
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | * #L%
27 | */
28 |
29 | import java.util.Optional;
30 | import java.util.function.Function;
31 |
32 | import hudson.AbortException;
33 | import io.adobe.cloudmanager.CloudManagerApi;
34 | import io.jenkins.plugins.adobe.cloudmanager.util.CloudManagerApiUtil;
35 | import mockit.Injectable;
36 | import mockit.Mock;
37 | import mockit.MockUp;
38 | import mockit.Mocked;
39 | import mockit.Tested;
40 | import org.junit.Before;
41 | import org.junit.Test;
42 | import static io.jenkins.plugins.adobe.cloudmanager.test.TestHelper.*;
43 | import static org.junit.Assert.*;
44 |
45 | public class CloudManagerBuilderTest {
46 |
47 | private static final String PROGRAM_ID = "2";
48 | private static final String PIPELINE_ID = "4";
49 |
50 | @Injectable
51 | private final String aioProject = AIO_PROJECT_NAME;
52 | @Injectable
53 | private final String program = "Program Name";
54 | @Injectable
55 | private final String pipeline = "Pipeline Name";
56 | @Tested
57 | private CloudManagerBuilder builder;
58 | @Mocked
59 | private CloudManagerApi api;
60 |
61 |
62 | @Before
63 | public void before() {
64 | new MockUp() {
65 | @Mock
66 | public Function> createApi() { return (name) -> Optional.of(api); }
67 | };
68 | }
69 |
70 | @Test
71 | public void createApi() throws Exception {
72 | assertNotNull(builder.createApi());
73 | }
74 |
75 | @Test
76 | public void createApiFailed() throws Exception {
77 | new MockUp() {
78 | @Mock
79 | public Function> createApi() { return (name) -> Optional.empty(); }
80 | };
81 |
82 | assertThrows(AbortException.class, () -> builder.createApi());
83 | }
84 |
85 | @Test
86 | public void missingProgram() throws Exception {
87 | new MockUp() {
88 | @Mock
89 | public Optional getProgramId(final CloudManagerApi api, final String programName) throws AbortException {
90 | return Optional.empty();
91 | }
92 | };
93 | AbortException exception = assertThrows(AbortException.class, () -> builder.getProgramId(api));
94 | assertEquals(Messages.CloudManagerBuilder_error_missingProgram(program), exception.getLocalizedMessage());
95 | }
96 |
97 |
98 | @Test
99 | public void getProgramIdFromName() throws Exception {
100 | new MockUp() {
101 | @Mock
102 | public Optional getProgramId(final CloudManagerApi api, final String programName) throws AbortException {
103 | return Optional.of(PROGRAM_ID);
104 | }
105 | };
106 |
107 | assertEquals(PROGRAM_ID, builder.getProgramId(api));
108 | }
109 |
110 | @Test
111 | public void getProgramIdFromId(@Tested CloudManagerBuilder localBuilder) throws Exception {
112 | localBuilder.setProgram(PROGRAM_ID);
113 | assertEquals(PROGRAM_ID, localBuilder.getProgramId(api));
114 | }
115 |
116 | @Test
117 | public void missingPipeline() throws Exception {
118 | new MockUp() {
119 | @Mock
120 | public Optional getPipelineId(final CloudManagerApi api, final String programId, final String pipelineName) throws AbortException {
121 | return Optional.empty();
122 | }
123 | };
124 |
125 | AbortException exception = assertThrows(AbortException.class, () -> builder.getPipelineId(api, PROGRAM_ID));
126 | assertEquals(Messages.CloudManagerBuilder_error_missingPipeline(pipeline), exception.getLocalizedMessage());
127 | }
128 |
129 | @Test
130 | public void getPipelineIdFromName() throws Exception {
131 | new MockUp() {
132 | @Mock
133 | public Optional getPipelineId(final CloudManagerApi api, final String programId, final String pipelineName) throws AbortException {
134 | return Optional.of(PIPELINE_ID);
135 | }
136 | };
137 |
138 | assertEquals(PIPELINE_ID, builder.getPipelineId(api, PROGRAM_ID));
139 | }
140 |
141 | @Test
142 | public void getPipelineIdFromId(@Tested CloudManagerBuilder localBuilder) throws Exception {
143 | localBuilder.setPipeline(PIPELINE_ID);
144 | assertEquals(PIPELINE_ID, localBuilder.getPipelineId(api, PROGRAM_ID));
145 | }
146 |
147 | }
148 |
--------------------------------------------------------------------------------