Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add artifactory support #2272

Merged
merged 1 commit into from
Sep 5, 2018
Merged

Conversation

jdekonin
Copy link
Contributor

  • adds the capability of reducing footprint on jenkins jobs
    concerning the storage of artifacts

Signed-off-by: Joe deKoning joe_dekoning@ca.ibm.com

@jdekonin
Copy link
Contributor Author

fyi @AdamBrousseau


sh "tar -C build/$RELEASE/images/ -zcvf $SDK_FILENAME ${JDK_FOLDER}"
if (ARTIFACTORY_SERVER) {
echo "ARTIFACTORY server to publish artifacts is: $ARTIFACTORY_SERVER"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since most of your variables are wrapped with braces, can you wrap the rest of them to be consistent.

sh "tar -C build/$RELEASE/images/ -zcvf $SDK_FILENAME ${JDK_FOLDER}"
if (ARTIFACTORY_SERVER) {
echo "ARTIFACTORY server to publish artifacts is: $ARTIFACTORY_SERVER"
def server = Artifactory.server ARTIFACTORY_SERVER
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this variable usage is fine though

echo "Artifactory Upload: $ARTIFACTORY_REPO/${env.JOB_NAME}/${env.BUILD_ID}/"

def buildInfo = Artifactory.newBuildInfo()
buildInfo.retention maxBuilds: 3, deleteBuildArtifacts: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 seems small. I assume this was your WIP number.

// temporarily copy to jenkins until consuming jobs have been updated to pull from artifactory
archiveArtifacts artifacts: "**/${TEST_PREFIX}*${TEST_SUFFIX}", fingerprint: true, onlyIfSuccessful: true
archiveArtifacts artifacts: "**/${SDK_PREFIX}*${SDK_SUFFIX}", fingerprint: true, onlyIfSuccessful: true
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are archiving to Jenkins in both cases, we technically don't need an else yet. Removing it would save defining the archive twice. Once we stop doing both, then we would need the else. Tom-eh-toh/Tom-a-toh I guess.

def downloadSpec = """{
"files": [
{
"pattern": "$ARTIFACTORY_REPO/${params.UPSTREAM_JOB_NAME}/${params.UPSTREAM_JOB_NUMBER}/*.tar.gz",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if we should move the Dir tree to the Variable file since we use it twice. But since we are switching test files to Adopt-test, I assume we would pass them the pattern as a job param. Maybe we should pass it now, rather than hardcode the path twice?

@@ -303,6 +313,9 @@ def set_job_variables(job_type) {
// fetch credentials required to connect to GitHub using ssh protocol
USER_CREDENTIALS_ID = get_git_user_credentials_id()

set_artifactory_server()
set_artifactory_repo()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these be combined into 1 function? Is there a use case where we would only call one or the other?

@jdekonin jdekonin changed the title Add artifactory support WIP: Add artifactory support Aug 8, 2018
@jdekonin jdekonin force-pushed the artifactory branch 20 times, most recently from 45eabfb to 2a1ed9a Compare August 14, 2018 22:22
@jdekonin jdekonin changed the title WIP: Add artifactory support Add artifactory support Aug 14, 2018
@jdekonin
Copy link
Contributor Author

This is ready for review. @AdamBrousseau @llxia

Copy link
Contributor

@AdamBrousseau AdamBrousseau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ref co-change adoptium/aqa-tests#512

returnStdout: true
).trim()
TEST_FILENAME = "${TEST_PREFIX}${TESTSHA}${TEST_SUFFIX}"
sh "tar -zcvf ${TEST_FILENAME} openj9/test/"
Copy link
Contributor

@AdamBrousseau AdamBrousseau Aug 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if this could be removed but we still have a few jobs not using the Adopt test scripts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to clarify that with @llxia that the test.jar isn't required anymore. I believe the only jobs that depend on that any longer are JDK9 which @pshipton has asked to be turned off from nightly builds.

Update: There are also a few windows jobs, but those need to be updated to work in the openjdk-test manner.

archiveArtifacts artifacts: "**/${TEST_PREFIX}*${TEST_SUFFIX}", fingerprint: true, onlyIfSuccessful: true
sh "tar -C build/$RELEASE/images/ -zcvf ${SDK_PREFIX}`date +%Y%d%m%H%M`${SDK_SUFFIX} ${JDK_FOLDER}"
archiveArtifacts artifacts: "**/${SDK_PREFIX}*${SDK_SUFFIX}", fingerprint: true, onlyIfSuccessful: true
SDK_FILENAME = "${SDK_PREFIX}${env.BUILD_ID}${SDK_SUFFIX}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why we are switching from date +%Y%d%m%H%M to BUILD_ID?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can revert, I did that to keep the filename simple. The upload and directory naming need a conversation at a broader level once put into use. Having a datestamp in the filename attached as a jenkins artifact is irrelevant as all that information is attached to the job.

def uploadSpec = """{
"files":[
{
"pattern": "${env.WORKSPACE}/*gz",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use SDK_SUFFIX instead of hardcoding *gz? Since TEST_SUFFIX is the same and will be disappearing soon. When we remove the test stuff this could become SDK_FILENAME too

}"""

def buildInfo = Artifactory.newBuildInfo()
// hardcoded to 20 for now, this need fup for usage on per platform level or across all jobs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo? fup


def buildInfo = Artifactory.newBuildInfo()
// hardcoded to 20 for now, this need fup for usage on per platform level or across all jobs
buildInfo.retention maxBuilds: 30, deleteBuildArtifacts: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm, this retention policy is on a per job name basis correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

jobs["${TEST_JOB_NAME}"] = build_with_one_upstream(TEST_JOB_NAME, BUILD_JOB_NAME, jobs["build"].getNumber(), params.VARIABLE_FILE, params.VENDOR_REPO, params.VENDOR_BRANCH, params.VENDOR_CREDENTIALS_ID, params.TEST_NODE, OPENJ9_REPO, OPENJ9_BRANCH, SHAS['OPENJ9'], VENDOR_TEST_REPOS, VENDOR_TEST_BRANCHES, VENDOR_TEST_SHAS, VENDOR_TEST_DIRS, USER_CREDENTIALS_ID, BUILD_LIST)
if (ARTIFACTORY_SERVER) {
jobs["${TEST_JOB_NAME}"] = build_with_one_upstream(TEST_JOB_NAME, "", "", params.VARIABLE_FILE, params.VENDOR_REPO, params.VENDOR_BRANCH, params.VENDOR_CREDENTIALS_ID, params.TEST_NODE, OPENJ9_REPO, OPENJ9_BRANCH, SHAS['OPENJ9'], VENDOR_TEST_REPOS, VENDOR_TEST_BRANCHES, VENDOR_TEST_SHAS, VENDOR_TEST_DIRS, USER_CREDENTIALS_ID, BUILD_LIST, CUSTOMIZED_SDK_URL, ARTIFACTORY_CREDS)
} else {
Copy link
Contributor

@AdamBrousseau AdamBrousseau Aug 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this if else necessary? Do the Artifactory variables get set to null and can we pass them no matter if they have a real value or not?

Edit: Now I see you also pass "" for the UPSTREAM_JOB* variables. I suppose this works but we can simplify it once we fully switch to Adopt test scripts.

Edit: Its not about Adopt test scripts, its about supporting both Artifactory and Master archiving. I wonder if it should be calling a different function that has slightly different params?

@@ -217,6 +219,7 @@ def workflow(SDK_VERSION, SPEC, SHAS, OPENJDK_REPO, OPENJDK_BRANCH, OPENJ9_REPO,
def BUILD_JOB_NAME = "Build-JDK${SDK_VERSION}-${SPEC}"
jobs["build"] = build(BUILD_JOB_NAME, OPENJDK_REPO, OPENJDK_BRANCH, SHAS['OPENJDK'], OPENJ9_REPO, OPENJ9_BRANCH, SHAS['OPENJ9'], OMR_REPO, OMR_BRANCH, SHAS['OMR'], params.VARIABLE_FILE, params.VENDOR_REPO, params.VENDOR_BRANCH, params.VENDOR_CREDENTIALS_ID, params.BUILD_NODE)
echo "JOB: ${BUILD_JOB_NAME} PASSED in: ${jobs['build'].getDurationString()}"
def CUSTOMIZED_SDK_URL = "${ARTIFACTORY_BASE_URL}/${BUILD_JOB_NAME}/${jobs["build"].getNumber()}/OpenJ9-JDK${SDK_VERSION}-${SPEC}-${jobs["build"].getNumber()}.tar.gz"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is SDK_NAME available at this point in time? ref back to my comment about changing from date to BUILD_ID

@@ -394,6 +404,7 @@ def set_job_variables(job_type) {

// fetch credentials required to connect to GitHub using ssh protocol
set_user_credentials()
set_artifactory_config()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this technically only needs to be done for case "build" or "test"? Is it worth moving it? Can likely remove it from test case too once we only use Adopt test scripts.

@AdamBrousseau
Copy link
Contributor

May need to figure out tagging levels shortly after we merge this. Anyone wanting to pull "nightlies" will need to pull the right level and not a developer build.

@AdamBrousseau
Copy link
Contributor

this is in regards to the build system pulling specific builds

No, the build system is fine and will know what to pull. My comment is regarding anyone, manually or automatically, wanting to pull binaries outside of our build system for other testing purposes. They currently won't be able to determine what "build" they're getting.

@jdekonin
Copy link
Contributor Author

@AdamBrousseau I believe this is now ready for review. I can walk you through the testing that I performed in sandbox jobs if you want to see the changes in action.

Copy link
Contributor

@AdamBrousseau AdamBrousseau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good on initial pass. Will looks at the test cases next


SDK_SUFFIX = ".tar.gz"
TEST_PREFIX = "test-"
TEST_SUFFIX = ".tar.gz"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are no longer needed

SDK_FILENAME = params.SDK_FILENAME
if (!SDK_FILENAME) {
try{
SDK_PREFIX = "OpenJ9-JDK${SDK_VERSION}-PR${ghprbPullId}-${SPEC}-"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't archive PRs anymore so we might as well remove this while we're here. Can likely merge Prefix and Suffix into the SDK_FILENAME declaration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes made in latest push

Copy link
Contributor

@AdamBrousseau AdamBrousseau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor nits, other than that LGTM.


def buildInfo = Artifactory.newBuildInfo()
// hardcoded to 30 for now, this need follow up for usage on per platform level or across all jobs
buildInfo.retention maxBuilds: 30, deleteBuildArtifacts: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TEST_PREFIX = "test-"
TEST_SUFFIX = ".tar.gz"


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some whitespaces here

jobs["${TEST_JOB_NAME}"] = build_with_one_upstream(TEST_JOB_NAME, BUILD_JOB_NAME, jobs["build"].getNumber(), params.VARIABLE_FILE, params.VENDOR_REPO, params.VENDOR_BRANCH, params.VENDOR_CREDENTIALS_ID, params.TEST_NODE, OPENJ9_REPO, OPENJ9_BRANCH, SHAS['OPENJ9'], VENDOR_TEST_REPOS, VENDOR_TEST_BRANCHES, VENDOR_TEST_SHAS, VENDOR_TEST_DIRS, USER_CREDENTIALS_ID, BUILD_LIST)
if (ARTIFACTORY_SERVER) {
def CUSTOMIZED_SDK_URL = "${ARTIFACTORY_BASE_URL}/${BUILD_JOB_NAME}/${jobs["build"].getNumber()}/${SDK_FILENAME}"
echo "Using CUSTOMIZED_SDK_URL = ${CUSTOMIZED_SDK_URL}, ARTIFACTORY_CREDS = ${ARTIFACTORY_CREDS}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra whitespace at the end of the line

def CUSTOMIZED_SDK_URL = "${ARTIFACTORY_BASE_URL}/${BUILD_JOB_NAME}/${jobs["build"].getNumber()}/${SDK_FILENAME}"
echo "Using CUSTOMIZED_SDK_URL = ${CUSTOMIZED_SDK_URL}, ARTIFACTORY_CREDS = ${ARTIFACTORY_CREDS}"
jobs["${TEST_JOB_NAME}"] = build_with_artifactory(TEST_JOB_NAME, params.VARIABLE_FILE, params.VENDOR_REPO, params.VENDOR_BRANCH, params.VENDOR_CREDENTIALS_ID, params.TEST_NODE, OPENJ9_REPO, OPENJ9_BRANCH, SHAS['OPENJ9'], VENDOR_TEST_REPOS, VENDOR_TEST_BRANCHES, VENDOR_TEST_SHAS, VENDOR_TEST_DIRS, USER_CREDENTIALS_ID, BUILD_LIST, CUSTOMIZED_SDK_URL, ARTIFACTORY_CREDS)
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra whitespace at the end of the line

// hardcoded to 30 for now, this need follow up for usage on per platform level or across all jobs
buildInfo.retention maxBuilds: 30, deleteBuildArtifacts: true
server.upload spec: uploadSpec, buildInfo: buildInfo
server.publishBuildInfo buildInfo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra whitespace at the end of the line

returnStdout: true
).trim()
SDK_FILENAME = "OpenJ9-JDK${SDK_VERSION}-${SPEC}-${DATESTAMP}.tar.gz"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't hurt to add an echo of the filename here outside the IF

"files":[
{
"pattern": "${env.WORKSPACE}/${SDK_FILENAME}",
"target": "${ARTIFACTORY_REPO}/${env.JOB_NAME}/${env.BUILD_ID}/"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to add Jenkins server name. For example, ${ARTIFACTORY_REPO}/${Jenkins_Server}/${env.JOB_NAME}/${env.BUILD_ID}/

With different Jenkins servers uploading to the same Artifactory, if we only identify them by job name and build id, we will have override issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Joe decided to hardcode it in the Variable file. By default, JENKINS_URL is a full https url so you need to parse it in order get "JENKINS_SERVER". The latter would be more future proof. I believe I've seen your code for this somewhere.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, JENKINS_URL is a full https url which is not ideal to use as folder name. Below is the code that I used before.

        def strs = env.HUDSON_URL.split( ':' )
        def url = strs[1].split( '//' )
        def serverName = "undefined"
        if (url && url.length>1) {
            serverName = url[1]
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is enforcing a directory structure through code that might not be desired. Setting that via the variable file promotes flexibility of use. Example...

#========================================#
# Artifactory settings
#========================================#
artifactory_server: 'artifactoryserver.companyname.com
artifactory_repo: '<repo name>[/<jenkins server or other directory naming if desired>]'
artifactory_creds: 'acbd1234-a1b2-1234-5678-123abc456def'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we had a combination of the 2?
i.e. Write a function to populate JENKINS_SERVER as a global variable. Then use the variable name in the yml file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I am ok with it. All I am saying is that by including Jenkins server name, we will be more future proof. I have already encountered similar issue in Test Result Summary Service, where we need to monitor two Jenkins servers and they have same build names. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talked to Joe. Came to the understanding that the current directory structure is temporary and we are not sure how it will change. I think its fine to leave the change as is for now and rework it as needed when we decide how we're going to change it.

* adds the capability of reducing footprint on jenkins jobs
    concerning the storage of artifacts
* [skip ci]

Signed-off-by: Joe deKoning <joe_dekoning@ca.ibm.com>
@jdekonin
Copy link
Contributor Author

Last push 29f1050 is a rebase of master plus the minor whitespace and echo output @AdamBrousseau pointed out.

@llxia llxia merged commit b36fb07 into eclipse-openj9:master Sep 5, 2018
AdamBrousseau added a commit to AdamBrousseau/openj9 that referenced this pull request Sep 5, 2018
Related eclipse-openj9#2272
[skip ci]

Signed-off-by: Adam Brousseau <adam.brousseau88@gmail.com>
AdamBrousseau added a commit to AdamBrousseau/openj9 that referenced this pull request Jun 11, 2019
- We no longer run our own testing so this
  code is no longer needed.
- Remove PullRequest pipelines as they are no longer in use.
- Combine 'build' and 'pullRequest' variable setup cases
  as they are identical.
- Also remove temp reverse spec map used prior to eclipse-openj9#2836.

Related eclipse-openj9#1450
Depends eclipse-openj9#2728 eclipse-openj9#2638 eclipse-openj9#2467 eclipse-openj9#2272 eclipse-openj9#2836 eclipse-openj9#4443
[skip ci]
Signed-off-by: Adam Brousseau <adam.brousseau88@gmail.com>
@jdekonin jdekonin deleted the artifactory branch December 11, 2019 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants