Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inject deployment env variables in the build
[FIXED JENKINS-33988] Inject deployment env variables in the build
- Loading branch information
Showing
3 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/main/java/org/jenkinsci/plugins/deployment/HostRecords.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright 2015 Felix Belzunce Arcos. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
package org.jenkinsci.plugins.deployment; | ||
|
||
import hudson.EnvVars; | ||
import hudson.model.AbstractBuild; | ||
import hudson.model.EnvironmentContributingAction; | ||
import hudson.model.InvisibleAction; | ||
import org.apache.commons.lang.StringUtils; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
/** | ||
* Injects the deployment environment variables into the build | ||
* @since May 8, 2015 | ||
* @version TODO | ||
*/ | ||
public class HostRecords extends InvisibleAction implements EnvironmentContributingAction { | ||
private final @Nonnull Collection<HostRecord> hostrecords; | ||
|
||
public HostRecords(@Nonnull Collection<HostRecord> hostRecords) { | ||
this.hostrecords = hostRecords; | ||
} | ||
|
||
public @Nonnull Collection<HostRecord> getHostrecords() { | ||
return hostrecords; | ||
} | ||
|
||
public void buildEnvVars(AbstractBuild<?, ?> abstractBuild, EnvVars envVars) { | ||
@Nonnull final List<String> deploymentEnv = new ArrayList(); | ||
@Nonnull final List<String> deploymentHost = new ArrayList(); | ||
@Nonnull final List<String> deploymentPath = new ArrayList(); | ||
@Nonnull final List<String> deploymentTimeStamp = new ArrayList(); | ||
|
||
Collection<HostRecord> hostRecords = getHostrecords(); | ||
|
||
for (HostRecord hostRecord : hostRecords) { | ||
deploymentEnv.add(hostRecord.getEnv()); | ||
deploymentHost.add(hostRecord.getHost()); | ||
deploymentPath.add(hostRecord.getPath()); | ||
deploymentTimeStamp.add(hostRecord.getTimestampString()); | ||
} | ||
envVars.put("DEPLOYMENT_ENV", StringUtils.join(deploymentEnv, ",")); | ||
envVars.put("DEPLOYMENT_HOST", StringUtils.join(deploymentHost, ",")); | ||
envVars.put("DEPLOYMENT_PATH", StringUtils.join(deploymentPath, ",")); | ||
envVars.put("DEPLOYMENT_TIMESTAMP", StringUtils.join(deploymentTimeStamp, ",")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63a9cd8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
จากการนำเข้า linepy *
จาก liff.ttypes นำเข้า LiffChatContext, LiffContext, LiffSquareChatContext, LiffNoneContext, LiffViewRequest
จาก akad.ttypes นำเข้าข้อความ
จาก akad.ttypes อิมพอร์ต ContentType เป็น Type
จาก akad.ttypes นำเข้า TalkException
จาก datetime นำเข้า datetime, timedelta
จากเวลานำเข้านอนหลับ
จาก bs4 นำเข้า BeautifulSoup เป็น bSoup
จาก bs4 นำเข้า BeautifulSoup
จาก humanfriendly นำเข้า format_timespan, format_size, format_number, format_length
จาก gtts นำเข้า gTTS
จากเธรดนำเข้าเธรด
จาก io นำเข้า StringIO
จากพูลการนำเข้าแบบหลายกระบวนการ
จากนักแปลนำเข้า googletrans
จาก urllib.parse นำเข้า urlencode
จากการนำเข้า tmp.MySplit *
จากการนำเข้าสุ่มrandint
จาก copyfile นำเข้า shutil
จาก youtube_dl นำเข้า YoutubeDL
นำเข้ากระบวนการย่อย, youtube_dl, เป็นมนุษย์, ติดตามย้อนกลับ
นำเข้ากระบวนการย่อยเป็น cmd
แพลตฟอร์มนำเข้า
คำขอนำเข้า json
เวลานำเข้า , สุ่ม, sys, json, null, pafy, codecs, html5lib, shutil, เกลียว, glob, re, base64, สตริง, ระบบปฏิบัติการ, การร้องขอ, หก, ast, pytz, วิกิพีเดีย, urllib, arllib, asyncio , ตรวจสอบย้อนกลับ
_session =ร้องขอ. session ()
ลอง :
นำเข้า urllib.request เป็น urllib2
ยกเว้น ImportError :
นำเข้า urllib2