├── Jenkinsfile ├── src ├── main │ ├── resources │ │ ├── lib │ │ │ └── ecs │ │ │ │ ├── taglib │ │ │ │ └── blockWrapper.jelly │ │ ├── com │ │ │ └── alibabacloud │ │ │ │ └── jenkins │ │ │ │ └── ecs │ │ │ │ ├── AlibabaEcsFollowerTemplate │ │ │ │ ├── help-systemDiskSize_zh_CN.html │ │ │ │ ├── help-systemDiskSize.html │ │ │ │ ├── help-minimumNumberOfInstances_zh_CN.html │ │ │ │ ├── help-snapshotId_zh_CN.html │ │ │ │ ├── help-instanceCapStr_zh_CN.html │ │ │ │ ├── help-launchTimeoutStr_zh_CN.html │ │ │ │ ├── help-instanceType_zh_CN.html │ │ │ │ ├── help-remoteAdmin_zh_CN.html │ │ │ │ ├── help-launchTimeoutStr.html │ │ │ │ ├── help-userData_zh_CN.html │ │ │ │ ├── help-image_zh_CN.html │ │ │ │ ├── help-instanceNamePrefix_zh_CN.html │ │ │ │ ├── help-minimumNumberOfInstances.html │ │ │ │ ├── help-zone_zh_CN.html │ │ │ │ ├── help-vsw_zh_CN.html │ │ │ │ ├── help-instanceType.html │ │ │ │ ├── help-maxTotalUses_zh_CN.html │ │ │ │ ├── help-initScript_zh_CN.html │ │ │ │ ├── help-image.html │ │ │ │ ├── help-userData.html │ │ │ │ ├── help-systemDiskCategory_zh_CN.html │ │ │ │ ├── help-zone.html │ │ │ │ ├── help-instanceCapStr.html │ │ │ │ ├── help-initScript.html │ │ │ │ ├── help-numExecutors_zh_CN.html │ │ │ │ ├── help-systemDiskCategory.html │ │ │ │ ├── help-vsw.html │ │ │ │ ├── help-dataDiskId_zh_CN.html │ │ │ │ ├── help-remoteFs_zh_CN.html │ │ │ │ ├── help-numExecutors.html │ │ │ │ ├── config.properties │ │ │ │ ├── help-ecsType_zh_CN.html │ │ │ │ ├── config_zh_CN.properties │ │ │ │ ├── help-ecsType.html │ │ │ │ ├── help-remoteFs.html │ │ │ │ └── config.jelly │ │ │ │ ├── AlibabaCloud │ │ │ │ ├── help-vpc_zh_CN.html │ │ │ │ ├── help-securityGroup_zh_CN.html │ │ │ │ ├── help-region_zh_CN.html │ │ │ │ ├── help-attachPublicIp_zh_CN.html │ │ │ │ ├── help-sshKey_zh_CN.html │ │ │ │ ├── help-vpc.html │ │ │ │ ├── help-noDelayProvisioning_zh_CN.html │ │ │ │ ├── help-securityGroup.html │ │ │ │ ├── help-noDelayProvisioning.html │ │ │ │ ├── help-intranetMaster_zh_CN.html │ │ │ │ ├── help-region.html │ │ │ │ ├── help-sshKey.html │ │ │ │ ├── help-attachPublicIp.html │ │ │ │ ├── config.properties │ │ │ │ ├── config_zh_CN.properties │ │ │ │ ├── help-intranetMaster.html │ │ │ │ ├── computerSet.jelly │ │ │ │ └── config.jelly │ │ │ │ ├── WindowsData │ │ │ │ ├── help-password_zh_CN.html │ │ │ │ ├── config.properties │ │ │ │ ├── config_zh_CN.properties │ │ │ │ ├── help-password.html │ │ │ │ ├── help-bootDelay_zh_CN.html │ │ │ │ ├── help-bootDelay.html │ │ │ │ └── config.jelly │ │ │ │ ├── AlibabaEcsStep │ │ │ │ ├── help.html │ │ │ │ └── config.jelly │ │ │ │ ├── Messages_en.properties │ │ │ │ ├── Messages.properties │ │ │ │ ├── AlibabaEcsTag │ │ │ │ └── config.jelly │ │ │ │ ├── Messages_zh_CN.properties │ │ │ │ ├── AlibabaEcsComputer │ │ │ │ └── configure.jelly │ │ │ │ └── EcsTemplateStep │ │ │ │ └── config.jelly │ │ └── index.jelly │ └── java │ │ └── com │ │ └── alibabacloud │ │ └── jenkins │ │ └── ecs │ │ ├── win │ │ ├── winrm │ │ │ ├── request │ │ │ │ ├── WinRMRequest.java │ │ │ │ ├── DeleteShellRequest.java │ │ │ │ ├── GetOutputRequest.java │ │ │ │ ├── SignalRequest.java │ │ │ │ ├── OpenShellRequest.java │ │ │ │ ├── ExecuteCommandRequest.java │ │ │ │ ├── SendInputRequest.java │ │ │ │ ├── AbstractWinRMRequest.java │ │ │ │ └── RequestFactory.java │ │ │ ├── WinRMConnectException.java │ │ │ ├── soap │ │ │ │ ├── Option.java │ │ │ │ ├── MessageBuilder.java │ │ │ │ ├── Namespaces.java │ │ │ │ ├── HeaderBuilder.java │ │ │ │ └── Header.java │ │ │ ├── RuntimeIOException.java │ │ │ ├── NegotiateNTLMSchemaFactory.java │ │ │ ├── WinRMConnectionManagerFactory.java │ │ │ ├── WinRM.java │ │ │ └── WindowsProcess.java │ │ └── WinConnection.java │ │ ├── AlibabaEcsComputerListener.java │ │ ├── util │ │ ├── AlibabaEcsFactoryImpl.java │ │ ├── EcsInstanceHelper.java │ │ ├── Closeables.java │ │ ├── AlibabaEcsFactory.java │ │ ├── DateUtils.java │ │ ├── LogHelper.java │ │ ├── MinimumInstanceChecker.java │ │ ├── NetworkUtils.java │ │ └── CloudHelper.java │ │ ├── exception │ │ └── AlibabaEcsException.java │ │ ├── EcsTypeData.java │ │ ├── enums │ │ ├── DataDiskCategory.java │ │ └── SystemDiskCategory.java │ │ ├── ConnectionStrategy.java │ │ ├── UnixData.java │ │ ├── EcsHostAddressProvider.java │ │ ├── AlibabaEcsComputerLauncher.java │ │ ├── AlibabaEcsTag.java │ │ ├── monitor │ │ ├── AlibabaEcsFollowerMonitor.java │ │ └── FreeMemMonitor.java │ │ ├── AlibabaEcsComputer.java │ │ ├── NoDelayProvisionerStrategy.java │ │ ├── WindowsData.java │ │ └── AlibabaEcsStep.java └── test │ └── java │ └── com │ └── alibabacloud │ └── jenkins │ └── ecs │ ├── util │ ├── DateUtilsTest.java │ ├── AlibabaEcsFactoryTest.java │ └── NetworkUtilsTest.java │ ├── EcsTemplateStepExecutionTest.java │ ├── AlibabaCloudTest.java │ ├── AlibabaEcsUnixComputerLauncherTest.java │ ├── AlibabaEcsComputerTest.java │ ├── AlibabaEcsStepTest.java │ └── AlibabaEcsFollowerTemplateTest.java ├── docs └── images │ ├── nas.png │ ├── nas_1.png │ ├── nas_2.png │ ├── nas_3.png │ ├── nas_4.png │ ├── nas_5.png │ ├── nas_6.png │ ├── nas_7.png │ ├── qrcode.png │ ├── jenkins.SSH.png │ ├── jenkins.avail.png │ ├── jenkins.conn.png │ ├── jenkins.error.png │ ├── jenkins.item.png │ ├── jenkins.nodes.png │ ├── jenkins.right.png │ ├── jenkins.spot.png │ ├── jenkins.script.png │ ├── jenkins.testCre.png │ ├── alibabacloud_ak_sk.png │ ├── jenkins.cloudName.png │ ├── jenkins.configSpot.png │ ├── jenkins.provision.png │ ├── jenkins.rightspot.png │ ├── jenkins.sampleStep.png │ ├── jenkins_config_vpc.png │ ├── nail_group_qr_code.png │ ├── alibabacloud.keypair.png │ ├── jenkins.Credentials.png │ ├── jenkins.cloudDetail.png │ ├── jenkins.groovySandbox.png │ ├── jenkins.templateName.png │ ├── jenkins_configure_az.png │ ├── jenkins_configure_sg.png │ ├── configure_credentials_1.png │ ├── jenkins.cloudsConfigure.png │ ├── jenkins.detailFollower.png │ ├── jenkins.pipelineSyntax.png │ ├── jenkins_cloud_mechanism.png │ ├── jenkins_configure_image.png │ ├── jenkins_configure_name.png │ ├── alibabacloud.keypairgene.png │ ├── alibabacloud_plugin_market.png │ ├── jenkins.Credentials.check.png │ ├── jenkins.cloud.primaryKey.png │ ├── jenkins_configure_clouds.png │ ├── jenkins_configure_flavor.png │ ├── jenkins_configure_region.png │ ├── jenkins_configure_ssh_key.png │ ├── jenkins_credentials_kind.png │ ├── jenkins.generatePipelineScript.png │ └── jenkins_configure_instance_count.png ├── .gitignore ├── .github └── workflows │ └── jenkins-security-scan.yml ├── PIPELINESTEP.md ├── CHANGELOG.md ├── nasData.md └── LICENSE /Jenkinsfile: -------------------------------------------------------------------------------- 1 | buildPlugin() -------------------------------------------------------------------------------- /src/main/resources/lib/ecs/taglib: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/images/nas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/nas.png -------------------------------------------------------------------------------- /docs/images/nas_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/nas_1.png -------------------------------------------------------------------------------- /docs/images/nas_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/nas_2.png -------------------------------------------------------------------------------- /docs/images/nas_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/nas_3.png -------------------------------------------------------------------------------- /docs/images/nas_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/nas_4.png -------------------------------------------------------------------------------- /docs/images/nas_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/nas_5.png -------------------------------------------------------------------------------- /docs/images/nas_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/nas_6.png -------------------------------------------------------------------------------- /docs/images/nas_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/nas_7.png -------------------------------------------------------------------------------- /docs/images/qrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/qrcode.png -------------------------------------------------------------------------------- /docs/images/jenkins.SSH.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.SSH.png -------------------------------------------------------------------------------- /docs/images/jenkins.avail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.avail.png -------------------------------------------------------------------------------- /docs/images/jenkins.conn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.conn.png -------------------------------------------------------------------------------- /docs/images/jenkins.error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.error.png -------------------------------------------------------------------------------- /docs/images/jenkins.item.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.item.png -------------------------------------------------------------------------------- /docs/images/jenkins.nodes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.nodes.png -------------------------------------------------------------------------------- /docs/images/jenkins.right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.right.png -------------------------------------------------------------------------------- /docs/images/jenkins.spot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.spot.png -------------------------------------------------------------------------------- /docs/images/jenkins.script.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.script.png -------------------------------------------------------------------------------- /docs/images/jenkins.testCre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.testCre.png -------------------------------------------------------------------------------- /docs/images/alibabacloud_ak_sk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/alibabacloud_ak_sk.png -------------------------------------------------------------------------------- /docs/images/jenkins.cloudName.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.cloudName.png -------------------------------------------------------------------------------- /docs/images/jenkins.configSpot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.configSpot.png -------------------------------------------------------------------------------- /docs/images/jenkins.provision.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.provision.png -------------------------------------------------------------------------------- /docs/images/jenkins.rightspot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.rightspot.png -------------------------------------------------------------------------------- /docs/images/jenkins.sampleStep.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.sampleStep.png -------------------------------------------------------------------------------- /docs/images/jenkins_config_vpc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins_config_vpc.png -------------------------------------------------------------------------------- /docs/images/nail_group_qr_code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/nail_group_qr_code.png -------------------------------------------------------------------------------- /docs/images/alibabacloud.keypair.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/alibabacloud.keypair.png -------------------------------------------------------------------------------- /docs/images/jenkins.Credentials.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.Credentials.png -------------------------------------------------------------------------------- /docs/images/jenkins.cloudDetail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.cloudDetail.png -------------------------------------------------------------------------------- /docs/images/jenkins.groovySandbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.groovySandbox.png -------------------------------------------------------------------------------- /docs/images/jenkins.templateName.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.templateName.png -------------------------------------------------------------------------------- /docs/images/jenkins_configure_az.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins_configure_az.png -------------------------------------------------------------------------------- /docs/images/jenkins_configure_sg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins_configure_sg.png -------------------------------------------------------------------------------- /docs/images/configure_credentials_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/configure_credentials_1.png -------------------------------------------------------------------------------- /docs/images/jenkins.cloudsConfigure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.cloudsConfigure.png -------------------------------------------------------------------------------- /docs/images/jenkins.detailFollower.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.detailFollower.png -------------------------------------------------------------------------------- /docs/images/jenkins.pipelineSyntax.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.pipelineSyntax.png -------------------------------------------------------------------------------- /docs/images/jenkins_cloud_mechanism.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins_cloud_mechanism.png -------------------------------------------------------------------------------- /docs/images/jenkins_configure_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins_configure_image.png -------------------------------------------------------------------------------- /docs/images/jenkins_configure_name.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins_configure_name.png -------------------------------------------------------------------------------- /docs/images/alibabacloud.keypairgene.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/alibabacloud.keypairgene.png -------------------------------------------------------------------------------- /docs/images/alibabacloud_plugin_market.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/alibabacloud_plugin_market.png -------------------------------------------------------------------------------- /docs/images/jenkins.Credentials.check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.Credentials.check.png -------------------------------------------------------------------------------- /docs/images/jenkins.cloud.primaryKey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.cloud.primaryKey.png -------------------------------------------------------------------------------- /docs/images/jenkins_configure_clouds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins_configure_clouds.png -------------------------------------------------------------------------------- /docs/images/jenkins_configure_flavor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins_configure_flavor.png -------------------------------------------------------------------------------- /docs/images/jenkins_configure_region.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins_configure_region.png -------------------------------------------------------------------------------- /docs/images/jenkins_configure_ssh_key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins_configure_ssh_key.png -------------------------------------------------------------------------------- /docs/images/jenkins_credentials_kind.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins_credentials_kind.png -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-systemDiskSize_zh_CN.html: -------------------------------------------------------------------------------- 1 |
2 | 系统盘大小,单位为GiB。取值范围:20~500。 3 |
-------------------------------------------------------------------------------- /docs/images/jenkins.generatePipelineScript.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins.generatePipelineScript.png -------------------------------------------------------------------------------- /docs/images/jenkins_configure_instance_count.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/alibabacloud-ecs-plugin/HEAD/docs/images/jenkins_configure_instance_count.png -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaCloud/help-vpc_zh_CN.html: -------------------------------------------------------------------------------- 1 |
2 | VPC ID 将用于创建ECS实例。
3 | 示例:"vpc-dweqdxdaadqdfadqw" 4 |
5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.DS_Store 2 | *.classpath 3 | *.settings 4 | *.project 5 | *.iml 6 | *.idea 7 | target 8 | logs 9 | aliyun-ecs/test-output* 10 | aliyun-ecs/bin 11 | work -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-systemDiskSize.html: -------------------------------------------------------------------------------- 1 |
2 | The size of the system disk, in GiB. Ranges:20~500。 3 |
-------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-minimumNumberOfInstances_zh_CN.html: -------------------------------------------------------------------------------- 1 |
2 | 最小实例数是用于生成节点的数量。
3 | 此插件将根据填写的数字创建子节点。 4 |
-------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/WindowsData/help-password_zh_CN.html: -------------------------------------------------------------------------------- 1 |
2 | 实例登陆密码,8~30 个字符,必须同时包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号),不能以斜线号(/)开头 3 |
-------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-snapshotId_zh_CN.html: -------------------------------------------------------------------------------- 1 |
2 | 创建数据盘的快照
3 | 实际创建的云盘大小为指定的快照的大小。不能使用早于2013年7月15日(含)创建的快照,请求会报错被拒绝。 4 |
-------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaCloud/help-securityGroup_zh_CN.html: -------------------------------------------------------------------------------- 1 |
2 | 新创建实例所属于的安全组ID。同一个安全组内的实例之间可以互相访问,一个安全组能容纳的实例数量视安全组类型而定。
3 | 示例:sg-bp15ed6xe1yxeycg7**** 4 |
-------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-instanceCapStr_zh_CN.html: -------------------------------------------------------------------------------- 1 |
2 | 限制从该模板启动的正在运行的实例总数,为空表示不限制。主要用于及控制ECS使用成本。 3 | 一旦实例数到达上限,额外的负载将执行排队等待,构建频率将降低。 4 |
-------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-launchTimeoutStr_zh_CN.html: -------------------------------------------------------------------------------- 1 |
2 | 等待SSH与新的从节点实例的链接完成的秒数,不填或为零时表示没有超时时间。
3 | 如果在该时间范围内无法与worker节点建立SSH, 则默认会删除掉该节点.
4 |
-------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/WindowsData/config.properties: -------------------------------------------------------------------------------- 1 | Windows_Admin_Password=Windows Admin Password 2 | Use_HTTPS=Use HTTPS 3 | Allow_Self_Signed_Certificate=Allow Self Signed Certificate 4 | Boot_Delay=Boot Delay -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/win/winrm/request/WinRMRequest.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.win.winrm.request; 2 | 3 | import org.dom4j.Document; 4 | 5 | public interface WinRMRequest { 6 | Document build(); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-instanceType_zh_CN.html: -------------------------------------------------------------------------------- 1 |
2 | 待创建实例的实例规格的ID。 3 |

4 | 已上线的实例规格请参见 选择实例规格 5 |

-------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsStep/help.html: -------------------------------------------------------------------------------- 1 |
2 | Creates an Aliyun ECS Spot Instance object, from an already globally defined cloud name and template without registering it as a Jenkins agent. 3 |
-------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaCloud/help-region_zh_CN.html: -------------------------------------------------------------------------------- 1 |
2 | 标识阿里云应用所在的地域。 3 | 查看阿里云地域获取所有支持的地域列表
4 | 样例: cn-hangzhou 5 |
-------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-remoteAdmin_zh_CN.html: -------------------------------------------------------------------------------- 1 |
2 | 该字段是可选的。指定用于使用 ssh 访问实例的用户名。使用windows镜像时需要将该参数指定为Administrator。指定自定义的用户名, 3 | 使用自定义用户名时需要注意该用户名必须在使用的镜像中已经创建。不指定此项,默认为“root” 4 |
5 | 6 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-launchTimeoutStr.html: -------------------------------------------------------------------------------- 1 |
2 | Number of seconds to wait for the ssh connection to the new slave instance to 3 | finish. Blank or zero here indicates no timeout/wait forever. 4 |
-------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-userData_zh_CN.html: -------------------------------------------------------------------------------- 1 |
2 | 实例自定义数据,不需要进行Base64编码,源码传入即可,原始数据最多为16 KB.
3 | 示例:
4 | 5 | #!/bin/sh
6 | echo 'hello world!' 7 |
8 |
-------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-image_zh_CN.html: -------------------------------------------------------------------------------- 1 |
2 | 镜像ID,启动实例时选择的镜像资源。
3 | 示例值:ubuntu_22_04_x64_20G_alibase_20220628.vhd 4 | 更多镜像请参见 公共镜像 5 |
-------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-instanceNamePrefix_zh_CN.html: -------------------------------------------------------------------------------- 1 |
2 | 实例名称前缀,和需要运行的任务名称之和不能超过128个英文或中文字符。
3 | 必须以大小字母或中文开头。
4 | 不能以http://或https://开头。
5 | 可以包含数字、半角冒号(:)、下划线(_)或者短划线(-)。
6 |
-------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-minimumNumberOfInstances.html: -------------------------------------------------------------------------------- 1 |
2 | The minimum number of instances is the number used to spawn nodes.
3 | This plugin will create child nodes based on the numbers filled in. 4 |
-------------------------------------------------------------------------------- /src/main/resources/index.jelly: -------------------------------------------------------------------------------- 1 | 2 |
3 | This plugin integrates Jenkins with 4 | Alibaba Cloud ECS 5 | or anything implementing 6 | the ECS API's such as an CentOS. 7 |
8 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-zone_zh_CN.html: -------------------------------------------------------------------------------- 1 |
2 | 待创建实例所属的可用区ID。
3 | 查看阿里云地域&可用区获取所有支持的可用区列表
4 | 示例:cn-hangzhou-a 5 |
-------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-vsw_zh_CN.html: -------------------------------------------------------------------------------- 1 |
2 | 虚拟交换机ID, 交换机(vSwitch)是组成专有网络的基础网络设备,用来连接不同的云资源实例。 3 | 专有网络是地域级别的资源,专有网络不可以跨地域,但包含所属地域的所有可用区。 4 | 您可以在每个可用区内创建一个或多个交换机来划分子网。
5 | 示例:vsw-bp1s5fnvk4gn2tws0**** 6 |
-------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/WindowsData/config_zh_CN.properties: -------------------------------------------------------------------------------- 1 | Windows_Admin_Password=Windows \u7ba1\u7406\u5458\u5bc6\u7801 2 | Use_HTTPS=\u4f7f\u7528 HTTPS 3 | Allow_Self_Signed_Certificate=\u5141\u8bb8\u81ea\u7b7e\u540d\u8bc1\u4e66 4 | Boot_Delay=\u542f\u52a8\u5ef6\u8fdf -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/WindowsData/help-password.html: -------------------------------------------------------------------------------- 1 |
2 | Instance login password, 8~30 characters, including three items (uppercase, lowercase, numbers, numbers, ()`~@#$%^&*_=|{}[]:;'<> ,.?/ special symbols in the middle order), cannot be preceded by a slash (/) 3 |
4 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaCloud/help-attachPublicIp_zh_CN.html: -------------------------------------------------------------------------------- 1 |
2 | Cloud自动创建的worker节点, 是否需要自动设置公网IP. 3 |
  • 如果您的JenkinsMaster部署在非阿里云环境, 则通常需要设置公网IP, 以便后续JenkinsMaster能够通过公网IP与worker节点通信
  • 4 |
  • 如果您的JenkinsMaster部署在阿里云上, 则无需配置该选项, 可以通过私网IP访问到worker节点
  • 5 |
    -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaCloud/help-sshKey_zh_CN.html: -------------------------------------------------------------------------------- 1 |
    2 | 阿里云SSH密钥对是一种安全便捷的登录认证方式,由公钥和私钥组成,仅支持Linux实例。 3 |

    4 | 私钥使用未加密的PEM(Privacy-Enhanced Mail)编码的PKCS#8格式。 5 | ECS密钥对的私钥以 "-----BEGIN RSA PRIVATE KEY-----" 开头。
    6 | 推荐设置凭据ID为在阿里云控制台上已创建密钥的名称。 7 |

    -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/WindowsData/help-bootDelay_zh_CN.html: -------------------------------------------------------------------------------- 1 |
    2 | 在此指示插件检测到 WinRM 可用后等待机器准备就绪的时间(以秒为单位)。 3 | 但是在 Windows 上,在启动过程中,WinRM 服务可能会启动,然后几分钟后会重新启动。 4 | 如果在 Jenkins 执行代理配置期间发生此重新启动,Windows 将阻止 WinRM 客户端再次连接,并且 5 | 代理将无法正确配置。 6 |
    7 | 已发现安全值是 3 分钟。 8 |
    -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaCloud/help-vpc.html: -------------------------------------------------------------------------------- 1 |
    2 | Virtual Private Cloud (VPC for short), 3 | you need to specify the VPC ID that has been created in Alibaba CLOUD. 4 | The VPC ID will be used to create an ECS instance.
    5 | Example:"vpc-dweqdxdaadqdfadqw" 6 |
    7 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-instanceType.html: -------------------------------------------------------------------------------- 1 |
    2 | ID of the instance type of the instance to be created. 3 |

    4 | For online instance specifications, see Choose an instance type 5 |

    -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-maxTotalUses_zh_CN.html: -------------------------------------------------------------------------------- 1 |
    2 | 可选值为:
    3 | - 0: 代表不限制复用次数, 即该节点会常驻, 可以执行不限次数的构建, 直到手动销毁或者空闲时长超过阈值导致销毁.
    4 | - 1: 代表该节点只能执行一次构建, 构建结束, 节点就立即销毁.
    5 | - 2~N: 代表节点可以执行2~N次构建. 没执行一次构建, 剩余构建次数递减1, 直到为0时销毁.
    6 |
    -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-initScript_zh_CN.html: -------------------------------------------------------------------------------- 1 |
    2 | Init脚本是在Jenkins开始启动跟随者节点之前在新启动的跟随者节点实例上运行的Shell脚本。
    3 | 这也是安装构建和测试所需的其他软件包的好地方。
    4 | 样例:
    5 | 6 | #!/bin/bash
    7 | sudo yum install -y net-tools 8 |
    9 |
    -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/win/winrm/WinRMConnectException.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.win.winrm; 2 | 3 | public class WinRMConnectException extends RuntimeIOException { 4 | 5 | public WinRMConnectException(String message, Throwable cause) { 6 | super(message, cause); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-image.html: -------------------------------------------------------------------------------- 1 |
    2 | Image ID, the image resource selected when starting the instance.
    3 | Example:ubuntu_22_04_x64_20G_alibase_20220628.vhd 4 | For more images, see public image 5 |
    -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-userData.html: -------------------------------------------------------------------------------- 1 |
    2 | Instance custom data, Base64 encoding is NOT required, the source code can be passed in, and the original data is up to 16 KB.
    3 | Example:
    4 | 5 | #!/bin/sh
    6 | echo 'hello world!' 7 |
    8 |
    -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-systemDiskCategory_zh_CN.html: -------------------------------------------------------------------------------- 1 |
    2 | 系统盘的云盘种类,可选择的云盘种类如下:
    3 |
  • cloud:普通云盘。
  • 4 |
  • cloud_efficiency:高效云盘。
  • 5 |
  • cloud_ssd:SSD云盘。
  • 6 |
  • cloud_essd:ESSD云盘。
  • 7 | 注意: ECS的 c7/g7/r7 规格族只支持 cloud_essd 类型云盘 8 |
    -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaCloud/help-noDelayProvisioning_zh_CN.html: -------------------------------------------------------------------------------- 1 | 默认情况下, Jenkins会评估当前构建队列中的任务数量与worker节点的繁忙程度, 从而避免过多地新建worker节点;
    2 | 如果勾选了该项, 则一旦构建队列中有任务积压, 则不会等待已有的worker节点结束工作, 而是会立刻新建worker节点来执行队里中的构建任务.
    3 | 勾选该项, 优点是队列中任务能迅速引发新建节点从而迅速完成构建, 缺点是任务结束后可能导致闲置的worker节点数量过多从而引发额外费用问题; 此时建议调整节点的 "Idle Termination Time In Minutes" 参数来缓解该问题
    4 |
    -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaCloud/help-securityGroup.html: -------------------------------------------------------------------------------- 1 |
    2 | ID of the security group to which the newly created instance belongs. 3 | Instances in the same security group can access each other. 4 | The number of instances that a security group can accommodate depends on the security group type.
    5 | Example: sg-bp15ed6xe1yxeycg7**** 6 |
    -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-zone.html: -------------------------------------------------------------------------------- 1 |
    2 | ID of the Availability Zone to which the instance to be created belongs.
    3 | See Alibaba Cloud documentation 4 | for more about what Availability Zone are.
    5 | Example:cn-hangzhou-a 6 |
    -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaCloud/help-noDelayProvisioning.html: -------------------------------------------------------------------------------- 1 | By default Jenkins do estimate load to avoid over-provisioning of cloud nodes. 2 | With this option enabled, a new node is created on Alibaba Cloud as soon as NodeProvisioner detects need for more agents. 3 | In worse scenarios, this will results in some extra nodes provisioned on ECS, which will be shortly terminated. -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-instanceCapStr.html: -------------------------------------------------------------------------------- 1 |
    2 | Limit the total number of running instances launched from this template, empty means no limit. Mainly used to 3 | control the cost of using ECS. 4 | Once the number of instances reaches the upper limit, additional loads will be queued and the build frequency will 5 | be reduced. 6 |
    -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaCloud/help-intranetMaster_zh_CN.html: -------------------------------------------------------------------------------- 1 |
    2 | 当前Jenkins Master是否部署在VPC内网环境中(即是否有访问公网的权限). 3 |
  • 如果您的Jenkins Master部署在内网环境中(即没有访问公网权限), 请勾选此项, 后续插件调用阿里云SDK会使用VPC私网域名进行请求.
  • 4 |
  • 如果在公网环境中(即有访问公网权限), 则无需勾选此项, 后续调用阿里云SDK会使用公网域名进行请求.
  • 5 |
  • 如果不勾选此项, 默认会使用公网域名进行访问, 如果无访问权限, 后续使用该插件会出现"ConnectTimeoutException"异常
  • 6 |
    -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaCloud/help-region.html: -------------------------------------------------------------------------------- 1 |
    2 | Specifies the geographic region in which your agents will run. Pick the region closest to you. 3 | Regions can be thought of as 4 | independent instances of ECS.
    5 | See Alibaba Cloud documentation 6 | for more about what regions are.
    7 | Example: cn-hangzhou 8 |
    -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-initScript.html: -------------------------------------------------------------------------------- 1 |
    2 | The Init script is a shell script that runs on the newly started follower node instance before Jenkins starts to start the follower node.
    3 | This is also a good place to install other packages needed for building and testing.
    4 | Example:
    5 | 6 | #!/bin/bash
    7 | sudo yum install -y net-tools 8 |
    9 |
    -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-numExecutors_zh_CN.html: -------------------------------------------------------------------------------- 1 |
    2 | Jenkins可以在此节点上执行的并发构建的最大数量。默认为4
    3 | 首先,一个不错的值是机器上的CPU内核数(查看《实例规格说明》获取CPU核数)。
    4 | 设置较高的值将导致每个构建花费更长的时间,但可能会增加整体吞吐量。
    5 | 例如,一个构建可能受CPU限制,而同时运行的第二个构建可能受I/O限制-因此,第二个构建此时可以利用备用I/O容量。 6 |

    7 | 对于主服务器,请将执行程序的数量设置为零,以防止其在本地执行构建。 注意:master始终可以运行包括管道的顶级任务在内的轻量级任务。 8 |
    9 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-systemDiskCategory.html: -------------------------------------------------------------------------------- 1 |
    2 | The cloud disk type of the system disk. The cloud disk types that can be selected are as follows:
    3 |
  • cloud_efficiency:Efficient cloud disk.
  • 4 |
  • cloud_ssd:SSD cloud disk.
  • 5 |
  • cloud_essd:ESSD cloud disk.
  • 6 |
  • cloud:Ordinary cloud disk.
  • 7 | Attention: c7/g7/r7 only support cloud_essd 8 |
    -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/win/winrm/soap/Option.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.win.winrm.soap; 2 | 3 | public class Option { 4 | private final String name; 5 | private final String value; 6 | 7 | public Option(String name, String value) { 8 | this.name = name; 9 | this.value = value; 10 | } 11 | 12 | public String getValue() { 13 | return value; 14 | } 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-vsw.html: -------------------------------------------------------------------------------- 1 |
    2 | Virtual switch ID, a switch (vSwitch) is a basic network device that forms a VPC and is used to connect different cloud resource instances. 3 | A VPC is a region-level resource. A VPC cannot span regions, but includes all the availability zones in the region to which it belongs. 4 | You can create one or more switches within each Availability Zone to divide the subnets.
    5 | Example:vsw-bp1s5fnvk4gn2tws0**** 6 |
    -------------------------------------------------------------------------------- /src/main/resources/lib/ecs/blockWrapper.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
    7 | 8 |
    9 |
    10 | 11 | 12 | 13 |
    14 |
    15 |
    16 |
    17 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-dataDiskId_zh_CN.html: -------------------------------------------------------------------------------- 1 |
    2 | 已有的云盘id
    3 | 当云盘需要挂载在多个实例上时的限制详见 NVMe云盘概述 4 | 当前使用的时块存储EBS,时延极低。吞吐数十Gbps,单ECS通过POSIX接口访问,随机读写
    5 | 当需要挂载的云盘为NVMe云盘时需要在初始化脚本,选择的已有云盘若为新云盘需要先格式化云盘
    6 | 7 | #!/bin/bash
    8 | mkdir /dev/xvdb
    9 | mount /dev/nvme0n1 /dev/xvdb
    10 | mount /dev/nvme1n1 /dev/xvdb
    11 |
    12 |
    -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaCloud/help-sshKey.html: -------------------------------------------------------------------------------- 1 |
    2 | Alibaba Cloud SSH key pair is a safe and convenient way of login authentication. It consists of a public key and a private key. It only supports Linux instances. 3 |

    4 | The private key is in unencrypted PEM (Privacy-Enhanced Mail) encoded PKCS#8 format. 5 | The private key of an ECS key pair starts with "-----BEGIN RSA PRIVATE KEY-----" .
    6 | It is recommended to set the credential ID to the name of the key created on the Alibaba Cloud console. 7 |

    -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaCloud/help-attachPublicIp.html: -------------------------------------------------------------------------------- 1 |
    2 | Whether the worker node automatically created by Cloud needs to set the public IP. 3 |
  • If your JenkinsMaster is deployed in a non-Alibaba cloud environment, you usually need to set the public IP so that the subsequent JenkinsMaster can communicate with the worker nodes through the public IP
  • 4 |
  • If your JenkinsMaster is deployed on Alibaba Cloud, you do not need to configure this option, you can access the worker node through the private IP
  • 5 |
    -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/WindowsData/help-bootDelay.html: -------------------------------------------------------------------------------- 1 |
    2 | Indicate here the time in seconds to wait for the machine to be ready once the plugin detects WinRM is available. 3 | Unfortunately, on Windows during the boot, the WinRM service might be started, and then several minutes after will be restarted. 4 | If this restart happens during the agent provisioning that Jenkins does, Windows will prevent the WinRM client to connect again and the 5 | agent will not be correctly provisioned. 6 |
    7 | A safe value has been found to be 3 minutes. 8 |
    -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/win/winrm/RuntimeIOException.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.win.winrm; 2 | 3 | @SuppressWarnings("serial") 4 | public class RuntimeIOException extends RuntimeException { 5 | public RuntimeIOException() { 6 | super(); 7 | } 8 | 9 | public RuntimeIOException(String message) { 10 | super(message); 11 | } 12 | 13 | public RuntimeIOException(Throwable cause) { 14 | super(cause); 15 | } 16 | 17 | public RuntimeIOException(String message, Throwable cause) { 18 | super(message, cause); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/AlibabaEcsComputerListener.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs; 2 | 3 | import hudson.Extension; 4 | import hudson.model.Computer; 5 | import hudson.model.TaskListener; 6 | import hudson.slaves.ComputerListener; 7 | 8 | /** 9 | * Created by kunlun.ykl on 2020/9/11. 10 | */ 11 | @Extension 12 | public class AlibabaEcsComputerListener extends ComputerListener { 13 | @Override 14 | public void onOnline(Computer c, TaskListener listener) { 15 | if (c instanceof AlibabaEcsComputer) { 16 | ((AlibabaEcsComputer)c).onConnected(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaCloud/config.properties: -------------------------------------------------------------------------------- 1 | Alibaba_Cloud_Credentials=Alibaba Cloud Credentials 2 | CredentialsDescription=Alibaba Cloud IAM Access Key used to connect to ECS. If not specified, implicit authentication mechanisms are used (IAM roles...) 3 | Region=Region 4 | VPC=VPC 5 | Security_Group=Security Group 6 | ECS_SSH_Key=ECS SSH Key 7 | Advanced=Advanced 8 | Assign_Public_Ip=Assign Public Ip 9 | Instance_Cap=Instance Cap 10 | No_delay_provisioning=No delay provisioning 11 | Test_Connection=Test Connection 12 | Images=Images 13 | ImagesDescription=List of Images to be launched as agents 14 | Name=Name -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/util/AlibabaEcsFactoryImpl.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.util; 2 | 3 | import com.aliyuncs.auth.AlibabaCloudCredentials; 4 | import hudson.Extension; 5 | import com.alibabacloud.jenkins.ecs.client.AlibabaEcsClient; 6 | 7 | /** 8 | * Created by kunlun.ykl on 2020/8/26. 9 | */ 10 | @Extension 11 | public class AlibabaEcsFactoryImpl implements AlibabaEcsFactory { 12 | 13 | @Override 14 | public AlibabaEcsClient connect(AlibabaCloudCredentials credentials, String regionNo, Boolean intranetMaster) { 15 | return new AlibabaEcsClient(credentials, regionNo, intranetMaster); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /.github/workflows/jenkins-security-scan.yml: -------------------------------------------------------------------------------- 1 | name: Jenkins Security Scan 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | types: [ opened, synchronize, reopened ] 9 | workflow_dispatch: 10 | 11 | permissions: 12 | security-events: write 13 | contents: read 14 | actions: read 15 | 16 | jobs: 17 | security-scan: 18 | uses: jenkins-infra/jenkins-security-scan/.github/workflows/jenkins-security-scan.yaml@v2 19 | with: 20 | java-cache: 'maven' # Optionally enable use of a build dependency cache. Specify 'maven' or 'gradle' as appropriate. 21 | # java-version: 21 # Optionally specify what version of Java to set up for the build, or remove to use a recent default. 22 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/util/EcsInstanceHelper.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.util; 2 | 3 | import com.aliyuncs.ecs.model.v20140526.DescribeInstancesResponse; 4 | 5 | import java.util.Date; 6 | 7 | public class EcsInstanceHelper { 8 | 9 | public static long getStartCostInSeconds(DescribeInstancesResponse.Instance instance) { 10 | String creationTime = instance.getCreationTime(); 11 | Date create = DateUtils.parse(creationTime); 12 | String startTime = instance.getStartTime(); 13 | Date start = DateUtils.parse(startTime); 14 | if (create == null || start == null) { 15 | return 0; 16 | } 17 | return (start.getTime() - create.getTime()) / 1000; 18 | } 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /PIPELINESTEP.md: -------------------------------------------------------------------------------- 1 | # AlibabaEcs Step pipeline 2 | 3 | ## 使用步骤 4 | 1. 配置ecs 模版配置 5 | ![](docs/images/jenkins.cloudDetail.png) 6 | 2. 新建一个流水线任务 7 | ![](docs/images/jenkins.item.png) 8 | 3. 点击流水线语法 9 | ![](docs/images/jenkins.pipelineSyntax.png) 10 | 4. 示例步骤 选择 alibabaEcs: Cloud template provisioning 11 | ![](docs/images/jenkins.sampleStep.png) 12 | 5. Alibaba Cloud name 选择刚创建模版名词 13 | ![](docs/images/jenkins.cloudName.png) 14 | 6. Template name 选择刚创建模版配置中的ecs模版描述 15 | ![](docs/images/jenkins.templateName.png) 16 | 7. 点击生成流水线脚本 17 | ![](docs/images/jenkins.generatePipelineScript%20.png) 18 | 8. 复制框中生成的脚本 19 | 9. 粘贴脚本到流水线中的脚本文本框内 20 | ![](docs/images/jenkins.script.png) 21 | 10. 不使用Groovy沙盘 22 | 23 | ![](docs/images/jenkins.groovySandbox.png) 24 | 11. 点击保存 25 | 12. 点击立即构建 -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/exception/AlibabaEcsException.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.exception; 2 | 3 | /** 4 | * Created by kunlun.ykl on 2020/9/25. 5 | */ 6 | public class AlibabaEcsException extends Exception { 7 | public AlibabaEcsException() { 8 | } 9 | 10 | public AlibabaEcsException(String message) { 11 | super(message); 12 | } 13 | 14 | public AlibabaEcsException(String message, Throwable cause) { 15 | super(message, cause); 16 | } 17 | 18 | public AlibabaEcsException(Throwable cause) { 19 | super(cause); 20 | } 21 | 22 | public AlibabaEcsException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 23 | super(message, cause, enableSuppression, writableStackTrace); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaCloud/config_zh_CN.properties: -------------------------------------------------------------------------------- 1 | Alibaba_Cloud_Credentials=\u963f\u91cc ECS \u51ed\u8bc1 2 | CredentialsDescription=\u7528\u4e8e\u8fde\u63a5 ECS \u7684\u963f\u91cc\u4e91 iam access key\u3002 \u5982\u679c\u672a\u6307\u5b9a\uff0c\u5219\u4f7f\u7528\u9690\u5f0f\u8eab\u4efd\u9a8c\u8bc1\u673a\u5236\uff08iam \u89d2\u8272...\uff09 3 | Region=\u5730\u57df 4 | VPC=\u865A\u62DF\u79C1\u6709\u4E91ID 5 | Security_Group=\u5b89\u5168\u7ec4ID 6 | ECS_SSH_Key=\u963f\u91cc\u4e91SSH\u5bc6\u94a5 7 | Advanced=\u9AD8\u7EA7... 8 | Assign_Public_Ip=\u662f\u5426\u8bbe\u7f6e\u516c\u7f51IP 9 | Instance_Cap=\u5b9e\u4f8b\u4e0a\u9650 10 | No_delay_provisioning=\u65e0\u5ef6\u8fdf\u4f9b\u5e94 11 | Test_Connection=\u6D4B\u8BD5\u8FDE\u63A5 12 | Images=ECS\u6a21\u7248 13 | ImagesDescription=List of Images to be launched as agents 14 | Name=\u540D\u5B57 -------------------------------------------------------------------------------- /src/test/java/com/alibabacloud/jenkins/ecs/util/DateUtilsTest.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.util; 2 | 3 | import org.junit.Test; 4 | 5 | import java.util.Calendar; 6 | import java.util.Date; 7 | 8 | public class DateUtilsTest { 9 | @Test 10 | public void parseTest() { 11 | String createTime = "2017-12-10T04:04Z"; 12 | Date parse = DateUtils.parse(createTime); 13 | System.out.println(parse); 14 | 15 | createTime = "2022-08-01T03:25Z"; 16 | parse = DateUtils.parse(createTime); 17 | System.out.println(parse.getTime()); 18 | } 19 | 20 | @Test 21 | public void formatTest() { 22 | String format = DateUtils.format(Calendar.getInstance().getTime()); 23 | System.out.println(format); 24 | Date parse = DateUtils.parse(format); 25 | System.out.println(parse); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/EcsTypeData.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs; 2 | 3 | import java.io.Serializable; 4 | import java.util.concurrent.TimeUnit; 5 | 6 | import hudson.model.AbstractDescribableImpl; 7 | 8 | public abstract class EcsTypeData extends AbstractDescribableImpl implements Serializable { 9 | private static final long serialVersionUID = 558886106677617487L; 10 | 11 | public abstract boolean isWindows(); 12 | 13 | public abstract boolean isUnix(); 14 | 15 | public abstract String getBootDelay(); 16 | 17 | public int getBootDelayInMillis() { 18 | if (getBootDelay() == null) { return 0; } 19 | try { 20 | return (int) TimeUnit.SECONDS.toMillis(Integer.parseInt(getBootDelay())); 21 | } catch (NumberFormatException nfe) { 22 | return 0; 23 | } 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/WindowsData/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-remoteFs_zh_CN.html: -------------------------------------------------------------------------------- 1 |
    2 |

    3 | 代理需要有一个专用于 Jenkins 的目录。指定代理上此目录的路径。最好用绝对路径, 4 | 例如 /var/jenkinsc:\jenkins. 5 | 这应该是代理计算机的本地路径。无需从控制器中看到此路径。 6 |

    7 | 代理不维护重要数据;所有作业配置、构建日志和工件存储在控制器上,因此可以使用临时目录作为代理根目录。 8 |
    9 | 通过为代理提供一个在机器重启后不会删除的目录,例如,代理可以缓存数据,例如工具安装,或 10 | 构建工作区。这可以防止不必要的工具下载或检查当构建开始在此代理上再次运行时再次输出源代码重启。 11 |

    12 | 如果您使用相对路径,例如 ./jenkins-agent, 路径将是相对于由提供的工作目录 13 | Launch method. 14 |

    23 |
    -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/win/winrm/request/DeleteShellRequest.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.win.winrm.request; 2 | 3 | import java.net.URI; 4 | import java.net.URISyntaxException; 5 | import java.net.URL; 6 | 7 | public class DeleteShellRequest extends AbstractWinRMRequest { 8 | 9 | private final String shellId; 10 | 11 | public DeleteShellRequest(URL url, String shellId) { 12 | super(url); 13 | this.shellId = shellId; 14 | } 15 | 16 | @Override 17 | protected void construct() { 18 | try { 19 | defaultHeader().action(new URI("http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete")).shellId(shellId).resourceURI(new URI("http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd")); 20 | 21 | setBody(null); 22 | } catch (URISyntaxException e) { 23 | throw new RuntimeException("Error while building request content", e); 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaCloud/help-intranetMaster.html: -------------------------------------------------------------------------------- 1 |
    2 | Whether the current Jenkins Master is deployed in the VPC intranet environment (that is, whether it has access to the public network). 3 |
  • If Jenkins Master is deployed in the intranet environment (that is, Jenkins Master do not have access to the public network), please check this option, and the subsequent plug-in calls to Alibaba Cloud SDK will use the VPC Private EndPoint name for requests.
  • 4 |
  • If Jenkins Master is in a public network environment (that is, you have access to the public network), you do not need to check this option. Subsequent calls to the Alibaba Cloud SDK will use the public Endpoint for requests.
  • 5 |
  • If you do not check this option, public API Endpoint will be used for access by default, which may lead to unreachable access, so the "ConnectTimeoutException" exception will occur when the plug-in is used later.
  • 6 |
    -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ### Version 1.5 (July 19, 2022) 4 | ### New features and improvements 5 | *** 6 | * Add support for vpc endpoint 7 | 8 | ### Dependency updates 9 | *** 10 | * alibabacloud-credentials from 1.0 to 1.1 11 | 12 | ## Version 1.5 (July 19, 2022) 13 | ### New features and improvements 14 | *** 15 | * Add noun notes 16 | 17 | ### Bug fixes 18 | *** 19 | * configuration cluster save updated System Disk Category and System Disk size 20 | 21 | ## Version 1.4 (July 18, 2022) 22 | ### New features and improvements 23 | *** 24 | * Add support system disk category 25 | * Add support system disk size 26 | * Add attach Public Ip 27 | 28 | 29 | ## Version 1.3 (Dec 22, 2020) 30 | - Add chinese readme index. 31 | - Delete allocate public ip method. 32 | 33 | ### Version 1.2 (Dec 3, 2020) 34 | - Fixed public IP connection error. 35 | 36 | ### Version 1.1 (Dec 2, 2020) 37 | - Added auto generate vsw function for easier node provisioning. 38 | 39 | ### Version 1.0 (Nov 20, 2020) 40 | - Initial release -------------------------------------------------------------------------------- /src/test/java/com/alibabacloud/jenkins/ecs/EcsTemplateStepExecutionTest.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs; 2 | 3 | import jenkins.model.Jenkins; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.mockito.Mock; 7 | import org.mockito.junit.MockitoJUnitRunner; 8 | 9 | /** 10 | * @author Alicia Doblas 11 | */ 12 | @RunWith(MockitoJUnitRunner.class) 13 | public class EcsTemplateStepExecutionTest { 14 | @Mock 15 | Jenkins jenkins; 16 | 17 | @Test 18 | public void tets() throws Exception { 19 | EcsTemplateStep step = new EcsTemplateStep(); 20 | step.setSystemDiskCategory("cloud_essd_PL0"); 21 | step.setDataDiskCategory("cloud_essd_PL0"); 22 | step.setNewDataDisk(true); 23 | step.setDataDiskSize("1"); 24 | step.setMountQuantity("1"); 25 | step.setMinimumNumberOfInstances("1"); 26 | EcsTemplateStepExecution stepExecution = new EcsTemplateStepExecution(step, null); 27 | stepExecution.start(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-numExecutors.html: -------------------------------------------------------------------------------- 1 |
    2 | The maximum number of concurrent builds that Jenkins may perform on this node.default: 4
    3 | A good value to start with would be the number of CPU cores on the machine(see the "Instance Types and 4 | Specifications" chapter of "Elastic Cloud Server Product 5 | Introduction" get the cpu number).
    6 | Setting a higher value would cause each build to take longer, but could increase the overall throughput. For 7 | example, one build might be CPU-bound, while a second build running at the same time might be I/O-bound — so the 8 | second build could take advantage of the spare I/O capacity at that moment. 9 |

    10 | For the master, set the number of executors to zero to prevent it from executing builds locally. Note: master will 11 | always be able to run flyweight tasks including Pipeline's top-level task. 12 |
    13 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/enums/DataDiskCategory.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.enums; 2 | 3 | public enum DataDiskCategory { 4 | cloud_ssd, 5 | cloud_efficiency, 6 | cloud, 7 | cloud_essd_PL0, 8 | cloud_essd_PL1, 9 | cloud_essd_PL2, 10 | cloud_essd_PL3; 11 | 12 | public static DataDiskCategory fromValue(String value) { 13 | if (value != null && !"".equals(value)) { 14 | DataDiskCategory[] var1 = values(); 15 | int var2 = var1.length; 16 | 17 | for (int var3 = 0; var3 < var2; ++var3) { 18 | DataDiskCategory enumEntry = var1[var3]; 19 | if (enumEntry.toString().equals(value)) { 20 | return enumEntry; 21 | } 22 | } 23 | throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); 24 | } else { 25 | throw new IllegalArgumentException("Value cannot be null or empty!"); 26 | } 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/enums/SystemDiskCategory.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.enums; 2 | 3 | public enum SystemDiskCategory { 4 | cloud_ssd, 5 | cloud_efficiency, 6 | cloud, 7 | cloud_essd_PL0, 8 | cloud_essd_PL1, 9 | cloud_essd_PL2, 10 | cloud_essd_PL3; 11 | 12 | public static SystemDiskCategory fromValue(String value) { 13 | if (value != null && !"".equals(value)) { 14 | SystemDiskCategory[] var1 = values(); 15 | int var2 = var1.length; 16 | 17 | for (int var3 = 0; var3 < var2; ++var3) { 18 | SystemDiskCategory enumEntry = var1[var3]; 19 | if (enumEntry.toString().equals(value)) { 20 | return enumEntry; 21 | } 22 | } 23 | throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); 24 | } else { 25 | throw new IllegalArgumentException("Value cannot be null or empty!"); 26 | } 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/util/Closeables.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.util; 2 | 3 | import java.io.Closeable; 4 | import java.io.IOException; 5 | import java.util.logging.Level; 6 | import java.util.logging.Logger; 7 | 8 | import edu.umd.cs.findbugs.annotations.Nullable; 9 | 10 | public class Closeables { 11 | private static Logger log = Logger.getLogger(Closeables.class.getCanonicalName()); 12 | 13 | /** 14 | * Quietly close a {@link Closeable}, logging any {@link IOException}s instead of throwing them. 15 | * 16 | * @param closeable The {@link Closeable} to close quietly. If null, then this method is a no-op. 17 | */ 18 | public static void closeQuietly(@Nullable Closeable closeable) { 19 | if (closeable == null) { 20 | return; 21 | } 22 | 23 | try { 24 | closeable.close(); 25 | } catch (IOException e) { 26 | log.log(Level.WARNING, "Failed to close resource, ignoring", e); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/ConnectionStrategy.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs; 2 | 3 | public enum ConnectionStrategy { 4 | 5 | PUBLIC_IP("Public IP"), 6 | 7 | PRIVATE_IP("Private IP"); 8 | 9 | private final String displayText; 10 | 11 | ConnectionStrategy(String displayText) { 12 | this.displayText = displayText; 13 | } 14 | 15 | /** 16 | * For backwards compatibility. 17 | * @param connectUsingPublicIp whether or not to use a public ip to establish a connection. 18 | * @param associatePublicIp whether or not to associate to a public ip. 19 | * @return an {@link ConnectionStrategy} based on provided parameters. 20 | */ 21 | public static ConnectionStrategy backwardsCompatible(boolean connectUsingPublicIp, boolean associatePublicIp) { 22 | if (connectUsingPublicIp || associatePublicIp) { 23 | return PUBLIC_IP; 24 | } else { 25 | return PRIVATE_IP; 26 | } 27 | } 28 | 29 | public String getDisplayText() { 30 | return this.displayText; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/util/AlibabaEcsFactory.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.util; 2 | 3 | import com.aliyuncs.auth.AlibabaCloudCredentials; 4 | import hudson.ExtensionPoint; 5 | import com.alibabacloud.jenkins.ecs.client.AlibabaEcsClient; 6 | import jenkins.model.Jenkins; 7 | 8 | /** 9 | * Created by kunlun.ykl on 2020/8/26. 10 | */ 11 | public interface AlibabaEcsFactory extends ExtensionPoint { 12 | static AlibabaEcsFactory getInstance() { 13 | AlibabaEcsFactory instance = null; 14 | for (AlibabaEcsFactory implementation : Jenkins.get().getExtensionList(AlibabaEcsFactory.class)) { 15 | if (instance != null) { 16 | throw new IllegalStateException("Multiple implementations of " + AlibabaEcsFactory.class.getName() 17 | + " found. If overriding, please consider using ExtensionFilter"); 18 | } 19 | instance = implementation; 20 | } 21 | return instance; 22 | } 23 | 24 | AlibabaEcsClient connect(AlibabaCloudCredentials credentials, String regionNo, Boolean intranetMaster); 25 | } 26 | -------------------------------------------------------------------------------- /nasData.md: -------------------------------------------------------------------------------- 1 | # 加速Java Maven构建 2 | 3 | 使用挂载 [NAS(文件存储)](https://help.aliyun.com/zh/nas/product-overview/what-is-nas?spm=a2c4g.11186623.0.0.17da61fd36UpTC) 加速 4 | Java Maven构建 5 | 6 | ## 使用步骤 7 | 8 | 1. 创建ecs 下载 maven 并配置maven的setting缓存目录为/data/nas/maven/cache 9 | 2. 在ecs上创建/data/nas目录 10 | ![](docs/images/nas.png) 11 | 3. 在[NAS控制台](https://nasnext.console.aliyun.com/cn-hangzhou/filesystem) 创建文件系统 12 | ![](docs/images/nas_1.png) 13 | 4. 点击创建出的文件系统 14 | ![](docs/images/nas_2.png) 15 | 5. 点击挂载使用,点击添加到ECS 16 | ![](docs/images/nas_3.png) 17 | 6. 点击挂载,选择刚配置maven的ecs 18 | ![](docs/images/nas_4.png) 19 | 7. 填写挂载路径为/data/nas, 默认开机自动挂载,选择协议类型为NFSv4.0(多台ECS同时编辑一个文件,请使用NFSv4.0),点击挂载 20 | ![](docs/images/nas_5.png) 21 | 8. 登录ecs使用 df-h 命令查看nas是否挂载 22 | ![](docs/images/nas_6.png) 23 | 9. 24 | 返回[ecs控制台](https://www.aliyun.com/product/ecs?spm=5176.28055625.J_3207526240.33.5861154aEUhMD6&scm=20140722.M_5288647._.V_1) 25 | ,点击更多,选择云盘和镜像创建自定义镜像 26 | ![](docs/images/nas_7.png) 27 | 10.使用jenkins插件创建ecs时镜像填写刚创建的镜像Id 28 | 29 | ## 注意 30 | 31 | 1. ECS 关联 VPC 必须跟挂载地址所在 VPC 相同,NAS 存储配置才能生效。 32 | 2. 文件系统所在可用区:华东 1 可用区 G。通用型 NAS 可跨可用区挂载,极速型不推荐跨可用区。 -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Alibaba Cloud 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 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/config.properties: -------------------------------------------------------------------------------- 1 | TestCreateEcs=TestCreateEcs 2 | Description=Description 3 | Image=Image 4 | Availability_Zone=Availability Zone 5 | VSW=VSW 6 | Instance_Charge_Type=Instance Charge Type 7 | Choose_Instance_Type=Choose Instance Type 8 | User_Data=User Data 9 | Remote_user=Remote user 10 | Init_Script=Init Script 11 | Labels=Labels 12 | Remote_FS_root=Remote FS root 13 | System_Disk_Category=System Disk Category 14 | System_Disk_Size=System Disk Size 15 | Instance_Cap=Instance Cap 16 | Minimum_number_of_instances=Minimum number of instances 17 | Idle_Termination_Time_In_Minutes=Idle Termination Time In Minutes 18 | IdleTTDesc=IdleTTDesc 19 | Number_of_Executors=Number of Executors 20 | Launch_Timeout_In_Seconds=Launch Timeout In Seconds 21 | Advanced=Advanced 22 | MountDataDisk=Mount Data Volume 23 | DataDiskCategory=DataVolumeCategory 24 | DataDiskSize=DataVolumeSize 25 | MountQuantity=MountQuantity 26 | ECS_Type=ECS Type 27 | Maximum_Total_Uses=Maximum Total Uses 28 | Instance_Name_Prefix=Instance Name Prefix 29 | DiskId=Disk Id 30 | NewDisk=Create new data volume 31 | SnapshotId=Snapshot Id 32 | 33 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/win/winrm/soap/MessageBuilder.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.win.winrm.soap; 2 | 3 | import org.dom4j.Document; 4 | import org.dom4j.DocumentHelper; 5 | import org.dom4j.Element; 6 | import org.dom4j.Namespace; 7 | import org.dom4j.QName; 8 | 9 | public class MessageBuilder { 10 | private final Document doc = DocumentHelper.createDocument(); 11 | private final Element envelope = doc.addElement(QName.get("Envelope", Namespaces.NS_SOAP_ENV)); 12 | 13 | public MessageBuilder() { 14 | for (Namespace ns : Namespaces.mostUsed()) { 15 | envelope.add(ns); 16 | } 17 | } 18 | 19 | public HeaderBuilder newHeader() { 20 | return new HeaderBuilder(); 21 | } 22 | 23 | public void addHeader(Header header) { 24 | Element elem = envelope.addElement(QName.get("Header", Namespaces.NS_SOAP_ENV)); 25 | header.toElement(elem); 26 | } 27 | 28 | public void addBody(Element body) { 29 | Element elem = envelope.addElement(QName.get("Body", Namespaces.NS_SOAP_ENV)); 30 | if (body != null) 31 | elem.add(body); 32 | } 33 | 34 | public Document build() { 35 | return doc; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/util/DateUtils.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.util; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | 5 | import java.text.DateFormat; 6 | import java.text.ParseException; 7 | import java.text.SimpleDateFormat; 8 | import java.util.Date; 9 | import java.util.TimeZone; 10 | 11 | 12 | @Slf4j 13 | public class DateUtils { 14 | private static final String pattern = "yyyy-MM-dd'T'HH:mm'Z'"; 15 | 16 | public static Date parse(String time) { 17 | TimeZone tz = TimeZone.getTimeZone("UTC"); 18 | try { 19 | DateFormat df = new SimpleDateFormat(pattern); 20 | df.setTimeZone(tz); 21 | return df.parse(time); 22 | } catch (ParseException e) { 23 | log.error("parse error. {}", time, e); 24 | } 25 | return null; 26 | } 27 | 28 | public static String format(Date time) { 29 | TimeZone tz = TimeZone.getTimeZone("UTC"); 30 | DateFormat df = new SimpleDateFormat(pattern); 31 | try { 32 | df.setTimeZone(tz); 33 | return df.format(time); 34 | } catch (Exception e) { 35 | log.error("format error. {}", time, e); 36 | } 37 | return null; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaCloud/computerSet.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 14 | 15 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/test/java/com/alibabacloud/jenkins/ecs/util/AlibabaEcsFactoryTest.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.util; 2 | 3 | import com.alibabacloud.jenkins.ecs.client.AlibabaEcsClient; 4 | import com.aliyuncs.auth.AlibabaCloudCredentials; 5 | import com.aliyuncs.auth.BasicCredentials; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.junit.Rule; 8 | import org.junit.Test; 9 | import org.jvnet.hudson.test.JenkinsRule; 10 | 11 | import static org.junit.Assert.assertNotNull; 12 | import static org.junit.Assert.assertTrue; 13 | 14 | /** 15 | * Created by kunlun.ykl on 2020/8/26. 16 | */ 17 | @Slf4j 18 | public class AlibabaEcsFactoryTest { 19 | @Rule 20 | public JenkinsRule r = new JenkinsRule(); 21 | 22 | @Test 23 | public void getInstanceTest() { 24 | AlibabaEcsFactory instance = AlibabaEcsFactory.getInstance(); 25 | assertTrue(instance instanceof AlibabaEcsFactoryImpl); 26 | } 27 | 28 | @Test 29 | public void connectTest() { 30 | String ak = ""; 31 | String sk = ""; 32 | AlibabaCloudCredentials credentials = new BasicCredentials(ak, sk); 33 | String endpointName = "cn-hangzhou"; 34 | AlibabaEcsClient connect = AlibabaEcsFactory.getInstance().connect(credentials, endpointName, true); 35 | assertNotNull(connect); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/UnixData.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs; 2 | 3 | import java.io.Serializable; 4 | import java.util.Objects; 5 | 6 | import hudson.Extension; 7 | import hudson.model.Descriptor; 8 | import org.kohsuke.stapler.DataBoundConstructor; 9 | 10 | public class UnixData extends EcsTypeData implements Serializable { 11 | 12 | @DataBoundConstructor 13 | public UnixData() {} 14 | 15 | @Override 16 | public boolean isWindows() { 17 | return false; 18 | } 19 | 20 | @Override 21 | public boolean isUnix() { 22 | return true; 23 | } 24 | 25 | @Override 26 | public String getBootDelay() { 27 | return null; 28 | } 29 | 30 | @Override 31 | public int hashCode() { 32 | return Objects.hash(); 33 | } 34 | 35 | @Override 36 | public boolean equals(Object obj) { 37 | if (this == obj){ 38 | return true; 39 | } 40 | if (obj == null){ 41 | return false; 42 | } 43 | if (this.getClass() != obj.getClass()){ 44 | return false; 45 | } 46 | return false; 47 | 48 | } 49 | 50 | @Extension 51 | public static class DescriptorImpl extends Descriptor { 52 | @Override 53 | public String getDisplayName() { 54 | return "unix"; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/win/winrm/request/GetOutputRequest.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.win.winrm.request; 2 | 3 | import java.net.URI; 4 | import java.net.URISyntaxException; 5 | import java.net.URL; 6 | 7 | import com.alibabacloud.jenkins.ecs.win.winrm.soap.Namespaces; 8 | import org.dom4j.DocumentHelper; 9 | import org.dom4j.Element; 10 | import org.dom4j.QName; 11 | 12 | public class GetOutputRequest extends AbstractWinRMRequest { 13 | 14 | private final String shellId, commandId; 15 | 16 | public GetOutputRequest(URL url, String shellId, String commandId) { 17 | super(url); 18 | this.shellId = shellId; 19 | this.commandId = commandId; 20 | } 21 | 22 | @Override 23 | protected void construct() { 24 | try { 25 | defaultHeader().action(new URI("http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Receive")).resourceURI(new URI("http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd")).shellId(shellId); 26 | 27 | Element body = DocumentHelper.createElement(QName.get("Receive", Namespaces.NS_WIN_SHELL)); 28 | body.addElement(QName.get("DesiredStream", Namespaces.NS_WIN_SHELL)).addAttribute("CommandId", commandId).addText("stdout stderr"); 29 | setBody(body); 30 | } catch (URISyntaxException e) { 31 | throw new RuntimeException("Error while building request content", e); 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-ecsType_zh_CN.html: -------------------------------------------------------------------------------- 1 |
    2 | 选择此代理使用的 ECS 类型: 3 |
      4 |
    • Unix:通过 ssh 连接。
    • 5 |
    • Windows:通过 CIFS 和 WinRM/WinRS 连接。
    • 6 |
    7 | 8 |
    9 | Windows ECS注意事项: 10 |
    11 | 通过 CIFS(发送初始 Jenkins agent.jar)和 WinRM 访问阿里巴巴 Windows 代理以启动和连接 12 | 之后给代理。 13 | 14 | 此 windows ECS 必须配置: 15 |
      16 |
    • 允许 SMB over TCP(传入 TCP 端口 445)和 WinRM(传入 TCP 端口 5985)的安全组
    • 17 |
    • Windows 防火墙应允许通过 TCP 传入 SMB
    • 18 |
    • java 应该已安装并在 %PATH% 中可用
    • 19 |
    • 应使用以下命令启用 WinRM(有关详细信息,请参阅:Microsoft article 555966): 20 |
        21 |
      • winrm quickconfig
      • 22 |
      • winrm set winrm/config/service/Auth '@{Basic="true"}'
      • 23 |
      • winrm set winrm/config/service '@{AllowUnencrypted="true"}'
      • 24 |
      • winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="10240"}'
      • 25 |
      • 对于 https: 26 |
          27 |
        • 生成 Windows 证书
        • 28 |
        • 安装证书
        • 29 |
        • winrm create winrm/config/Listener?Address=*+Transport=HTTPS '@{Hostname="HOSTNAME"; CertificateThumbprint="THUMBPRINT"}'
        • 30 |
        31 |
      • 32 |
      33 |
    • 34 |
    35 | 36 | 最后确保将用户名设置为管理员并输入管理员密码。 37 |
    38 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/win/winrm/request/SignalRequest.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.win.winrm.request; 2 | 3 | import java.net.URI; 4 | import java.net.URISyntaxException; 5 | import java.net.URL; 6 | 7 | import com.alibabacloud.jenkins.ecs.win.winrm.soap.Namespaces; 8 | import org.dom4j.DocumentHelper; 9 | import org.dom4j.Element; 10 | import org.dom4j.QName; 11 | 12 | public class SignalRequest extends AbstractWinRMRequest { 13 | 14 | private final String commandId, shellId; 15 | 16 | public SignalRequest(URL url, String shellId, String commandId) { 17 | super(url); 18 | this.commandId = commandId; 19 | this.shellId = shellId; 20 | } 21 | 22 | @Override 23 | protected void construct() { 24 | try { 25 | defaultHeader().action(new URI("http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Command")).resourceURI(new URI("http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd")).shellId(shellId); 26 | 27 | Element body = DocumentHelper.createElement(QName.get("Signal", Namespaces.NS_WIN_SHELL)).addAttribute("CommandId", commandId); 28 | 29 | body.addElement(QName.get("Code", Namespaces.NS_WIN_SHELL)).addText("http://schemas.microsoft.com/wbem/wsman/1/windows/shell/signal/terminate"); 30 | setBody(body); 31 | } catch (URISyntaxException e) { 32 | throw new RuntimeException("Error while building request content", e); 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/win/winrm/request/OpenShellRequest.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.win.winrm.request; 2 | 3 | import java.net.URI; 4 | import java.net.URISyntaxException; 5 | import java.net.URL; 6 | import java.util.Arrays; 7 | 8 | import com.alibabacloud.jenkins.ecs.win.winrm.soap.Namespaces; 9 | import com.alibabacloud.jenkins.ecs.win.winrm.soap.Option; 10 | import org.dom4j.DocumentHelper; 11 | import org.dom4j.Element; 12 | import org.dom4j.QName; 13 | 14 | public class OpenShellRequest extends AbstractWinRMRequest { 15 | 16 | public OpenShellRequest(URL url) { 17 | super(url); 18 | } 19 | 20 | protected void construct() { 21 | try { 22 | defaultHeader().action(new URI("http://schemas.xmlsoap.org/ws/2004/09/transfer/Create")).resourceURI(new URI("http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd")).options(Arrays.asList(new Option("WINRS_NOPROFILE", "FALSE"), new Option("WINRS_CODEPAGE", "437"))); 23 | 24 | Element body = DocumentHelper.createElement(QName.get("Shell", Namespaces.NS_WIN_SHELL)); 25 | body.addElement(QName.get("InputStreams", Namespaces.NS_WIN_SHELL)).addText("stdin"); 26 | body.addElement(QName.get("OutputStreams", Namespaces.NS_WIN_SHELL)).addText("stdout stderr"); 27 | setBody(body); 28 | } catch (URISyntaxException e) { 29 | throw new RuntimeException("Error while building request content", e); 30 | } 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsStep/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/win/winrm/request/ExecuteCommandRequest.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.win.winrm.request; 2 | 3 | import java.net.URI; 4 | import java.net.URISyntaxException; 5 | import java.net.URL; 6 | import java.util.Collections; 7 | 8 | import com.alibabacloud.jenkins.ecs.win.winrm.soap.Namespaces; 9 | import com.alibabacloud.jenkins.ecs.win.winrm.soap.Option; 10 | import org.dom4j.DocumentHelper; 11 | import org.dom4j.Element; 12 | import org.dom4j.QName; 13 | 14 | public class ExecuteCommandRequest extends AbstractWinRMRequest { 15 | 16 | private final String shellId; 17 | private final String command; 18 | 19 | public ExecuteCommandRequest(URL url, String shellId, String command) { 20 | super(url); 21 | this.command = command; 22 | this.shellId = shellId; 23 | } 24 | 25 | @Override 26 | protected void construct() { 27 | try { 28 | defaultHeader().action(new URI("http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Command")).resourceURI(new URI("http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd")).shellId(shellId).options(Collections.singletonList(new Option("WINRS_CONSOLEMODE_STDIN", "FALSE"))); 29 | 30 | Element body = DocumentHelper.createElement(QName.get("CommandLine", Namespaces.NS_WIN_SHELL)); 31 | body.addElement(QName.get("Command", Namespaces.NS_WIN_SHELL)).addText("\"" + command + "\""); 32 | setBody(body); 33 | } catch (URISyntaxException e) { 34 | throw new RuntimeException("Error while building request content", e); 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/EcsHostAddressProvider.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs; 2 | 3 | import java.util.List; 4 | import java.util.Optional; 5 | 6 | import com.aliyuncs.ecs.model.v20140526.DescribeInstancesResponse.Instance.VpcAttributes; 7 | import org.apache.commons.lang.StringUtils; 8 | 9 | import com.aliyuncs.ecs.model.v20140526.DescribeInstancesResponse.Instance; 10 | 11 | import static com.alibabacloud.jenkins.ecs.ConnectionStrategy.*; 12 | 13 | 14 | public class EcsHostAddressProvider { 15 | 16 | public static String windows(Instance instance, ConnectionStrategy strategy) { 17 | if (strategy.equals(PRIVATE_IP)) { 18 | return getPrivateIpAddress(instance); 19 | } else if (strategy.equals(PUBLIC_IP)) { 20 | return getPublicIpAddress(instance); 21 | } else { 22 | throw new IllegalArgumentException("Could not windows host address for strategy = " + strategy.toString()); 23 | } 24 | } 25 | 26 | 27 | private static String getPublicIpAddress(Instance instance) { 28 | List publicIpAddress = instance.getPublicIpAddress(); 29 | return publicIpAddress.get(0); 30 | } 31 | 32 | 33 | private static String getPrivateIpAddress(Instance instance) { 34 | VpcAttributes vpcAttributes = instance.getVpcAttributes(); 35 | List privateIpAddress = vpcAttributes.getPrivateIpAddress(); 36 | return privateIpAddress.get(0); 37 | } 38 | 39 | private static Optional filterNonEmpty(String value) { 40 | return Optional.ofNullable(value).filter(StringUtils::isNotEmpty); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/win/winrm/request/SendInputRequest.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.win.winrm.request; 2 | 3 | import java.net.URI; 4 | import java.net.URISyntaxException; 5 | import java.net.URL; 6 | import java.util.Base64; 7 | 8 | import com.alibabacloud.jenkins.ecs.win.winrm.soap.Namespaces; 9 | import org.dom4j.DocumentHelper; 10 | import org.dom4j.Element; 11 | import org.dom4j.QName; 12 | 13 | public class SendInputRequest extends AbstractWinRMRequest { 14 | 15 | private final String commandId, shellId; 16 | byte[] input; 17 | 18 | public SendInputRequest(URL url, byte[] input, String shellId, String commandId) { 19 | super(url); 20 | this.input = input.clone(); 21 | this.commandId = commandId; 22 | this.shellId = shellId; 23 | } 24 | 25 | @Override 26 | protected void construct() { 27 | try { 28 | defaultHeader().action(new URI("http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Send")).resourceURI(new URI("http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd")).shellId(shellId); 29 | 30 | Element body = DocumentHelper.createElement(QName.get("Send", Namespaces.NS_WIN_SHELL)); 31 | body.addElement(QName.get("Stream", Namespaces.NS_WIN_SHELL)) 32 | .addAttribute("Name", "stdin") 33 | .addAttribute("CommandId", commandId) 34 | .addText(Base64.getEncoder().encodeToString(input)); 35 | setBody(body); 36 | } catch (URISyntaxException e) { 37 | throw new RuntimeException("Error while building request content", e); 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/config_zh_CN.properties: -------------------------------------------------------------------------------- 1 | TestCreateEcs=\u6D4B\u8BD5\u521B\u5EFAECS 2 | Description=\u63cf\u8ff0 3 | Image=\u955c\u50cfID 4 | Availability_Zone=\u53ef\u7528\u533a 5 | VSW=\u865a\u62df\u4ea4\u6362\u673aID 6 | Instance_Charge_Type=\u4ed8\u8d39\u7c7b\u578b 7 | Choose_Instance_Type=\u5b9e\u4f8b\u89c4\u683c 8 | User_Data=\u81ea\u5b9a\u4e49\u6570\u636e 9 | Init_Script=\u521d\u59cb\u5316\u811a\u672c 10 | Labels=\u8282\u70b9\u6807\u7b7e 11 | Remote_FS_root=\u8fdc\u7a0b\u6839\u76ee\u5f55 12 | Remote_user=\u8fdc\u7a0b\u7528\u6237 13 | System_Disk_Category=\u7cfb\u7edf\u76d8\u7c7b\u578b 14 | System_Disk_Size=\u7cfb\u7edf\u76d8\u5927\u5c0f 15 | Instance_Cap=\u5b9e\u4f8b\u4e0a\u9650 16 | Minimum_number_of_instances=\u6700\u5C0F\u5B9E\u4F8B\u6570 17 | Idle_Termination_Time_In_Minutes=\u7a7a\u95f2\u7ec8\u6b62\u65f6\u95f4 18 | IdleTTDesc=\u4ECE\u8282\u70B9\u5728\u88AB\u7EC8\u6B62\u4E4B\u524D\u4FDD\u6301\u7A7A\u95F2\u72B6\u6001\u7684\u65F6\u95F4\uFF08\u5355\u4F4D\uFF1A\u5206\u949F\uFF09 19 | Number_of_Executors=\u6267\u884c\u8005\u6570\u91cf 20 | Launch_Timeout_In_Seconds=\u542f\u52a8\u8d85\u65f6\uff08\u5355\u4f4d\u4e3a\u79d2\uff09 21 | Advanced=\u9AD8\u7EA7... 22 | MountDataDisk=\u6302\u8f7d\u6570\u636e\u5377 23 | DataDiskCategory=\u6570\u636e\u5377\u7c7b\u578b 24 | DataDiskSize=\u6570\u636e\u5377\u5927\u5c0f 25 | MountQuantity=\u6570\u636e\u5377\u5927\u5c0f 26 | ECS_Type=\u7c7b\u578b 27 | Maximum_Total_Uses=\u5355\u8282\u70b9\u6700\u5927\u53ef\u590d\u7528\u6b21\u6570 28 | Instance_Name_Prefix=\u5b9e\u4f8b\u540d\u79f0\u524d\u7f00 29 | DiskId=\u4e91\u76d8id 30 | NewDisk=\u521b\u5efa\u65b0\u7684\u6570\u636e\u5377 31 | SnapshotId=\u5feb\u7167id 32 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/Messages_en.properties: -------------------------------------------------------------------------------- 1 | shutdown=Jenkins instance is quieting down 2 | terminating=Jenkins instance is terminating 3 | viaContextPath=/computer/ 4 | slaveTemplate_provision_error=slaveTemplate.provision error 5 | 6 | AlibabaECSCloud.NonUniqName=Duplicate Cloud Name 7 | AlibabaECSCloud.PermissionError=permission is error 8 | AlibabaECSCloud.NotSpecifiedCredentials=Credentials not specified 9 | AlibabaECSCloud.NotFoundCredentials=Credentials not found 10 | AlibabaECSCloud.IllegalAkSk=Illegal ak/sk: 11 | AlibabaECSCloud.NotSpecifiedSSHPrivateKey=SSH PrivateKey not specified 12 | AlibabaECSCloud.IllegalSSHPrivateKey=Illegal SSH PrivateKey: 13 | AlibabaECSCloud.ConnectionSuccess=Connection OK 14 | AlibabaECSCloud.SSHPrivateKeyValidateError=SSH PrivateKey validate error 15 | AlibabaECSCloud.NotSpecifiedDescription=Description not specified 16 | AlibabaECSCloud.MinimumNumberOfInstancesCheckError=Minimum number of instances must not be larger than AMI Instance Cap %d 17 | AlibabaECSCloud.MinimumNumberOfInstancesError=Minimum number of instances must be a non-negative integer (or null) 18 | AlibabaECSCloud.Success=Success 19 | AlibabaECSCloud.Error=Error 20 | AlibabaECSCloud.NotFoundInstanceType=instanceType not found 21 | AlibabaECSCloud.DiskQuantityError=Please fill in the correct data volume quantity。Current specs max support count: 22 | AlibabaECSCloud.NotFoundMountQuantity=Mount Quantity not specified 23 | AlibabaECSCloud.NotSpecifiedPassword=Password not specified 24 | abaECSCloud.DiskDoesNotExist=disk does not exist 25 | AlibabaECSCloud.MountMultipleDisksError=Disk does not support multiple attach 26 | AlibabaECSCloud.InstanceTypeDoesNotSupportMultiAttach=The instanceType of the specified instance does not support multi attach disk 27 | 28 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/win/winrm/soap/Namespaces.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.win.winrm.soap; 2 | 3 | import java.util.Arrays; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import org.dom4j.Namespace; 8 | 9 | public class Namespaces { 10 | public static final Namespace NS_SOAP_ENV = Namespace.get("env", "http://www.w3.org/2003/05/soap-envelope"); 11 | public static final Namespace NS_ADDRESSING = Namespace.get("a", "http://schemas.xmlsoap.org/ws/2004/08/addressing"); 12 | public static final Namespace NS_CIMBINDING = Namespace.get("b", "http://schemas.dmtf.org/wbem/wsman/1/cimbinding.xsd"); 13 | public static final Namespace NS_ENUM = Namespace.get("n", "http://schemas.xmlsoap.org/ws/2004/09/enumeration"); 14 | public static final Namespace NS_TRANSFER = Namespace.get("x", "http://schemas.xmlsoap.org/ws/2004/09/transfer"); 15 | public static final Namespace NS_WSMAN_DMTF = Namespace.get("w", "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"); 16 | public static final Namespace NS_WSMAN_MSFT = Namespace.get("p", "http://schemas.microsoft.com/wbem/wsman/1/wsman.xsd"); 17 | public static final Namespace NS_SCHEMA_INST = Namespace.get("xsi", "http://www.w3.org/2001/XMLSchema-instance"); 18 | public static final Namespace NS_WIN_SHELL = Namespace.get("rsp", "http://schemas.microsoft.com/wbem/wsman/1/windows/shell"); 19 | public static final Namespace NS_WSMAN_FAULT = Namespace.get("f", "http://schemas.microsoft.com/wbem/wsman/1/wsmanfault"); 20 | 21 | private Namespaces() { 22 | } 23 | 24 | public static final List mostUsed() { 25 | return Collections.unmodifiableList(Arrays.asList(NS_SOAP_ENV, NS_ADDRESSING, NS_WIN_SHELL, NS_WSMAN_DMTF, NS_WSMAN_MSFT)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/Messages.properties: -------------------------------------------------------------------------------- 1 | shutdown=Jenkins instance is quieting down 2 | terminating=Jenkins instance is terminating 3 | viaContextPath=/computer/ 4 | slaveTemplate_provision_error=slaveTemplate.provision error 5 | 6 | AlibabaECSCloud.NonUniqName=Duplicate Cloud Name 7 | AlibabaECSCloud.PermissionError=permission is error 8 | AlibabaECSCloud.NotSpecifiedCredentials=Credentials not specified 9 | AlibabaECSCloud.NotFoundCredentials=Credentials not found 10 | AlibabaECSCloud.IllegalAkSk=Illegal ak/sk: 11 | AlibabaECSCloud.NotSpecifiedSSHPrivateKey=SSH PrivateKey not specified 12 | AlibabaECSCloud.IllegalSSHPrivateKey=Illegal SSH PrivateKey: 13 | AlibabaECSCloud.ConnectionSuccess=Connection OK 14 | AlibabaECSCloud.SSHPrivateKeyValidateError=SSH PrivateKey validate error 15 | AlibabaECSCloud.NotSpecifiedDescription=Description not specified 16 | AlibabaECSCloud.MinimumNumberOfInstancesCheckError=Minimum number of instances must not be larger than AMI Instance Cap %d 17 | AlibabaECSCloud.MinimumNumberOfInstancesError=Minimum number of instances must be a non-negative integer (or null) 18 | AlibabaECSCloud.Success=Success 19 | AlibabaECSCloud.Error=Error 20 | AlibabaECSCloud.NotFoundInstanceType=instanceType not found 21 | AlibabaECSCloud.DiskQuantityError=Please fill in the correct data volume quantity。Current specs max support count: 22 | AlibabaECSCloud.NotFoundMountQuantity=Mount Quantity not specified 23 | OfflineCause.SSLException=The instance SSL Key check failed 24 | AlibabaECSCloud.NotSpecifiedPassword=Password not specified 25 | AlibabaECSCloud.DiskDoesNotExist=disk does not exist 26 | AlibabaECSCloud.MountMultipleDisksError=Disk does not support multiple attach 27 | AlibabaECSCloud.InstanceTypeDoesNotSupportMultiAttach=The instanceType of the specified instance does not support multi attach disk 28 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsTag/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 |
    39 | 40 |
    41 |
    42 |
    43 |
    44 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-ecsType.html: -------------------------------------------------------------------------------- 1 |
    2 | Choose the type of ECS this agent uses: 3 |
      4 |
    • Unix: connected to with ssh.
    • 5 |
    • Windows: connected to with CIFS and WinRM/WinRS.
    • 6 |
    7 | 8 |
    9 | Notes for Windows ECS: 10 |
    11 | Alibaba Windows agents are accessed with CIFS (to send the initial Jenkins agent.jar) and WinRM to launch and connect 12 | to the agent afterward. 13 | 14 | This windows ECS must be configured with: 15 |
      16 |
    • a security group allowing SMB over TCP (incoming TCP port 445) and WinRM (incoming TCP port 5985)
    • 17 |
    • windows firewall should allow incoming SMB over TCP
    • 18 |
    • java should be installed and available in the %PATH%
    • 19 |
    • WinRM should be enabled with the following commands (for more information see: Microsoft article 555966): 20 |
        21 |
      • winrm quickconfig
      • 22 |
      • winrm set winrm/config/service/Auth '@{Basic="true"}'
      • 23 |
      • winrm set winrm/config/service '@{AllowUnencrypted="true"}'
      • 24 |
      • winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="10240"}'
      • 25 |
      • For https: 26 | 31 |
      • 32 |
      33 |
    • 34 |
    35 | 36 | Finally make sure to set the username to Administrator and enter the administrator password. 37 |
    38 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/util/LogHelper.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.util; 2 | 3 | import java.io.PrintStream; 4 | import java.util.logging.Level; 5 | import java.util.logging.LogRecord; 6 | import java.util.logging.SimpleFormatter; 7 | 8 | import hudson.model.TaskListener; 9 | import org.slf4j.Logger; 10 | 11 | /** 12 | * Created by kunlun.ykl on 2020/9/25. 13 | */ 14 | public class LogHelper { 15 | private static final SimpleFormatter sf = new SimpleFormatter(); 16 | 17 | public static void debug(Logger logger, TaskListener listener, String message, Throwable e) { 18 | logger.debug(message, e); 19 | remoteLog(logger.getName(), Level.FINEST, listener, message, e); 20 | } 21 | 22 | public static void info(Logger logger, TaskListener listener, String message, Throwable e) { 23 | logger.info(message, e); 24 | remoteLog(logger.getName(), Level.INFO, listener, message, e); 25 | } 26 | 27 | public static void warn(Logger logger, TaskListener listener, String message, Throwable e) { 28 | logger.warn(message, e); 29 | remoteLog(logger.getName(), Level.WARNING, listener, message, e); 30 | } 31 | 32 | public static void error(Logger logger, TaskListener listener, String message, Throwable e) { 33 | logger.error(message, e); 34 | remoteLog(logger.getName(), Level.SEVERE, listener, message, e); 35 | } 36 | 37 | public static void remoteLog(String loggerName, Level level, TaskListener listener, String message, Throwable e) { 38 | if (listener != null) { 39 | if (e != null) { 40 | message += " Exception: " + e; 41 | } 42 | LogRecord lr = new LogRecord(level, message); 43 | lr.setLoggerName(loggerName); 44 | PrintStream printStream = listener.getLogger(); 45 | printStream.print(sf.format(lr)); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/win/winrm/NegotiateNTLMSchemaFactory.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.win.winrm; 2 | 3 | import org.apache.http.Header; 4 | import org.apache.http.HttpRequest; 5 | import org.apache.http.auth.AuthScheme; 6 | import org.apache.http.auth.AuthSchemeProvider; 7 | import org.apache.http.auth.AuthenticationException; 8 | import org.apache.http.auth.Credentials; 9 | import org.apache.http.auth.NTCredentials; 10 | import org.apache.http.client.config.AuthSchemes; 11 | import org.apache.http.impl.auth.NTLMScheme; 12 | import org.apache.http.message.BufferedHeader; 13 | import org.apache.http.protocol.HttpContext; 14 | import org.apache.http.util.CharArrayBuffer; 15 | 16 | public class NegotiateNTLMSchemaFactory implements AuthSchemeProvider { 17 | 18 | public AuthScheme create(HttpContext context) { 19 | return new NegotiateNTLM(); 20 | } 21 | 22 | public static class NegotiateNTLM extends NTLMScheme { 23 | @Override 24 | public String getSchemeName() { 25 | return AuthSchemes.SPNEGO; 26 | } 27 | 28 | @Override 29 | public Header authenticate(Credentials credentials, HttpRequest request) throws AuthenticationException { 30 | Credentials ntCredentials = credentials; 31 | if (!(credentials instanceof NTCredentials)) { 32 | ntCredentials = new NTCredentials(credentials.getUserPrincipal().getName(), credentials.getPassword(), null, null); 33 | } 34 | Header header = super.authenticate(ntCredentials, request); 35 | //need replace NTLM with Negotiate 36 | CharArrayBuffer buffer = new CharArrayBuffer(512); 37 | buffer.append(header.getName()); 38 | buffer.append(": "); 39 | buffer.append(header.getValue().replaceFirst("NTLM", "Negotiate")); 40 | return new BufferedHeader(buffer); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/Messages_zh_CN.properties: -------------------------------------------------------------------------------- 1 | shutdown=Jenkins instance is quieting down 2 | terminating=jenkins \u5b9e\u4f8b\u6b63\u5728\u7ec8\u6b62 3 | viaContextPath=/computer/ 4 | slaveTemplate_provision_error=slavetemplate.provision \u9519\u8bef 5 | 6 | AlibabaECSCloud.NonUniqName=\u91cd\u590d\u7684\u4e91\u540d\u79f0 7 | AlibabaECSCloud.PermissionError=\u6743\u9650\u662f\u9519\u8bef\u7684 8 | AlibabaECSCloud.NotSpecifiedCredentials=\u672a\u6307\u5b9a\u51ed\u636e 9 | AlibabaECSCloud.NotFoundCredentials=\u672a\u627e\u5230\u51ed\u636e 10 | AlibabaECSCloud.IllegalAkSk=\u975e\u6cd5ak/sk\uff1a 11 | AlibabaECSCloud.NotSpecifiedSSHPrivateKey=\u672a\u6307\u5b9a SSH \u79c1\u94a5 12 | AlibabaECSCloud.IllegalSSHPrivateKey=\u975e\u6cd5 SSH \u79c1\u94a5\uff1a 13 | AlibabaECSCloud.ConnectionSuccess=\u8fde\u63a5\u6b63\u5e38 14 | AlibabaECSCloud.SSHPrivateKeyValidateError=SSH \u79c1\u94a5\u9a8c\u8bc1\u9519\u8bef 15 | AlibabaECSCloud.NotSpecifiedDescription=\u672a\u6307\u5b9a\u63cf\u8ff0 16 | AlibabaECSCloud.MinimumNumberOfInstancesCheckError=\u6700\u5c0f\u5b9e\u4f8b\u6570\u4e0d\u5f97\u5927\u4e8e AMI \u5b9e\u4f8b\u4e0a\u9650 %d 17 | AlibabaECSCloud.MinimumNumberOfInstancesError=\u6700\u5c0f\u5b9e\u4f8b\u6570\u5fc5\u987b\u662f\u975e\u8d1f\u6574\u6570\uff08\u6216 null\uff09 18 | AlibabaECSCloud.Success=\u6210\u529f 19 | AlibabaECSCloud.Error=\u5f02\u5e38 20 | AlibabaECSCloud.NotFoundInstanceType=\u672a\u627e\u5230\u5b9e\u4f8b\u89c4\u683c 21 | AlibabaECSCloud.DiskQuantityError=\u8bf7\u586b\u5199\u6b63\u786e\u7684\u6570\u636e\u91cf\u3002\u5f53\u524d\u89c4\u683c\u6700\u5927\u652f\u6301\u6570\uff1a 22 | AlibabaECSCloud.NotFoundMountQuantity=\u672a\u6307\u5b9a\u6302\u8f7d\u6570\u91cf 23 | AlibabaECSCloud.NotSpecifiedPassword=\u672a\u6307\u5b9a\u5bc6\u7801 24 | abaECSCloud.DiskDoesNotExist=\u78c1\u76d8\u4e0d\u5b58\u5728 25 | AlibabaECSCloud.MountMultipleDisksError=\u6570\u636e\u5377\u4e0d\u652f\u6301\u591a\u6302\u8f7d 26 | AlibabaECSCloud.InstanceTypeDoesNotSupportMultiAttach=\u6307\u5b9a\u5b9e\u4f8b\u89c4\u683c\u4e0d\u652f\u6301\u591a\u6302\u76d8 -------------------------------------------------------------------------------- /src/test/java/com/alibabacloud/jenkins/ecs/AlibabaCloudTest.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs; 2 | 3 | import java.util.List; 4 | 5 | import com.alibabacloud.credentials.plugin.auth.AlibabaCredentials; 6 | import com.alibabacloud.credentials.plugin.util.CredentialsHelper; 7 | import com.google.common.collect.Lists; 8 | import org.junit.Rule; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.jvnet.hudson.test.JenkinsRule; 12 | import org.mockito.BDDMockito; 13 | import org.powermock.api.mockito.PowerMockito; 14 | import org.powermock.core.classloader.annotations.PowerMockIgnore; 15 | import org.powermock.core.classloader.annotations.PrepareForTest; 16 | import org.powermock.modules.junit4.PowerMockRunner; 17 | 18 | import static org.junit.Assert.assertNotNull; 19 | import static org.powermock.api.mockito.PowerMockito.when; 20 | 21 | /** 22 | * Created by kunlun.ykl on 2020/9/29. 23 | */ 24 | @PowerMockIgnore( 25 | {"javax.crypto.*", "org.hamcrest.*", "javax.net.ssl.*", "com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) 26 | @RunWith(PowerMockRunner.class) 27 | @PrepareForTest({CredentialsHelper.class}) 28 | public class AlibabaCloudTest { 29 | @Rule 30 | public JenkinsRule r = new JenkinsRule(); 31 | 32 | @Test 33 | public void cloudTest() { 34 | String credentialsId = "sampleCredentialsId"; 35 | String sshKey = null; 36 | AlibabaCredentials credentials = new AlibabaCredentials("ak", 37 | "sk"); 38 | PowerMockito.mockStatic(CredentialsHelper.class); 39 | BDDMockito.given(CredentialsHelper.getCredentials(credentialsId)).willReturn(credentials); 40 | when(CredentialsHelper.getCredentials(credentialsId)).thenReturn(credentials); 41 | List tags = Lists.newArrayList(); 42 | // AlibabaCloud cloud = new AlibabaCloud("testCloud", credentialsId, sshKey, "cn-beijing", "centos", "test-vpc", 43 | // "test-sg", "cn-beijing-a", "test-vsw", "ecs.c5.large", 1, 44 | // "", "", "", "", 20, false, false, tags ,"Spot"); 45 | // assertNotNull(cloud); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaEcsFollowerTemplate/help-remoteFs.html: -------------------------------------------------------------------------------- 1 |
    2 |

    3 | An agent needs to have a directory dedicated to Jenkins. Specify 4 | the path to this directory on the agent. It is best to use 5 | an absolute path, such as /var/jenkins or c:\jenkins. 6 | This should be a path local to the agent machine. There is no need for 7 | this path to be visible from the controller. 8 |

    9 | Agents do not maintain important data; all job configurations, build logs and 10 | artifacts are stored on the controller, so it would be possible to use a temporary 11 | directory as the agent root directory. 12 |
    13 | However, by giving an agent a directory that is not deleted after a machine 14 | reboot, for example, the agent can cache data such as tool installations, or 15 | build workspaces. This prevents unnecessary downloading of tools, or checking 16 | out source code again when builds start to run on this agent again after a 17 | reboot. 18 |

    19 | If you use a relative path, such as ./jenkins-agent, the path will be 20 | relative to the working directory provided by the Launch method. 21 |

      22 |
    • For launchers where Jenkins controls starting the agent process, such 23 | as SSH, the current working directory will typically be consistent, 24 | e.g. the user's home directory. 25 |
    • 26 |
    • For launchers where Jenkins has no control over starting the agent process, 27 | such as inbound agents launched from the command line, 28 | the current working directory may change between 29 | launches of the agent and use of a relative path may prove problematic. 30 |
      31 | The principal issue encountered when using relative paths with inbound launchers 32 | is the proliferation of stale workspaces and tool installation 33 | on the agent machine. This can cause disk space issues. 34 |
    • 35 |
    36 |
    37 | 38 | -------------------------------------------------------------------------------- /src/test/java/com/alibabacloud/jenkins/ecs/AlibabaEcsUnixComputerLauncherTest.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintStream; 5 | import java.util.List; 6 | 7 | import javax.annotation.Nonnull; 8 | 9 | import com.google.common.collect.Lists; 10 | import hudson.model.Descriptor.FormException; 11 | import hudson.model.TaskListener; 12 | import hudson.slaves.SlaveComputer; 13 | import org.junit.Ignore; 14 | import org.junit.Rule; 15 | import org.junit.Test; 16 | import org.jvnet.hudson.test.JenkinsRule; 17 | 18 | /** 19 | * Created by kunlun.ykl on 2020/8/25. 20 | */ 21 | @Ignore 22 | public class AlibabaEcsUnixComputerLauncherTest { 23 | @Rule 24 | public JenkinsRule r = new JenkinsRule(); 25 | 26 | @Test 27 | public void launchTest() throws IOException, FormException { 28 | AlibabaEcsUnixComputerLauncher launcher = new AlibabaEcsUnixComputerLauncher(); 29 | String ecsInstanceId = "i-abc"; 30 | String name = "hanting-test"; 31 | String remoteFS = "/root"; 32 | String cloudName = "alibaba-ecs-cloud"; 33 | String labelString = "myCI"; 34 | String initScript = ""; 35 | String templateName = "alibaba-ecs-cloud-t1"; 36 | String userData = "userData-test"; 37 | int numExecutors = 1; 38 | int launchTimeout = 10000; 39 | List tags = Lists.newArrayList(); 40 | String idleTerminationMinutes = "30"; 41 | UnixData unixData = new UnixData(); 42 | AlibabaEcsSpotFollower follower = new AlibabaEcsSpotFollower(ecsInstanceId, name, remoteFS, cloudName, 43 | labelString, initScript, templateName, numExecutors, launchTimeout, tags, idleTerminationMinutes, userData, 44 | unixData, "", 1, ""); 45 | r.jenkins.addNode(follower); 46 | 47 | SlaveComputer slaveComputer = new SlaveComputer(follower); 48 | TaskListener listener = new TaskListener() { 49 | @Nonnull 50 | @Override 51 | public PrintStream getLogger() { 52 | return System.out; 53 | } 54 | }; 55 | launcher.launch(slaveComputer, listener); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/AlibabaEcsComputerLauncher.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs; 2 | 3 | import com.alibabacloud.jenkins.ecs.exception.AlibabaEcsException; 4 | import hudson.model.Slave; 5 | import hudson.model.TaskListener; 6 | import hudson.slaves.ComputerLauncher; 7 | import hudson.slaves.SlaveComputer; 8 | 9 | import java.io.IOException; 10 | import java.util.logging.Level; 11 | import java.util.logging.Logger; 12 | 13 | /** 14 | * Created by kunlun.ykl on 2020/8/24. 15 | */ 16 | public abstract class AlibabaEcsComputerLauncher extends ComputerLauncher { 17 | private static final Logger LOGGER = Logger.getLogger(AlibabaEcsComputerLauncher.class.getName()); 18 | 19 | @Override 20 | public void launch(SlaveComputer slaveComputer, TaskListener listener) { 21 | try { 22 | launchScript((AlibabaEcsComputer) slaveComputer, listener); 23 | } catch (AlibabaEcsException | IOException e) { 24 | e.printStackTrace(listener.error(e.getMessage())); 25 | Slave node = slaveComputer.getNode(); 26 | if (node != null && node instanceof AlibabaEcsSpotFollower) { 27 | LOGGER.log(Level.WARNING, String.format("Terminating the ecs agent %s due a problem launching or connecting to it", slaveComputer.getName()), e); 28 | ((AlibabaEcsSpotFollower) node).terminate(); 29 | } 30 | } catch (InterruptedException e) { 31 | Thread.currentThread().interrupt(); 32 | e.printStackTrace(listener.error(e.getMessage())); 33 | Slave node = slaveComputer.getNode(); 34 | if (node != null && node instanceof AlibabaEcsSpotFollower) { 35 | LOGGER.log(Level.WARNING, String.format("Terminating the ecs agent %s due a problem launching or connecting to it", slaveComputer.getName()), e); 36 | ((AlibabaEcsSpotFollower) node).terminate(); 37 | } 38 | } 39 | } 40 | 41 | /** 42 | * Stage 2 of the launch. Called after the ECS instance comes up. 43 | */ 44 | protected abstract void launchScript(AlibabaEcsComputer computer, TaskListener listener) throws AlibabaEcsException, IOException, InterruptedException; 45 | } 46 | -------------------------------------------------------------------------------- /src/main/resources/com/alibabacloud/jenkins/ecs/AlibabaCloud/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/win/winrm/request/AbstractWinRMRequest.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.win.winrm.request; 2 | 3 | import java.net.URI; 4 | import java.net.URISyntaxException; 5 | import java.net.URL; 6 | import java.util.UUID; 7 | 8 | import com.alibabacloud.jenkins.ecs.win.winrm.soap.HeaderBuilder; 9 | import com.alibabacloud.jenkins.ecs.win.winrm.soap.MessageBuilder; 10 | import org.dom4j.Document; 11 | import org.dom4j.Element; 12 | 13 | public abstract class AbstractWinRMRequest implements WinRMRequest { 14 | 15 | protected MessageBuilder message = new MessageBuilder(); 16 | protected HeaderBuilder header = message.newHeader(); 17 | 18 | protected String timeout = "PT60S"; 19 | protected int envelopSize = 153600; 20 | protected String locale = "en-US"; 21 | 22 | protected URL url; 23 | 24 | public AbstractWinRMRequest(URL url) { 25 | this.url = url; 26 | } 27 | 28 | protected abstract void construct(); 29 | 30 | public Document build() { 31 | construct(); 32 | return message.build(); 33 | } 34 | 35 | protected HeaderBuilder defaultHeader() throws URISyntaxException { 36 | return header.to(url.toURI()).replyTo(new URI("http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous")).maxEnvelopeSize(envelopSize).id(generateUUID()).locale(locale).timeout(timeout); 37 | } 38 | 39 | protected void setBody(Element body) { 40 | message.addHeader(header.build()); 41 | message.addBody(body); 42 | } 43 | 44 | protected String generateUUID() { 45 | return "uuid:" + UUID.randomUUID().toString().toUpperCase(); 46 | } 47 | 48 | public String getTimeout() { 49 | return timeout; 50 | } 51 | 52 | public void setTimeout(String timeout) { 53 | this.timeout = timeout; 54 | } 55 | 56 | public int getEnvelopSize() { 57 | return envelopSize; 58 | } 59 | 60 | public void setEnvelopSize(int envelopSize) { 61 | this.envelopSize = envelopSize; 62 | } 63 | 64 | public String getLocale() { 65 | return locale; 66 | } 67 | 68 | public void setLocale(String locale) { 69 | this.locale = locale; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/alibabacloud/jenkins/ecs/win/winrm/soap/HeaderBuilder.java: -------------------------------------------------------------------------------- 1 | package com.alibabacloud.jenkins.ecs.win.winrm.soap; 2 | 3 | import java.net.URI; 4 | import java.util.ArrayList; 5 | import java.util.Collections; 6 | import java.util.List; 7 | 8 | public class HeaderBuilder { 9 | private String to; 10 | private String replyTo; 11 | private String maxEnvelopeSize; 12 | private String timeout; 13 | private String locale; 14 | private String id; 15 | private String action; 16 | private String shellId; 17 | private String resourceURI; 18 | private List